public class Role extends BaseOpenmrsMetadata implements java.io.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(java.lang.String role)
constructor with id
|
Role(java.lang.String role,
java.lang.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
|
java.util.Set<Role> |
getAllChildRoles()
Recursive (if need be) method to return all child roles of this role
|
java.util.Set<Role> |
getAllParentRoles()
Recursive (if need be) method to return all parent roles of this role
|
java.util.Set<Role> |
getChildRoles() |
java.lang.Integer |
getId() |
java.util.Set<Role> |
getInheritedRoles() |
java.lang.String |
getName() |
java.util.Set<Privilege> |
getPrivileges() |
java.lang.String |
getRole() |
boolean |
hasChildRoles()
Convenience method to test whether or not this role is a parent of another role
|
boolean |
hasPrivilege(java.lang.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
|
java.util.Set<Role> |
recurseOverChildren(java.util.Set<Role> total)
Returns the full set of child roles be looping over children.
|
java.util.Set<Role> |
recurseOverParents(java.util.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(java.util.Set<Role> childRoles) |
void |
setId(java.lang.Integer id) |
void |
setInheritedRoles(java.util.Set<Role> inheritedRoles) |
void |
setPrivileges(java.util.Set<Privilege> privileges) |
void |
setRole(java.lang.String role) |
java.lang.String |
toString()
Returns a string consisting of the name of the class of which the object is an instance and
the
uuid field surrounded by [ and ]. |
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReasonequals, getUuid, hashCode, setUuidclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetUuid, setUuidpublic static final long serialVersionUID
public Role()
public Role(java.lang.String role)
public Role(java.lang.String role,
java.lang.String description)
public java.util.Set<Privilege> getPrivileges()
public void setPrivileges(java.util.Set<Privilege> privileges)
privileges - The privileges to set.public java.lang.String getName()
getName in interface OpenmrsMetadatagetName in class BaseOpenmrsMetadatapublic void addPrivilege(Privilege privilege)
privilege - Privilege to addpublic void removePrivilege(Privilege privilege)
privilege - Privilege to removepublic java.lang.String getRole()
public void setRole(java.lang.String role)
role - The role to set.public java.lang.String toString()
BaseOpenmrsObjectuuid field surrounded by [ and ]. In other words,
this method returns a string equal to the value of: getClass().getName() + '[' + uuid + ']'
If the uuid field is null, it delegates to
Object.toString()
toString in class BaseOpenmrsObjectObject.toString()public boolean hasPrivilege(java.lang.String privilegeName)
privilegeName privilege name in this roles privileges. This
method does not recurse through the inherited rolesprivilegeName - String name of a privilegepublic java.util.Set<Role> getInheritedRoles()
public void setInheritedRoles(java.util.Set<Role> inheritedRoles)
inheritedRoles - The inheritedRoles to set.public boolean inheritsRoles()
public java.util.Set<Role> getAllParentRoles()
public java.util.Set<Role> recurseOverParents(java.util.Set<Role> total)
total - Roles already looped overpublic java.lang.Integer getId()
getId in interface OpenmrsObjectOpenmrsObject.getId()public void setId(java.lang.Integer id)
setId in interface OpenmrsObjectid - - The unique Identifier for the objectOpenmrsObject.setId(java.lang.Integer)public java.util.Set<Role> getChildRoles()
public void setChildRoles(java.util.Set<Role> childRoles)
childRoles - the immediate children to setpublic boolean hasChildRoles()
public java.util.Set<Role> getAllChildRoles()
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.