package com.megatim.apifdxweb.model.administration;
|
|
import com.megatim.fdxcommons.model.enumeration.EtatOperation;
|
import com.megatim.fdxcommons.model.enumeration.TypeOperation;
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Objects;
|
import javax.persistence.Column;
|
import javax.persistence.Entity;
|
import javax.persistence.FetchType;
|
import javax.persistence.GeneratedValue;
|
import javax.persistence.GenerationType;
|
import javax.persistence.Id;
|
import javax.persistence.ManyToMany;
|
import javax.persistence.SequenceGenerator;
|
import javax.persistence.Table;
|
import javax.persistence.Temporal;
|
import javax.persistence.TemporalType;
|
import javax.persistence.EnumType;
|
import javax.persistence.Enumerated;
|
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinTable;
|
import javax.persistence.OneToMany;
|
import javax.validation.constraints.NotEmpty;
|
|
/**
|
*
|
* @author DYNABOOK
|
*/
|
@Entity(name = "Role")
|
@Table(name = "FDX_ROLE")
|
public class Role implements Comparable<Role>, Serializable {
|
|
@SequenceGenerator(name = "SEQ_ROLE",
|
sequenceName = "SEQ_ROLE",
|
allocationSize = 1,
|
initialValue = 1)
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_ROLE")
|
@Column(name = "ID")
|
@Id
|
private Long id;
|
|
@Column(name = "ID_GENERER")
|
protected String idGenerer;
|
|
@Column(nullable = false, name = "libelle")
|
@NotEmpty(message = "Le libellé est obligatoire")
|
private String libelle;
|
|
@Column(name = "description")
|
private String description;
|
|
@Column(name = "TYPE_OPERATION")
|
private TypeOperation typeOperation = TypeOperation.AJOUTER;
|
|
@Column(name = "ETAT_OPERATION")
|
@Enumerated(EnumType.STRING)
|
private EtatOperation etatOperation;
|
|
@Column(name = "IS_ADMIN")
|
private boolean admin = false;
|
|
@Column(name = "IS_SUPER_ADMIN")
|
private boolean superAdmin = false;
|
|
@Column(name = "IS_MEGA_ADMIN")
|
private boolean megaAdmin = false;
|
|
@OneToMany(mappedBy = "role")
|
private List<User> users = new ArrayList<>();
|
|
@ManyToMany(fetch = FetchType.EAGER)
|
@JoinTable(
|
name = "FS_ROLE_ACTION",
|
joinColumns = @JoinColumn(name = "FS_ROLE_ID"),
|
inverseJoinColumns = @JoinColumn(name = "FS_ACTION_ID"))
|
private List<Action> actions = new ArrayList<>();
|
|
@Column(name = "DATE_CREATION")
|
@Temporal(TemporalType.TIMESTAMP)
|
private Date dateCreation;
|
|
@Column(name = "USER_CREATION")
|
private String utilisateurCreation;
|
|
@Column(name = "DATE_DERN_MOD")
|
@Temporal(TemporalType.TIMESTAMP)
|
private Date dateDerniereModification;
|
|
@Column(name = "USER_UPDATE")
|
private String utilisateurModification;
|
|
@Column(name = "DATE_SUPPR")
|
@Temporal(TemporalType.TIMESTAMP)
|
private Date dateSuppression;
|
|
@Column(name = "USER_DELETE")
|
private String utilisateurSuppression;
|
|
public Role() {
|
}
|
|
public Long getId() {
|
return id;
|
}
|
|
public void setId(Long id) {
|
this.id = id;
|
}
|
|
public String getLibelle() {
|
return libelle;
|
}
|
|
public void setLibelle(String libelle) {
|
this.libelle = libelle;
|
}
|
|
public String getDescription() {
|
return description;
|
}
|
|
public void setDescription(String description) {
|
this.description = description;
|
}
|
|
public TypeOperation getTypeOperation() {
|
return typeOperation;
|
}
|
|
public void setTypeOperation(TypeOperation typeOperation) {
|
this.typeOperation = typeOperation;
|
}
|
|
public String getIdGenerer() {
|
return idGenerer;
|
}
|
|
public void setIdGenerer(String idGenerer) {
|
this.idGenerer = idGenerer;
|
}
|
|
public List<Action> getActions() {
|
return actions;
|
}
|
|
public void setActions(List<Action> actions) {
|
this.actions = actions;
|
}
|
|
public Date getDateCreation() {
|
return dateCreation;
|
}
|
|
public void setDateCreation(Date dateCreation) {
|
this.dateCreation = dateCreation;
|
}
|
|
public String getUtilisateurCreation() {
|
return utilisateurCreation;
|
}
|
|
public void setUtilisateurCreation(String utilisateurCreation) {
|
this.utilisateurCreation = utilisateurCreation;
|
}
|
|
public Date getDateDerniereModification() {
|
return dateDerniereModification;
|
}
|
|
public void setDateDerniereModification(Date dateDerniereModification) {
|
this.dateDerniereModification = dateDerniereModification;
|
}
|
|
public String getUtilisateurModification() {
|
return utilisateurModification;
|
}
|
|
public void setUtilisateurModification(String utilisateurModification) {
|
this.utilisateurModification = utilisateurModification;
|
}
|
|
public Date getDateSuppression() {
|
return dateSuppression;
|
}
|
|
public void setDateSuppression(Date dateSuppression) {
|
this.dateSuppression = dateSuppression;
|
}
|
|
public String getUtilisateurSuppression() {
|
return utilisateurSuppression;
|
}
|
|
public boolean isAdmin() {
|
return admin;
|
}
|
|
public void setAdmin(boolean admin) {
|
this.admin = admin;
|
}
|
|
public boolean isSuperAdmin() {
|
return superAdmin;
|
}
|
|
public void setSuperAdmin(boolean superAdmin) {
|
this.superAdmin = superAdmin;
|
}
|
|
public boolean isMegaAdmin() {
|
return megaAdmin;
|
}
|
|
public void setMegaAdmin(boolean megaAdmin) {
|
this.megaAdmin = megaAdmin;
|
}
|
|
public void setUtilisateurSuppression(String utilisateurSuppression) {
|
this.utilisateurSuppression = utilisateurSuppression;
|
}
|
|
public EtatOperation getEtatOperation() {
|
return etatOperation;
|
}
|
|
public void setEtatOperation(EtatOperation etatOperation) {
|
this.etatOperation = etatOperation;
|
}
|
|
public List<User> getUsers() {
|
return users;
|
}
|
|
public void setUsers(List<User> users) {
|
this.users = users;
|
}
|
|
@Override
|
public int hashCode() {
|
int hash = 7;
|
hash = 11 * hash + Objects.hashCode(this.id);
|
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 Role other = (Role) obj;
|
if (!Objects.equals(this.id, other.id)) {
|
return false;
|
}
|
return true;
|
}
|
|
/*
|
* (non-Javadoc)
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
*/
|
@Override
|
public int compareTo(Role parameter) {
|
if (parameter == null) {
|
return -1;
|
}
|
if (parameter.libelle == null || parameter.libelle.trim().length() == 0) {
|
return -1;
|
}
|
if (libelle == null || libelle.trim().length() == 0) {
|
return 1;
|
}
|
return libelle.compareTo(parameter.libelle);
|
}
|
}
|