You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
2.3 KiB
Java
106 lines
2.3 KiB
Java
package info.bukova.isspst.data;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import javax.persistence.Column;
|
|
import javax.persistence.Entity;
|
|
import javax.persistence.JoinColumn;
|
|
import javax.persistence.JoinTable;
|
|
import javax.persistence.ManyToMany;
|
|
import javax.persistence.Table;
|
|
|
|
import org.hibernate.annotations.LazyCollection;
|
|
import org.hibernate.annotations.LazyCollectionOption;
|
|
import org.springframework.security.core.GrantedAuthority;
|
|
|
|
@Entity
|
|
@Table(name="ROLE")
|
|
public class Role extends BaseSimpleData implements GrantedAuthority, DataModel {
|
|
|
|
/**
|
|
*
|
|
*/
|
|
private static final long serialVersionUID = 5677876140880991163L;
|
|
|
|
@Column(name="AUTHORITY", unique=true)
|
|
private String authority;
|
|
@Column(name="DESCRIPTION")
|
|
private String description;
|
|
@ManyToMany
|
|
@LazyCollection(LazyCollectionOption.FALSE)
|
|
@JoinTable(name="ROLE_PERMISSION", joinColumns={@JoinColumn(name="ROLE_ID")}, inverseJoinColumns={@JoinColumn(name="PERMISSION_ID")})
|
|
private List<Permission> permissions;
|
|
@Column(name = "WORKGROUP")
|
|
private boolean workgroup;
|
|
@Column(name = "CENTRE")
|
|
private boolean centre;
|
|
|
|
public Role(String authority, String description) {
|
|
this();
|
|
this.authority = authority;
|
|
this.description = description;
|
|
}
|
|
|
|
public Role() {
|
|
this.permissions = new ArrayList<Permission>();
|
|
centre = false;
|
|
workgroup = false;
|
|
}
|
|
|
|
@Override
|
|
public String getAuthority() {
|
|
return authority;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public void setAuthority(String authority) {
|
|
this.authority = authority;
|
|
}
|
|
|
|
public List<Permission> getPermissions() {
|
|
return permissions;
|
|
}
|
|
|
|
public void setPermissions(List<Permission> permissions) {
|
|
this.permissions = permissions;
|
|
}
|
|
|
|
public void addPermission(Permission permission) {
|
|
this.permissions.add(permission);
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if ((o instanceof Role) && ((Role)o).getId() == this.getId()) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public boolean isWorkgroup() {
|
|
return workgroup;
|
|
}
|
|
|
|
public void setWorkgroup(boolean workgroup) {
|
|
this.workgroup = workgroup;
|
|
}
|
|
|
|
public boolean isCentre() {
|
|
return centre;
|
|
}
|
|
|
|
public void setCentre(boolean centre) {
|
|
this.centre = centre;
|
|
}
|
|
|
|
}
|