@Entity public class Person extends Object implements PersonEntity
Modifier and Type | Field and Description |
---|---|
static String |
CHECK_ACTIVE_PERSONS_WITH_LOGIN_EXISTS
Query name.
|
static String |
FIND_ALL
Query name.
|
static String |
FIND_BY_LOGIN
Query name.
|
static String |
FIND_LIKE_ID
Query name.
|
static String |
FIND_PERSONS_FOR_SECURITY_ROLE
Query name.
|
Modifier | Constructor and Description |
---|---|
protected |
Person()
Constructor needed for JPA-specific purposes.
|
|
Person(String id,
String loginName)
Creates new
Person instance with the empty map of details. |
|
Person(String id,
String loginName,
Map<String,String> details)
Creates new
Person instance with given map of details. |
Modifier and Type | Method and Description |
---|---|
Person |
addRole(Role role)
Adds given
role to the roles the person is assigned to. |
void |
addSecurityRole(SecurityRole securityRole)
Adds a security role.
|
Person |
addSubstitute(Person substitute)
Adds a substitute.
|
boolean |
equals(Object obj) |
Set<Person> |
getActivelySubstituted()
Returns a collection of all actively substituted persons including transitive substitutions.
|
Set<Person> |
getActiveSubstitutes()
Returns a set of active substitutes of this person including transitive substitutions.
|
String |
getDetail(String detailName)
Returns a value of the detail with given
detailName or null if there is no
such detail. |
Map<String,String> |
getDetails()
Returns a map of details (name-value pairs) of the person.
|
Set<Person> |
getDirectlySubstituted()
Returns a collection of directly substituted Persons for this Person.
|
Set<Person> |
getDirectSubstitutes()
Returns a set of substitutes of this Person.
|
String |
getEmail()
Returns the email.
|
Long |
getEntityVersion()
Returns the entity version.
|
String |
getFirstName()
Returns the first name.
|
String |
getId()
Returns the primary key.
|
String |
getLastName()
Returns the last name.
|
String |
getLoginName()
Returns the login name of the person.
|
String |
getPasswordHash() |
String |
getPasswordSalt() |
String |
getPhone()
Returns the phone.
|
Set<String> |
getRights()
Returns a set of this person rights.
|
Role |
getRole(RoleUnitName roleName)
Returns the role which corresponds to given
roleName or null if the person
contains no such role. |
Collection<Role> |
getRoles()
Returns a collection of roles the person is assigned to.
|
Set<RoleUnitName> |
getRoleUnitNames()
Returns a set of role unit names.
|
Collection<SecurityRole> |
getSecurityRoles()
Returns a collection of the security roles that are assigned to the user.
|
byte[] |
getSetting(String settingName)
Returns the content of the setting with given
detailName or null if there is
no such setting. |
Map<String,byte[]> |
getSettings()
Returns a map of settings (name-value pairs) of the person.
|
boolean |
hasDetail(String detailName)
Returns
true if this person has the detail (identified by given detailName ),
otherwise returns false . |
int |
hashCode() |
boolean |
hasRight(String right)
Returns true if this person has the given right.
|
boolean |
isActive()
Returns true if the user is active.
|
boolean |
isInRole(RoleUnitName role)
Return true if this person is in the given role, i.e.
|
boolean |
isInRoles(Collection<RoleUnitName> roles)
Returns true if this person is at least in one of the given roles.
|
boolean |
isStrictlyInRole(RoleUnitName role)
Returns true if this person is strictly in the given role, i.e.
|
boolean |
isStrictlyInRoles(Collection<RoleUnitName> roles)
Returns true if this person is strictly at least in one of the given roles.
|
boolean |
isSubstitutionActive()
Returns the substitution active flag.
|
PersonDetail |
removeDetail(String detailName)
Removes the detail identified by given
detailName and returns the
PersonDetail instance (JPA entity) that has just been removed. |
Person |
removeRole(Role role)
Removes given
role from the roles the person is assigned to. |
void |
removeSecurityRole(SecurityRole securityRole)
Removes a security role.
|
void |
removeSetting(String settingName)
Removes the setting identified by given
settingName and returns the
PersonDetail instance (JPA entity) that has just been removed. |
Person |
removeSubstitute(Person substitute)
Removes a substitute.
|
void |
setActive(boolean active)
Sets the active flag.
|
Person |
setDetail(String detailName,
String detailValue)
Adds or updates the detail identified by given
detailName . |
void |
setEmail(String email)
Sets the email.
|
void |
setFirstName(String firstName)
Sets the first name.
|
void |
setLastName(String lastName)
Sets the last name.
|
void |
setLoginName(String loginName)
Sets the login of the user.
|
void |
setPasswordHash(String passwordHash) |
void |
setPasswordSalt(String passwordSalt) |
void |
setPhone(String phone)
Sets the phone
|
void |
setSecurityRoles(Collection<SecurityRole> securityRoles)
Sets security roles.
|
Person |
setSetting(String settingName,
byte[] settingContent)
Adds or updates the setting identified by given
settingName . |
void |
setSubstitutes(Collection<Person> substitutes)
Sets a new set of substitutes for this Person.
|
void |
setSubstitutionActive(boolean substitutionActive)
Sets the substitution active flag.
|
String |
toString() |
public static final String FIND_ALL
public static final String FIND_BY_LOGIN
public static final String FIND_LIKE_ID
public static final String FIND_PERSONS_FOR_SECURITY_ROLE
public static final String CHECK_ACTIVE_PERSONS_WITH_LOGIN_EXISTS
protected Person()
public Person(String id, String loginName)
Person
instance with the empty map of details.id
- loginName
- NullPointerException
- if loginName
is nullpublic String getId()
EntityWithId
getId
in interface EntityWithId<String>
public String getLoginName()
getLoginName
in interface PersonEntity
public void setLoginName(String loginName)
loginName
- The new login of the user in its plain form. Cannot be null
.NullPointerException
- (unchecked) If loginName
is null
.public Long getEntityVersion()
getEntityVersion
in interface PersonEntity
public String getFirstName()
getFirstName
in interface PersonEntity
public void setFirstName(String firstName)
firstName
- public String getLastName()
getLastName
in interface PersonEntity
public void setLastName(String lastName)
lastName
- public String getEmail()
getEmail
in interface PersonEntity
public void setEmail(String email)
email
- public String getPhone()
getPhone
in interface PersonEntity
public void setPhone(String phone)
phone
- public String getPasswordHash()
public void setPasswordHash(String passwordHash)
passwordHash
- the passwordHash to setpublic String getPasswordSalt()
public void setPasswordSalt(String passwordSalt)
passwordSalt
- the passwordSalt to setpublic boolean isActive()
isActive
in interface PersonEntity
public void setActive(boolean active)
active
- public Map<String,String> getDetails()
getDetails
in interface PersonEntity
public boolean hasDetail(String detailName)
true
if this person has the detail (identified by given detailName
),
otherwise returns false
.detailName
- The name of the detail to check for presence.true
if this person has the detail (identified by given detailName
),
otherwise returns false
.public Map<String,byte[]> getSettings()
public byte[] getSetting(String settingName)
detailName
or null
if there is
no such setting.settingName
- The name of the setting to retrieve. Cannot be null
.settingName
or null
if there is
no such detail.NullPointerException
- (unchecked) If settingName
is null
.public Person setSetting(String settingName, byte[] settingContent)
settingName
. If the setting does not
exist in the person's settings, it will be added there, otherwise the setting will be updated
to the new value (with given settingContent
).settingName
- The name of the setting to be added or updated. Cannot be null
.settingContent
- The new value of the setting to add or update. Cannot be null
.Person
instance.NullPointerException
- (unchecked) If at least one of the arguments is null
.public void removeSetting(String settingName)
settingName
and returns the
PersonDetail
instance (JPA entity) that has just been removed.settingName
- The name of the setting to remove from this person.public String getDetail(String detailName)
detailName
or null
if there is no
such detail.detailName
- The name of the detail to retrieve. Cannot be null
.detailName
or null
if there is no
such detail.NullPointerException
- (unchecked) If detailName
is null
.public Person setDetail(String detailName, String detailValue)
detailName
. If the detail does not
exist in the person's details, it will be added there, otherwise the detail will be updated
to the new value (with given detailValue
).detailName
- The name of the detail to be added or updated. Cannot be null
.detailValue
- The new value of the detail to add or update. Cannot be null
.Person
instance.NullPointerException
- (unchecked) If at least one of the arguments is null
.public PersonDetail removeDetail(String detailName)
detailName
and returns the
PersonDetail
instance (JPA entity) that has just been removed.detailName
- The name of the detail to remove from this person.PersonDetail
instance (JPA entity).public Collection<Role> getRoles()
public Set<RoleUnitName> getRoleUnitNames()
getRoleUnitNames
in interface PersonEntity
public boolean isInRole(RoleUnitName role)
role
- NullPointerException
- if role
is nullpublic boolean isInRoles(Collection<RoleUnitName> roles)
roles
- NullPointerException
- if roles
or any element of roles
is nullisInRole(RoleUnitName)
public boolean isStrictlyInRole(RoleUnitName role)
role
- NullPointerException
- if role
is nullpublic boolean isStrictlyInRoles(Collection<RoleUnitName> roles)
roles
- NullPointerException
- if roles
or any element of roles
is nullisStrictlyInRole(RoleUnitName)
public Person addRole(Role role)
role
to the roles the person is assigned to.role
- The role to add to the roles the person is assigned to.public Role getRole(RoleUnitName roleName)
roleName
or null
if the person
contains no such role.roleName
- The name of the role to get.roleName
or null
.NullPointerException
- (unchecked) If roleName
is null
.public Person removeRole(Role role)
role
from the roles the person is assigned to.role
- The role to remove from the roles the person is assigned to.public Set<Person> getDirectSubstitutes()
getDirectSubstitutes
in interface PersonEntity
public Set<Person> getDirectlySubstituted()
getDirectlySubstituted
in interface PersonEntity
public Set<Person> getActiveSubstitutes()
getActiveSubstitutes
in interface PersonEntity
public Set<Person> getActivelySubstituted()
getActivelySubstituted
in interface PersonEntity
public void setSubstitutes(Collection<Person> substitutes)
substitutes
- The set of substitutes for this person.public Person addSubstitute(Person substitute)
substitute
- public Person removeSubstitute(Person substitute)
substitute
- public boolean isSubstitutionActive()
isSubstitutionActive
in interface PersonEntity
public void setSubstitutionActive(boolean substitutionActive)
substitutionActive
- public Collection<SecurityRole> getSecurityRoles()
public void setSecurityRoles(Collection<SecurityRole> securityRoles)
securityRoles
- NullPointerException
- if any role in securityRoles
is nullpublic void addSecurityRole(SecurityRole securityRole)
securityRole
- NullPointerException
- if securityRole
is nullpublic void removeSecurityRole(SecurityRole securityRole)
securityRole
- NullPointerException
- if securityRole
is nullpublic Set<String> getRights()
getRights
in interface PersonEntity
public boolean hasRight(String right)
right
- Copyright © 2007-2020 Whitestein Technologies. All Rights Reserved.