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 com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;

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

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

    @EmbeddedId
    private AnnotationEntityId id;
    @Column(name = "user_id")
    private String user;
    @Column
    @Enumerated(EnumType.STRING)
    private AnnotationStatus status;
    @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;

    @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<>();

}
