package space.nstart.pcp.routepassportconsumer.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import jakarta.persistence.Version
import com.fasterxml.jackson.databind.JsonNode
import org.hibernate.annotations.JdbcTypeCode
import org.hibernate.type.SqlTypes
import java.math.BigDecimal
import java.time.LocalDateTime
import java.util.UUID

@Entity
@Table(name = "route_passports")
class RoutePassportEntity(
    @Id
    @Column(name = "route_id", nullable = false)
    var routeId: UUID,

    @Column(name = "route_name_full", nullable = false, columnDefinition = "TEXT")
    var routeNameFull: String,

    @Column(name = "route_name_short", nullable = false, length = 255)
    var routeNameShort: String,

    @Column(name = "ka_short", nullable = false, length = 64)
    var kaShort: String,

    @Column(name = "ka_full", nullable = false, length = 255)
    var kaFull: String,

    @Column(name = "orbit_number", nullable = false)
    var orbitNumber: Long,

    @Column(name = "orbit_state", nullable = false, length = 64)
    var orbitState: String,

    @Column(name = "interval_begin", nullable = false)
    var intervalBegin: LocalDateTime,

    @Column(name = "interval_end", nullable = false)
    var intervalEnd: LocalDateTime,

    @Column(name = "roll_angle_min", nullable = false)
    var rollAngleMin: BigDecimal,

    @Column(name = "roll_angle_max", nullable = false)
    var rollAngleMax: BigDecimal,

    @Column(name = "visir_angle_min", nullable = false)
    var visirAngleMin: BigDecimal,

    @Column(name = "visir_angle_max", nullable = false)
    var visirAngleMax: BigDecimal,

    @Column(name = "resolution_range", nullable = false)
    var resolutionRange: BigDecimal,

    @Column(name = "resolution_azimuth", nullable = false)
    var resolutionAzimuth: BigDecimal,

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "polarisation", nullable = false, columnDefinition = "jsonb")
    var polarisation: JsonNode,

    @Column(name = "processing_level", nullable = false, length = 64)
    var processingLevel: String,

    @Column(name = "geometry_wkt", nullable = false, columnDefinition = "TEXT")
    var geometryWkt: String,

    @Column(name = "route_status", nullable = false, length = 32)
    var routeStatus: String,

    @Column(name = "trace_id", length = 255)
    var traceId: String? = null,

    @Column(name = "correlation_id", length = 255)
    var correlationId: String? = null,

    @Column(name = "source_topic", length = 255)
    var sourceTopic: String? = null,

    @Column(name = "source_partition")
    var sourcePartition: Int? = null,

    @Column(name = "source_offset")
    var sourceOffset: Long? = null,

    @Column(name = "source_key", length = 255)
    var sourceKey: String? = null,

    @JdbcTypeCode(SqlTypes.JSON)
    @Column(name = "raw_payload", columnDefinition = "jsonb")
    var rawPayload: JsonNode? = null,

    @Column(name = "created_at", nullable = false)
    var createdAt: LocalDateTime,

    @Column(name = "updated_at", nullable = false)
    var updatedAt: LocalDateTime,

    @Version
    @Column(name = "version", nullable = false)
    var version: Long = 0,
)
