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

import java.time.OffsetDateTime;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;

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

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "entity")
public class TypeEntity {

    @Id
    private String id;
    @Column
    private String type;
    @Column
    private String label;
    @Column
    private String hexColor;
    @Column
    private String recommendationHexColor;
    @Column
    private String skippedHexColor;
    @Column
    private int rank;
    @Column
    private boolean isHint;
    @Column
    private boolean isCaseInsensitive;
    @Column
    private boolean isRecommendation;
    @Column(length = 4000)
    private String description;
    @Column
    private long version;
    @Column
    private boolean addToDictionaryAction;
    @Column
    private boolean hasDictionary;
    @Column
    private boolean systemManaged;
    @Column
    private boolean autoHideSkipped;
    @Column
    private OffsetDateTime softDeletedTime;

    @Column
    private boolean dossierDictionaryOnly;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dossier_template_id")
    private DossierTemplateEntity dossierTemplate;

    @Column(updatable = false, insertable = false, name = "dossier_template_id")
    private String dossierTemplateId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dossier_id")
    private DossierEntity dossier;

    @Column(updatable = false, insertable = false, name = "dossier_id")
    private String dossierId;


    public boolean isDeleted() {

        return this.softDeletedTime != null;
    }

}
