package com.megatim.fdxcommons.model.referentiel; import com.fasterxml.jackson.annotation.JsonIgnore; import com.megatim.fdxcommons.model.enumeration.CategorieFichier; import java.io.Serializable; import java.time.LocalDateTime; import java.util.HashSet; import java.util.Objects; import java.util.Set; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import com.megatim.fdxcommons.model.search.CriteriaEntitySearch; /** * * @author ASUS */ @Entity @Getter @Setter @XmlRootElement(name = "typeFichiersList") @XmlAccessorType(XmlAccessType.FIELD) @NoArgsConstructor public class TypeFichier implements Serializable { @Id @CriteriaEntitySearch(libelle = "Code", rang = 1) private String code; @NotEmpty(message = "Le libellé du type de fichier est obligatoire") @CriteriaEntitySearch(libelle = "Libellé", rang = 2) private String libelle; private String description; @ManyToOne @CriteriaEntitySearch(libelle = "Participant", fieldName = "participant.code", rang = 3) private Participant participant; @NotNull(message = "Le type de fichier doit être associé à un référentiel en préparation") @ManyToOne @CriteriaEntitySearch(libelle = "Référentiel", fieldName = "referentiel.version", rang = 4) private Referentiel referentiel; @XmlTransient @JsonIgnore @OneToMany(mappedBy = "typeFichier") private Set routages = new HashSet<>(); @XmlTransient @JsonIgnore @OneToMany(mappedBy = "typeFichier") private Set validateurFichierConfigurations = new HashSet<>(); @XmlTransient @JsonIgnore @OneToMany(mappedBy = "typeFichier") private Set validateurFichiers = new HashSet<>(); @NotNull(message = "La catégorie de fichier est obligatoire") @Enumerated(EnumType.STRING) private CategorieFichier categorieFichier; @NotNull(message = "L'extension du type de fichier est obligatoire") @ManyToOne private ExtensionFichier extensionFichier; @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) private LocalDateTime dateCreation; @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) private LocalDateTime dateMiseAjour; private String createBy; private String lastModifiedBy; @Override public String toString() { return this.getCode() + " - " + this.getLibelle(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof TypeFichier)) { return false; } final TypeFichier other = (TypeFichier) obj; if (this.getCode() != null && !this.getCode().equals(other.getCode())) { return false; } return true; } @Override public int hashCode() { int hash = 3; hash = 17 * hash + Objects.hashCode(this.code); return hash; } }