org.openmrs
Class User

java.lang.Object
  extended by org.openmrs.Person
      extended by org.openmrs.User
All Implemented Interfaces:
java.io.Serializable

public class User
extends Person
implements java.io.Serializable

Defines a User in the system. A user is simply an extension of a person and all that that implies. A user is defined as someone who will be manipulating the system and must log in or is being referred to in another part of the system (as a provider, creator, etc) Users are special Persons in that they have login credentials (login/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)

See Also:
Serialized Form

Field Summary
 org.apache.commons.logging.Log log
           
static long serialVersionUID
           
 
Fields inherited from class org.openmrs.Person
personId
 
Constructor Summary
User()
          default constructor
User(java.lang.Integer userId)
          constructor with id
User(Person person)
          constructor with person object
 
Method Summary
 User addRole(Role role)
          Add the given Role to the list of roles for this User
 boolean equals(java.lang.Object obj)
          Compares two objects for similarity This must pass through to the parent object (org.openmrs.Person) in order to get similarity of person/user objects
 java.util.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()
           
 java.util.Date getDateChanged()
           
 java.util.Date getDateCreated()
           
 java.util.Date getDateVoided()
           
 java.lang.String getFirstName()
          Deprecated. use getGivenName on Person
 java.lang.String getLastName()
          Deprecated. use getFamilyName on Person
 java.util.Collection<Privilege> getPrivileges()
          Get all privileges this user has.
 java.util.List<java.util.Locale> getProficientLocales()
          Returns a list of Locales for which the User is considered proficient.
 java.util.Set<Role> getRoles()
           
 java.lang.String getSecretQuestion()
           
 java.lang.String getSystemId()
           
 java.lang.Integer getUserId()
           
 java.lang.String getUsername()
           
 java.util.Map<java.lang.String,java.lang.String> getUserProperties()
           
 java.lang.String getUserProperty(java.lang.String prop)
          Get prop property from this user's properties.
 java.lang.String getUserProperty(java.lang.String prop, java.lang.String defaultValue)
          Get prop property from this user's properties.
 java.lang.Boolean getVoided()
           
 User getVoidedBy()
           
 java.lang.String getVoidReason()
           
 int hashCode()
          The hashcode for a user/person is used to index the objects in a tree This must pass through to the parent object (org.openmrs.Person) in order to get similarity of person/user objects
 boolean hasPrivilege(java.lang.String privilege)
          This method shouldn't be used directly.
 boolean hasRole(java.lang.String r)
          Check if this user has the given String role
 boolean hasRole(java.lang.String r, boolean ignoreSuperUser)
          Auto generated method comment
 boolean isSuperUser()
          Return true if this user has all privileges
 java.lang.Boolean isVoided()
           
 User removeRole(Role role)
          Remove the given Role from the list of roles for this User
 void removeUserProperty(java.lang.String prop)
          Convenience method.
 User replaceSerialization(java.util.Map<?,?> sessionMap)
          If the serializer wishes, don't serialize this entire object, just the important parts
 void setChangedBy(User changedBy)
           
 void setCreator(User creator)
           
 void setDateChanged(java.util.Date dateChanged)
           
 void setDateCreated(java.util.Date dateCreated)
           
 void setDateVoided(java.util.Date dateVoided)
           
 void setPersonId(java.lang.Integer personId)
          Overrides the parent setPersonId(Integer) so that we can be sure user id is also set correctly.
 void setRoles(java.util.Set<Role> roles)
           
 void setSecretQuestion(java.lang.String secretQuestion)
           
 void setSystemId(java.lang.String systemId)
           
 void setUserId(java.lang.Integer userId)
           
 void setUsername(java.lang.String username)
           
 void setUserProperties(java.util.Map<java.lang.String,java.lang.String> userProperties)
           
 void setUserProperty(java.lang.String prop, java.lang.String value)
          Convenience method.
 void setVoided(java.lang.Boolean voided)
           
 void setVoidedBy(User voidedBy)
           
 void setVoidReason(java.lang.String voidReason)
           
 java.lang.String toString()
           
 void validateSerialization(java.util.Map<?,?> sessionMap)
           
 
Methods inherited from class org.openmrs.Person
addAddress, addAttribute, addName, getActiveAttributes, getAddresses, getAge, getAge, getAttribute, getAttribute, getAttributeMap, getAttributes, getAttributes, getAttributes, getBirthdate, getBirthdateEstimated, getCauseOfDeath, getDead, getDeathDate, getFamilyName, getGender, getGivenName, getMiddleName, getNames, getPersonAddress, getPersonChangedBy, getPersonCreator, getPersonDateChanged, getPersonDateCreated, getPersonDateVoided, getPersonId, getPersonName, getPersonVoided, getPersonVoidedBy, getPersonVoidReason, isBirthdateEstimated, isDead, isPatient, isPersonVoided, isUser, printAttributes, removeAddress, removeAttribute, removeName, setAddresses, setAttributes, setBirthdate, setBirthdateEstimated, setCauseOfDeath, setDead, setDeathDate, setGender, setNames, setPersonChangedBy, setPersonCreator, setPersonDateChanged, setPersonDateCreated, setPersonDateVoided, setPersonVoided, setPersonVoidedBy, setPersonVoidReason
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values

log

public org.apache.commons.logging.Log log
Constructor Detail

User

public User()
default constructor


User

public User(java.lang.Integer userId)
constructor with id


User

public User(Person person)
constructor with person object

Method Detail

isSuperUser

public boolean isSuperUser()
Return true if this user has all privileges

Returns:
true/false if this user is defined as a super user

hasPrivilege

public boolean hasPrivilege(java.lang.String privilege)
This method shouldn't be used directly. Use org.openmrs.api.context.Context#hasPrivilege so that anonymous/authenticated/proxy privileges are all included Return true if this user has the specified privilege

Parameters:
privilege -
Returns:
true/false

hasRole

public boolean hasRole(java.lang.String r)
Check if this user has the given String role

Parameters:
r - String name of a role to check
Returns:
true/false if this user has the role

hasRole

public boolean hasRole(java.lang.String r,
                       boolean ignoreSuperUser)
Auto generated method comment

Parameters:
r -
ignoreSuperUser -
Returns:

getPrivileges

public java.util.Collection<Privilege> getPrivileges()
Get all privileges this user has. This delves into all of the roles that a person has, appending unique privileges

Returns:
Collection of complete Privileges this user has

equals

public boolean equals(java.lang.Object obj)
Compares two objects for similarity This must pass through to the parent object (org.openmrs.Person) in order to get similarity of person/user objects

Overrides:
equals in class Person
Parameters:
obj -
Returns:
boolean true/false whether or not they are the same objects
See Also:
Person.equals(java.lang.Object)

hashCode

public int hashCode()
The hashcode for a user/person is used to index the objects in a tree This must pass through to the parent object (org.openmrs.Person) in order to get similarity of person/user objects

Overrides:
hashCode in class Person
See Also:
Person.hashCode()

getAllRoles

public java.util.Set<Role> getAllRoles()
Returns all roles attributed to this user by expanding the role list to include the parents of the assigned roles

Returns:
all roles (inherited from parents and given) for this user

getRoles

public java.util.Set<Role> getRoles()
Returns:
Returns the roles.

setRoles

public void setRoles(java.util.Set<Role> roles)
Parameters:
roles - The roles to set.

addRole

public User addRole(Role role)
Add the given Role to the list of roles for this User

Parameters:
roleservation -
Returns:
this user with the given role attached

removeRole

public User removeRole(Role role)
Remove the given Role from the list of roles for this User

Parameters:
roleservation -
Returns:
this user with the given role removed

getSystemId

public java.lang.String getSystemId()
Returns:
Returns the systemId.

setSystemId

public void setSystemId(java.lang.String systemId)
Parameters:
systemId - The systemId to set.

getUserId

public java.lang.Integer getUserId()
Returns:
Returns the userId.

setUserId

public void setUserId(java.lang.Integer userId)
Parameters:
userId - The userId to set.

setPersonId

public void setPersonId(java.lang.Integer personId)
Overrides the parent setPersonId(Integer) so that we can be sure user id is also set correctly.

Overrides:
setPersonId in class Person
Parameters:
personId - The personId to set.
See Also:
Person.setPersonId(java.lang.Integer)

getUsername

public java.lang.String getUsername()
Returns:
Returns the username.

setUsername

public void setUsername(java.lang.String username)
Parameters:
username - The username to set.

getSecretQuestion

public java.lang.String getSecretQuestion()
Returns:
Returns the secretQuestion.

setSecretQuestion

public void setSecretQuestion(java.lang.String secretQuestion)
Parameters:
secretQuestion - The secretQuestion to set.

toString

public java.lang.String toString()
Overrides:
toString in class Person
See Also:
Object.toString()

getUserProperties

public java.util.Map<java.lang.String,java.lang.String> getUserProperties()
Returns:
Returns the userProperties.

setUserProperties

public void setUserProperties(java.util.Map<java.lang.String,java.lang.String> userProperties)
Parameters:
properties - The properties to set.

setUserProperty

public void setUserProperty(java.lang.String prop,
                            java.lang.String value)
Convenience method. Adds the given property to the user's properties


removeUserProperty

public void removeUserProperty(java.lang.String prop)
Convenience method. Removes the given property from the user's properties


getUserProperty

public java.lang.String getUserProperty(java.lang.String prop)
Get prop property from this user's properties. If prop is not found in properties, return empty string

Parameters:
prop -
Returns:
property value

getUserProperty

public java.lang.String getUserProperty(java.lang.String prop,
                                        java.lang.String defaultValue)
Get prop property from this user's properties. If prop is not found in properties, return defaultValue

Parameters:
prop -
defaultValue -
Returns:
property value
See Also:
getUserProperty(java.lang.String)

getCreator

public User getCreator()
Returns:
Returns the creator.

setCreator

public void setCreator(User creator)
Parameters:
creator - The creator to set.

getChangedBy

public User getChangedBy()
Returns:
Returns the changedBy.

setChangedBy

public void setChangedBy(User changedBy)
Parameters:
changedBy - The changedBy to set.

getDateChanged

public java.util.Date getDateChanged()
Returns:
Returns the dateChanged.

setDateChanged

public void setDateChanged(java.util.Date dateChanged)
Parameters:
dateChanged - The dateChanged to set.

getDateCreated

public java.util.Date getDateCreated()
Returns:
Returns the dateCreated.

setDateCreated

public void setDateCreated(java.util.Date dateCreated)
Parameters:
dateCreated - The dateCreated to set.

getDateVoided

public java.util.Date getDateVoided()
Returns:
Returns the dateVoided.

setDateVoided

public void setDateVoided(java.util.Date dateVoided)
Parameters:
dateVoided - The dateVoided to set.

isVoided

public java.lang.Boolean isVoided()
Returns:
Returns the void status.

getVoided

public java.lang.Boolean getVoided()

setVoided

public void setVoided(java.lang.Boolean voided)
Parameters:
voided - The void status to set.

getVoidedBy

public User getVoidedBy()
Returns:
Returns the voidedBy.

setVoidedBy

public void setVoidedBy(User voidedBy)
Parameters:
voidedBy - The voidedBy to set.

getVoidReason

public java.lang.String getVoidReason()
Returns:
Returns the voidReason.

setVoidReason

public void setVoidReason(java.lang.String voidReason)
Parameters:
voidReason - The voidReason to set.

getFirstName

public java.lang.String getFirstName()
Deprecated. use getGivenName on Person

Returns:
String user's first name

getLastName

public java.lang.String getLastName()
Deprecated. use getFamilyName on Person

Returns:
String user's last name

replaceSerialization

public User replaceSerialization(java.util.Map<?,?> sessionMap)
If the serializer wishes, don't serialize this entire object, just the important parts

Overrides:
replaceSerialization in class Person
Parameters:
sessionMap - serialization session information
Returns:
User object to serialize
See Also:
OpenmrsUtil.isShortSerialization(Map)

validateSerialization

public void validateSerialization(java.util.Map<?,?> sessionMap)

getProficientLocales

public java.util.List<java.util.Locale> getProficientLocales()
Returns a list of Locales for which the User is considered proficient.

Returns:
List of the User's proficient locales

OpenMRS-trunk

Generated May 29 2008 02:01 AM. NOTE - these libraries are in active development and subject to change