package net.ihe.xds.users.model; import java.io.Serializable; import java.util.Set; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.SequenceGenerator; import javax.persistence.Table; import org.hibernate.validator.NotNull; import org.jboss.seam.annotations.security.management.RoleConditional; import org.jboss.seam.annotations.security.management.RoleGroups; import org.jboss.seam.annotations.security.management.RoleName; /** * * @author abderrazek boufahja * */ @Entity @Table(name = "user_role") @SequenceGenerator(name = "user_role_sequence", sequenceName = "user_role_id_seq", allocationSize = 1) public class UserRole implements Serializable { private static final long serialVersionUID = 9177366120789064801L; public static final String ADMINISTRATOR_ROLE = "admin"; private Long id; private String name; private boolean conditional; private Set groups; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "user_role_sequence") public Long getId() { return id; } public void setId(Long id) { this.id = id; } @RoleName @NotNull public String getName() { return name; } public void setName(String name) { this.name = name; } @RoleGroups @ManyToMany @JoinTable(name = "user_role_group", joinColumns = @JoinColumn(name = "role_id"), inverseJoinColumns = @JoinColumn(name = "member_of_role")) public Set getGroups() { return groups; } public void setGroups(Set groups) { this.groups = groups; } @RoleConditional public boolean isConditional() { return conditional; } public void setConditional(boolean conditional) { this.conditional = conditional; } }