package com.iqser.red.service.persistence.management.v1.processor.entity.annotations;

import java.time.OffsetDateTime;
import java.util.HashSet;
import java.util.Set;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "manual_recategorization")
public class ManualRecategorizationEntity implements IBaseAnnotation {

    public static final int MAX_LEGAL_BASIS_LENGTH = 4000;
    public static final int MAX_SECTION_LENGTH = 1024;

    @EmbeddedId
    private AnnotationEntityId id;
    @Column(name = "user_id")
    private String user;
    @Column
    private String typeId;
    @Column
    private OffsetDateTime requestDate;
    @Column
    private OffsetDateTime processedDate;
    @Column
    private OffsetDateTime softDeletedTime;
    @Column
    private int page;
    @Column
    private boolean addToDictionary;
    @Column
    private boolean addToAllDossiers;
    @Column(length = MAX_LEGAL_BASIS_LENGTH)
    private String legalBasis;
    @Column(length = MAX_SECTION_LENGTH)
    private String section;
    @Column
    private String value;

    @ManyToOne
    private FileEntity fileStatus;

    @ElementCollection
    @CollectionTable(name = "manual_recategorization_type_ids_of_dictionaries_with_add")
    @Fetch(value = FetchMode.SUBSELECT)
    private Set<String> typeIdsOfDictionariesWithAdd = new HashSet<>();

    @ElementCollection
    @CollectionTable(name = "manual_recategorization_type_ids_of_dictionaries_with_delete")
    @Fetch(value = FetchMode.SUBSELECT)
    private Set<String> typeIdsOfDictionariesWithDelete = new HashSet<>();

}
