package com.megatim.fdxconsultation.model.stats; import com.megatim.fdxcommons.model.search.CriteriaEntitySearch; import com.megatim.fdxconsultation.model.base.BaseEntity; import com.megatim.fdxcommons.model.enumeration.FonctionAggregation; import com.megatim.fdxconsultation.model.enums.TypeResultatConfiguration; import java.io.Serializable; import java.util.HashSet; import java.util.Objects; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.OneToOne; import javax.persistence.SequenceGenerator; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; /** * * @author ASUS */ @Getter @Setter @Entity @NoArgsConstructor public class TableConfiguration extends BaseEntity implements Serializable { @Id @SequenceGenerator(name = "SEQ_TABLE_CONF", sequenceName = "SEQ_TABLE_CONF", allocationSize = 1, initialValue = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_TABLE_CONF") private Long id; @NotEmpty(message = "Le libellé est obligatoire") private String libelle; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "targeted_column_id", referencedColumnName = "id") private TableauBordColumn targetedColumn; @OneToMany(mappedBy = "tableConfiguration", cascade = CascadeType.ALL) private Set groupingColumns = new HashSet<>(); @Enumerated(EnumType.STRING) @NotNull(message = "La fonction d'aggrégation est obligatoire") private FonctionAggregation fonctionAggregation; @Enumerated(EnumType.STRING) @CriteriaEntitySearch(libelle = "Type de Résultat") private TypeResultatConfiguration typeResultatConfiguration; @ManyToOne @JoinColumn(name = "tableaubord_id", referencedColumnName = "id") private TableauBord tableauBord; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "criterion_id", referencedColumnName = "id") private CriteriaEntityPersisted criterion; private String color = "#527ccc"; @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "fonctionAggCriterion_id", referencedColumnName = "id") private FonctionAggregationCriterion fonctionAggregationCriterion; @Override public int hashCode() { int hash = 3; hash = 71 * hash + Objects.hashCode(this.libelle); return hash; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final TableConfiguration other = (TableConfiguration) obj; return Objects.equals(this.libelle, other.libelle); } }