package io.gmss.fiscad.entities.infocad.metier;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import io.gmss.fiscad.entities.BaseEntity;
import io.gmss.fiscad.entities.infocad.parametre.Personne;
import io.gmss.fiscad.entities.infocad.parametre.PositionRepresentation;
import io.gmss.fiscad.entities.infocad.parametre.TypeContestation;
import io.gmss.fiscad.entities.infocad.parametre.TypeRepresentation;
import io.gmss.fiscad.enums.RoleActeur;
import io.gmss.fiscad.enums.TypeDroit;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import java.io.Serializable;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
//@SQLDelete(sql =
//        "UPDATE acteur_concerne " +
//                "SET deleted = true " +
//                "WHERE id = ?")
//@Where(clause = " deleted = false")
public class ActeurConcerne extends BaseEntity implements Serializable {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String observation;
    @Enumerated(EnumType.STRING)
    private TypeDroit typeDroit;
    private float part;
    @ManyToOne
    private TypeRepresentation typeRepresentation;
    @ManyToOne
    private PositionRepresentation positionRepresentation;
    @ManyToOne
    private Personne personne;
    private Long personneExternalKey;
    @ManyToOne
    private TypeContestation typeContestation;

    @JsonIgnore
    @ManyToOne
    private Enquete enquete;
    @Enumerated(EnumType.STRING)
    private RoleActeur roleActeur;

    @OneToMany(mappedBy = "acteurConcerne")
    @JsonManagedReference
    private List<Piece> pieces;

    @JsonIgnore
    @ManyToOne
    private Tpe terminal;
    @Column(nullable = false, columnDefinition = "BOOLEAN DEFAULT false")
    private boolean synchronise;
    //////////////////////////////
    private Long blocId;
    @ColumnDefault("0")
    private int haveDeclarant;
    private Long max_numero_acteur_concerne_id;
    private Long mobileDataId;

}
