@Entity public class User extends BaseOpenmrsObject implements Serializable, Attributable<User>, Auditable, Retireable
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 |
containsRole(String roleName)
Checks if the user has a given role.
|
List<User> |
findPossibleValues(String searchText)
Deprecated.
|
Set<Role> |
getAllRoles()
Returns all roles attributed to this user by expanding the role list to include the parents of
the assigned roles
|
User |
getChangedBy() |
User |
getCreator() |
Date |
getDateChanged() |
Date |
getDateCreated() |
Date |
getDateRetired() |
String |
getDisplayString()
Gets a descriptive String used for display purposes This is meant as an alternative to using
the toString() to display this object to a user
|
String |
getEmail() |
String |
getFamilyName()
Get familyName on the Person this user account belongs to
|
String |
getGivenName()
Get givenName on the Person this user account belongs to
|
Integer |
getId() |
Set<PersonName> |
getNames() |
Person |
getPerson() |
PersonName |
getPersonName() |
List<User> |
getPossibleValues()
Deprecated.
|
Collection<Privilege> |
getPrivileges()
Get all privileges this user has.
|
List<Locale> |
getProficientLocales()
Returns a list of Locales for which the User is considered proficient.
|
Boolean |
getRetired() |
User |
getRetiredBy() |
String |
getRetireReason() |
Set<Role> |
getRoles() |
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.
|
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
|
User |
hydrate(String userId)
Deserialize the given string into a full object
|
Boolean |
isRetired() |
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.
|
String |
serialize()
Turn the current object into an identifying string that can be retrieved later
|
void |
setChangedBy(User changedBy) |
void |
setCreator(User creator) |
void |
setDateChanged(Date dateChanged) |
void |
setDateCreated(Date dateCreated) |
void |
setDateRetired(Date dateRetired) |
void |
setEmail(String email) |
void |
setId(Integer id) |
void |
setPerson(Person person) |
void |
setRetired(Boolean retired) |
void |
setRetiredBy(User retiredBy) |
void |
setRetireReason(String retireReason) |
void |
setRoles(Set<Role> roles) |
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()
Returns a string equal to the value of: ClassName{hashCode=...,
uuid=...}
|
equals, getUuid, hashCode, 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 boolean containsRole(String roleName)
roleName
- the name of the role to checkpublic Collection<Privilege> getPrivileges()
public Set<Role> getAllRoles()
public User addRole(Role role)
role
- public User removeRole(Role role)
role
- @Deprecated public List<User> findPossibleValues(String searchText)
Attributable
findPossibleValues
in interface Attributable<User>
searchText
- String to search onAttributable.findPossibleValues(java.lang.String)
@Deprecated public List<User> getPossibleValues()
Attributable
getPossibleValues
in interface Attributable<User>
Attributable.getPossibleValues()
public User hydrate(String userId)
Attributable
hydrate
in interface Attributable<User>
userId
- String to deserializeAttributable.hydrate(java.lang.String)
public String serialize()
Attributable
serialize
in interface Attributable<User>
Attributable.serialize()
public String getDisplayString()
Attributable
getDisplayString
in interface Attributable<User>
Attributable.getDisplayString()
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.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 getEmail()
public void setEmail(String email)
email
- The email 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
public Map<String,String> getUserProperties()
public void setUserProperties(Map<String,String> userProperties)
userProperties
- A Map<String,String> of the properties to set.public 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()
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)
public User getCreator()
getCreator
in interface Creatable
public void setCreator(User creator)
setCreator
in interface Creatable
creator
- - the user who created the objectpublic Date getDateCreated()
getDateCreated
in interface Creatable
public void setDateCreated(Date dateCreated)
setDateCreated
in interface Creatable
dateCreated
- - the date the object was createdpublic User getChangedBy()
getChangedBy
in interface Changeable
public void setChangedBy(User changedBy)
setChangedBy
in interface Changeable
changedBy
- - the user who last changed the objectpublic Date getDateChanged()
getDateChanged
in interface Changeable
public void setDateChanged(Date dateChanged)
setDateChanged
in interface Changeable
dateChanged
- - the date the object was last changedpublic Boolean isRetired()
isRetired
in interface Retireable
public Boolean getRetired()
getRetired
in interface Retireable
public void setRetired(Boolean retired)
setRetired
in interface Retireable
retired
- - whether of not this object is retiredpublic User getRetiredBy()
getRetiredBy
in interface Retireable
public void setRetiredBy(User retiredBy)
setRetiredBy
in interface Retireable
retiredBy
- - the user who retired the objectpublic Date getDateRetired()
getDateRetired
in interface Retireable
public void setDateRetired(Date dateRetired)
setDateRetired
in interface Retireable
dateRetired
- - the date the object was retiredpublic String getRetireReason()
getRetireReason
in interface Retireable
public void setRetireReason(String retireReason)
setRetireReason
in interface Retireable
retireReason
- - the reason the object was retiredCopyright © 2024 OpenMRS Inc.. All rights reserved.