/* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template */ 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.CascadeType; import javax.persistence.Entity; 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; /** * * @author ASUS */ @Entity @Getter @Setter @NoArgsConstructor @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class ApplicationSource implements Serializable { @Id @NotEmpty(message = "Le libellé obligatoire") private String libelle; private String description; @NotNull(message = "L'application source doit être associée à un réfrérentiel en préparation") @ManyToOne private Referentiel referentiel; @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) private LocalDateTime dateCreation; @XmlJavaTypeAdapter(LocalDateTimeAdapter.class) private LocalDateTime dateMiseAjour; private String createBy; private String lastModifiedBy; @OneToMany(mappedBy = "applicationSource", cascade = CascadeType.ALL) @XmlTransient @JsonIgnore private Set structureLignes = new HashSet<>(); @Override public String toString() { return this.getLibelle(); } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ApplicationSource other = (ApplicationSource) obj; if (this.getLibelle() != null && !this.getLibelle().equals(other.getLibelle())) { return false; } return true; } @Override public int hashCode() { int hash = 5; hash = 19 * hash + Objects.hashCode(this.libelle); return hash; } }