public class Role extends BaseChangeableOpenmrsMetadata
Privilege
s. User
s 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 FormModifier 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
|
Set<Role> |
getAllChildRoles()
Recursive (if need be) method to return all child roles of this role
Should only return child roles
|
Set<Role> |
getAllParentRoles()
Recursive (if need be) method to return all parent roles of this role
Should only return parent roles
|
Set<Role> |
getChildRoles() |
Integer |
getId() |
Set<Role> |
getInheritedRoles() |
String |
getName() |
Set<Privilege> |
getPrivileges() |
String |
getRole() |
boolean |
hasChildRoles()
Convenience method to test whether or not this role is a parent of another role
|
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()
Returns a string equal to the value of: ClassName{hashCode=...,
uuid=...}
|
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReason
equals, getUuid, hashCode, setUuid
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getUuid, setUuid
public static final long serialVersionUID
public Role()
public Role(String role)
public void setPrivileges(Set<Privilege> privileges)
privileges
- The privileges to set.public String getName()
getName
in interface OpenmrsMetadata
getName
in class BaseOpenmrsMetadata
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()
BaseOpenmrsObject
ClassName{hashCode=..., uuid=...}
If the uuid
field is null
, it returns:
ClassName{hashCode=...}Should include hashCode if uuid is null Should include uuid if not null
toString
in class BaseOpenmrsObject
Object.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()
OpenmrsObject.getId()
public void setId(Integer id)
id
- - 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 © 2024 OpenMRS Inc.. All rights reserved.