/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package veolia.core.entities; import java.io.Serializable; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; 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.ManyToMany; import javax.persistence.Table; import org.eclipse.persistence.annotations.CascadeOnDelete; import org.hibernate.validator.constraints.NotEmpty; import veolia.core.enums.EnumPermission; /** * * @author Toto-Works */ @Entity @Table(name="core_permission") public class Permission implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotEmpty(message="Champ action obligatoire") @Column(nullable=false,name="permission_action") private String action; @ManyToMany(mappedBy = "permissions",fetch = FetchType.LAZY, cascade = CascadeType.ALL) @CascadeOnDelete private List users; @ManyToMany(mappedBy = "permissions",fetch = FetchType.LAZY, cascade = CascadeType.ALL) @CascadeOnDelete private List groups; @ManyToMany(mappedBy = "permissions",fetch = FetchType.LAZY, cascade = CascadeType.ALL) @CascadeOnDelete private List features; @ManyToMany(mappedBy = "permissions",fetch = FetchType.LAZY, cascade = CascadeType.ALL) @CascadeOnDelete private List modules; public Long getId() { return id; } public void setId(Long id) { this.id = id; } /** * @return the action */ public String getAction() { return action; } /** * @param action the action to set */ public void setAction(String action) { this.action = action; } /** * @return the users */ public List getUsers() { return users; } /** * @param users the users to set */ public void setUsers(List users) { this.users = users; } /** * @return the groups */ public List getGroups() { return groups; } /** * @param groups the groups to set */ public void setGroups(List groups) { this.groups = groups; } /** * @return the features */ public List getFeatures() { return features; } /** * @param features the features to set */ public void setFeatures(List features) { this.features = features; } /** * @return the modules */ public List getModules() { return modules; } /** * @param modules the modules to set */ public void setModules(List modules) { this.modules = modules; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Permission)) { return false; } Permission other = (Permission) object; return (this.id != null || other.id == null) && (this.id == null || this.id.equals(other.id)); } @Override public String toString() { return "veolia.core.entities.Permission[ id=" + id + " ]"; } }