package space.nstart.pcp.complan.db.entity

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.EnumType
import jakarta.persistence.Enumerated
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import space.nstart.pcp.pcp_types_lib.dto.ballistics.RevolutionSign
import java.util.UUID

@Table(name = "dynamic_plan_interval")
@Entity
class DynamicPlanIntervalEntity(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    var id: Long? = null,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "run_id", nullable = false)
    var run: DynamicPlanRunEntity? = null,

    @Column(name = "request_id", nullable = false)
    var requestId: UUID? = null,

    @Column(name = "interval_id", nullable = false)
    var intervalId: UUID? = null,

    @Column(name = "region_id", nullable = false)
    var regionId: UUID? = null,

    @Enumerated(EnumType.STRING)
    @Column(name = "rev_sign", nullable = false)
    var revSign: RevolutionSign = RevolutionSign.ASC,

    @Column(name = "contour_wkt", nullable = false, columnDefinition = "TEXT")
    var contourWkt: String = "",

    @Column(name = "observation_parameters_count", nullable = false)
    var observationParametersCount: Int = 0,

    @Column(name = "interval_order", nullable = false)
    var intervalOrder: Int = 0
) {
    constructor() : this(id = null)
}
