public class Role extends BaseOpenmrsMetadata implements Serializable
Privileges. Users contain a number of roles
(Users DO NOT contain any privileges directly) Roles can be grouped by inheriting other roles. If
a user is given Role A that inherits from Role B, the user has all rights/abilities for both Role
A's privileges and for Role B's privileges.Privilege,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static long |
serialVersionUID |
| Constructor and Description |
|---|
Role()
default constructor
|
Role(String role)
constructor with id
|
Role(String role,
String description)
constructor with all database required properties
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPrivilege(Privilege privilege)
Adds the given Privilege to the list of privileges
|
boolean |
equals(Object obj) |
Set<Role> |
getAllChildRoles()
Recursive (if need be) method to return all child roles of this role
|
Set<Role> |
getAllParentRoles()
Recursive (if need be) method to return all parent roles of this role
|
Set<Role> |
getChildRoles() |
Integer |
getId() |
Set<Role> |
getInheritedRoles() |
Set<Privilege> |
getPrivileges() |
String |
getRole() |
boolean |
hasChildRoles()
Convenience method to test whether or not this role is a parent of another role
|
int |
hashCode() |
boolean |
hasPrivilege(String privilegeName)
Looks for the given
privilegeName privilege name in this roles privileges. |
boolean |
inheritsRoles()
Convenience method to test whether or not this role extends/ inherits from any other roles
|
Set<Role> |
recurseOverChildren(Set<Role> total)
Returns the full set of child roles be looping over children.
|
Set<Role> |
recurseOverParents(Set<Role> total)
Returns the full set of roles be looping over inherited roles.
|
void |
removePrivilege(Privilege privilege)
Removes the given Privilege from the list of privileges
|
void |
setChildRoles(Set<Role> childRoles) |
void |
setId(Integer id) |
void |
setInheritedRoles(Set<Role> inheritedRoles) |
void |
setPrivileges(Set<Privilege> privileges) |
void |
setRole(String role) |
String |
toString() |
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getName, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReasongetUuid, setUuidclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetUuid, setUuidpublic static final long serialVersionUID
public Role()
public Role(String role)
public boolean equals(Object obj)
equals in class ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class ObjectObject.hashCode()public void setPrivileges(Set<Privilege> privileges)
privileges - The privileges to set.public void addPrivilege(Privilege privilege)
privilege - Privilege to addpublic void removePrivilege(Privilege privilege)
privilege - Privilege to removepublic String getRole()
public void setRole(String role)
role - The role to set.public String toString()
toString in class ObjectObject.toString()public boolean hasPrivilege(String privilegeName)
privilegeName privilege name in this roles privileges. This
method does not recurse through the inherited rolesprivilegeName - String name of a privilegepublic void setInheritedRoles(Set<Role> inheritedRoles)
inheritedRoles - The inheritedRoles to set.public boolean inheritsRoles()
public Set<Role> getAllParentRoles()
public Set<Role> recurseOverParents(Set<Role> total)
total - Roles already looped overpublic Integer getId()
getId in interface OpenmrsObjectOpenmrsObject.getId()public void setId(Integer id)
setId in interface OpenmrsObjectid - - The unique Identifier for the objectOpenmrsObject.setId(java.lang.Integer)public void setChildRoles(Set<Role> childRoles)
childRoles - the immediate children to setpublic boolean hasChildRoles()
public Set<Role> getAllChildRoles()
Copyright © 2018 OpenMRS LLC.. All Rights Reserved.