/* * 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.apifdxweb.model.administration; import com.megatim.fdxcommons.model.enumeration.TypeOperation; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; /** * * @author Leonel FOFOU */ @Entity(name = "Action") @Table(name = "FS_ACTION") public class Action implements Comparable, Serializable { @SequenceGenerator(name = "SEQ_ACTION", sequenceName = "SEQ_ACTION", allocationSize = 1, initialValue = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_ACTION") @Column(name = "ID") @Id private Long id; @Column(name = "path") private String path; @Column(name = "module") private String module; @Column(name = "name") private String name; @Column(name = "categorie") private String categorie; @Column(name = "description") private String description; @Column(name = "autorise") private Boolean autorise; @Column(name = "ID_GENERER") protected String idGenerer; @Column(name = "TYPE_OPERATION") private TypeOperation typeOperation = TypeOperation.AJOUTER; @ManyToMany(mappedBy = "actions") private List roles = new ArrayList(); public Action() { } public Action(String name, String description, String path, String module, Boolean autorise) { this.name = name; this.description = description; this.path = path; this.module = module; this.autorise = autorise; } public Action(String name, String description, String path, String module, String categorie, Boolean autorise) { this.name = name; this.description = description; this.path = path; this.module = module; this.categorie = categorie; this.autorise = autorise; } public Action(String name, String description, String path, String module, Boolean autorise, Role role) { this.name = name; this.description = description; this.path = path; this.module = module; this.autorise = autorise; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getName() { return name; } public void setName(String name) { this.name = name; } public List getRoles() { return roles; } public void setRoles(List roles) { this.roles = roles; } public String getIdGenerer() { return idGenerer; } public void setIdGenerer(String idGenerer) { this.idGenerer = idGenerer; } public TypeOperation getTypeOperation() { return typeOperation; } public void setTypeOperation(TypeOperation typeOperation) { this.typeOperation = typeOperation; } public Boolean getAutorise() { return autorise; } public void setAutorise(Boolean autorise) { this.autorise = autorise; } public String getModule() { return module; } public void setModule(String module) { this.module = module; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getCategorie() { return categorie; } public void setCategorie(String categorie) { this.categorie = categorie; } @Override public int hashCode() { int hash = 7; hash = 79 * 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 Action other = (Action) obj; return Objects.equals(this.id, other.id); } /* * (non-Javadoc) * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override public int compareTo(Action parameter) { // Si le parametre est null if (parameter == null) { return -1; } // Si le code du parametre est vide if (parameter.id == null) { return -1; } // Si le code du parametre en cours est vide if (id == null) { return 1; } // On retourne la comparaison des codes return id.compareTo(parameter.id); } }