package com.megatim.fdxcommons.model.referentiel;
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
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.Id;
|
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinTable;
|
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToOne;
|
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.Size;
|
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
|
@NoArgsConstructor
|
@XmlRootElement(name = "groupeParticipants")
|
@XmlAccessorType(XmlAccessType.FIELD)
|
public class GroupeParticipant implements Serializable {
|
|
@Id
|
@NotEmpty(message = "Code obligatoire")
|
@CriteriaEntitySearch(libelle = "Code", rang = 1)
|
private String code;
|
|
@NotEmpty(message = "Libellé obligatoire")
|
@CriteriaEntitySearch(libelle = "Libellé", rang = 2)
|
private String libelle;
|
|
private String description;
|
|
@NotNull(message = "Le groupe de participants doit être associé à un référentiel en préparation")
|
@ManyToOne
|
@CriteriaEntitySearch(libelle = "Référentiel", fieldName = "referentiel.version", rang = 3)
|
private Referentiel referentiel;
|
|
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
|
private LocalDateTime dateCreation;
|
|
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
|
private LocalDateTime dateMiseAjour;
|
|
private String createBy;
|
|
private String lastModifiedBy;
|
@Size(min = 1, message = "Un participant doit au moins être sélectionné")
|
@ManyToMany
|
@JoinTable(
|
name = "grpe_pct_ass",
|
joinColumns = @JoinColumn(name = "groupe_id"),
|
inverseJoinColumns = @JoinColumn(name = "participant_id"))
|
private Set<Participant> participants = new HashSet<>();
|
|
@XmlTransient
|
@JsonIgnore
|
@ManyToMany(mappedBy = "groupeParticipantsEnvoi")
|
private Set<Routage> routageEnvois = new HashSet<>();
|
|
@XmlTransient
|
@JsonIgnore
|
@ManyToMany(mappedBy = "groupeParticipantsReception")
|
private Set<Routage> routageReceptions = new HashSet<>();
|
|
@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 GroupeParticipant)) {
|
return false;
|
}
|
final GroupeParticipant other = (GroupeParticipant) obj;
|
if (this.getCode() != null && !this.getCode().equals(other.getCode())) {
|
return false;
|
}
|
return true;
|
}
|
|
@Override
|
public int hashCode() {
|
int hash = 7;
|
hash = 97 * hash + Objects.hashCode(this.code);
|
return hash;
|
}
|
|
}
|