package com.betriebsratkanzlei.legalconsenthub.form_element

import com.betriebsratkanzlei.legalconsenthub.application_form.ApplicationForm
import jakarta.persistence.CascadeType
import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.GeneratedValue
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.OneToMany
import jakarta.persistence.OrderColumn
import java.util.UUID

@Entity
class FormElementSection(
    @Id
    @GeneratedValue
    var id: UUID? = null,
    @Column(nullable = false)
    var title: String,
    var shortTitle: String? = null,
    var description: String? = null,
    @OneToMany(mappedBy = "formElementSection", cascade = [CascadeType.ALL], orphanRemoval = true)
    @OrderColumn(name = "form_element_order")
    var formElements: MutableList<FormElement> = mutableListOf(),
    @ManyToOne
    @JoinColumn(name = "application_form_id", nullable = false)
    var applicationForm: ApplicationForm? = null,
)
