public class User extends BaseOpenmrsMetadata implements Serializable
Person
in the system,
although that person may have other user accounts. Users have login credentials (username/password)
and can have special user properties. User properties are just simple key-value pairs for either quick
info or display specific info that needs to be persisted (like locale preferences, search options, etc)Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Constructor and Description |
---|
User()
default constructor
|
User(Integer userId)
constructor with id
|
User(Person person)
constructor with person object
|
Modifier and Type | Method and Description |
---|---|
void |
addName(PersonName name) |
User |
addRole(Role role)
Add the given Role to the list of roles for this User
|
boolean |
equals(Object obj)
Compares two objects for similarity
|
Set<Role> |
getAllRoles()
Returns all roles attributed to this user by expanding the role list to include the parents
of the assigned roles
|
String |
getFamilyName()
Get familyName on the Person this user account belongs to
|
String |
getFirstName()
Deprecated.
use getGivenName on Person
|
String |
getGivenName()
Get givenName on the Person this user account belongs to
|
Integer |
getId() |
String |
getLastName()
Deprecated.
use getFamilyName on Person
|
Set<PersonName> |
getNames() |
Person |
getPerson() |
PersonName |
getPersonName() |
Collection<Privilege> |
getPrivileges()
Get all privileges this user has.
|
List<Locale> |
getProficientLocales()
Returns a list of Locales for which the User is considered proficient.
|
Set<Role> |
getRoles() |
String |
getSecretQuestion() |
String |
getSystemId() |
Integer |
getUserId() |
String |
getUsername() |
Map<String,String> |
getUserProperties() |
String |
getUserProperty(String prop)
Get prop property from this user's properties.
|
String |
getUserProperty(String prop,
String defaultValue)
Get prop property from this user's properties.
|
int |
hashCode()
The hashcode for a user is used to index the objects in a tree
|
boolean |
hasPrivilege(String privilege)
This method shouldn't be used directly.
|
boolean |
hasRole(String r)
Check if this user has the given String role
|
boolean |
hasRole(String r,
boolean ignoreSuperUser)
Checks if this user has the given String role
|
boolean |
isSuperUser()
Return true if this user has all privileges
|
User |
removeRole(Role role)
Remove the given Role from the list of roles for this User
|
void |
removeUserProperty(String prop)
Convenience method.
|
User |
replaceSerialization(Map<?,?> sessionMap)
If the serializer wishes, don't serialize this entire object, just the important parts
|
void |
setId(Integer id) |
void |
setPerson(Person person) |
void |
setPersonId(Integer personId)
Deprecated.
|
void |
setRoles(Set<Role> roles) |
void |
setSecretQuestion(String secretQuestion) |
void |
setSystemId(String systemId) |
void |
setUserId(Integer userId) |
void |
setUsername(String username) |
void |
setUserProperties(Map<String,String> userProperties) |
void |
setUserProperty(String prop,
String value)
Convenience method.
|
String |
toString() |
void |
validateSerialization(Map<?,?> sessionMap) |
getChangedBy, getCreator, getDateChanged, getDateCreated, getDateRetired, getDescription, getName, getRetired, getRetiredBy, getRetireReason, isRetired, setChangedBy, setCreator, setDateChanged, setDateCreated, setDateRetired, setDescription, setName, setRetired, setRetiredBy, setRetireReason
getUuid, setUuid
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getUuid, setUuid
public static final long serialVersionUID
public User()
public User(Integer userId)
public User(Person person)
public boolean isSuperUser()
public boolean hasPrivilege(String privilege)
privilege
- public boolean hasRole(String r)
r
- String name of a role to checkpublic boolean hasRole(String r, boolean ignoreSuperUser)
r
- String name of a role to checkignoreSuperUser
- If this is false, then this method will always return true for a
superuser.public Collection<Privilege> getPrivileges()
public boolean equals(Object obj)
public int hashCode()
hashCode
in class Object
Person.hashCode()
public Set<Role> getAllRoles()
public User addRole(Role role)
role
- public User removeRole(Role role)
role
- public String getSystemId()
public void setSystemId(String systemId)
systemId
- The systemId to set.public Integer getUserId()
public void setUserId(Integer userId)
userId
- The userId to set.@Deprecated public void setPersonId(Integer personId)
setPerson(Person)
public Person getPerson()
public void setPerson(Person person)
person
- the person to setpublic String getUsername()
public void setUsername(String username)
username
- The username to set.public String getSecretQuestion()
public void setSecretQuestion(String secretQuestion)
secretQuestion
- The secretQuestion to set.public Map<String,String> getUserProperties()
public void setUserProperties(Map<String,String> userProperties)
userProperties
- A Mappublic void setUserProperty(String prop, String value)
public void removeUserProperty(String prop)
public String getUserProperty(String prop)
prop
- public String getUserProperty(String prop, String defaultValue)
defaultValue
prop
- defaultValue
- getUserProperty(java.lang.String)
public void addName(PersonName name)
Person.addName(PersonName)
public PersonName getPersonName()
Person.getPersonName()
public String getGivenName()
Person.getGivenName()
public String getFamilyName()
Person.getFamilyName()
public Set<PersonName> getNames()
Person.getNames()
@Deprecated public String getFirstName()
@Deprecated public String getLastName()
public User replaceSerialization(Map<?,?> sessionMap)
sessionMap
- serialization session informationOpenmrsUtil.isShortSerialization(Map)
public void validateSerialization(Map<?,?> sessionMap)
public List<Locale> getProficientLocales()
public Integer getId()
getId
in interface OpenmrsObject
OpenmrsObject.getId()
public void setId(Integer id)
setId
in interface OpenmrsObject
id
- - The unique Identifier for the objectOpenmrsObject.setId(java.lang.Integer)
Copyright © 2018 OpenMRS LLC.. All Rights Reserved.