Package com.avoka.tm.query
Class UserQuery
java.lang.Object
com.avoka.tm.query.UserQuery
Provides a user value object query class.
Examples
Please find the user query examples about list, get first and count below.
User Query List Example
This Groovy example shows how to list active users sorted by first name and last name, with the result set limited to a maximum of 50 records.
import com.avoka.tm.query.* import com.avoka.tm.vo.* List<User> users = new UserQuery() .setAccountStatus(User.STATUS_ACTIVE) .addOrderByAsc("firstName") .addOrderByAsc("lastName") .setFetchLimit(50) .listValues() // In JSON format String usersJson = new UserQuery() .setAccountStatus(User.STATUS_ACTIVE) .addOrderByAsc("firstName") .addOrderByAsc("lastName") .setFetchLimit(50) .listJson()
User Query First Example
This Groovy example shows how to get first user matching certain criteria.
import com.avoka.tm.query.* import com.avoka.tm.vo.* User userJohn = new UserQuery() .setFirstName("John") .firstValue()
User Query Count Example
This Groovy example shows how to count all users which have an inactive status.
import com.avoka.tm.query.* int inactiveCount = new UserQuery() .setAccountStatus(User.STATUS_INACTIVE) .count()
- Since:
- 5.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd the group name to the user query so that only users belonging to the group are included.addOrderByAsc
(String orderProperty) Add the sort order by ascending to the query.addOrderByDesc
(String orderProperty) Add the sort order by descending to the query.Add the role name to the user query so that only users with this role are included.addRoles
(Collection<String> roleNames) Add the roles name to the user query so that only users with these roles are included.int
count()
Execute a select count query and return the total number of records selected by the query.Execute the query and return the first user JSON value.Execute the query and return the first user value object for the query.listJson()
Execute the query and return an users JSON array list.Execute the user query and return a list of User value objects.setAccountStatus
(String accountStatus) Set the user account status [ Active | Inactive | Locked | Locked Temporarily | Pending | Rejected ] query parameter.setClientCode
(String clientCode) Set the user organization client code query parameter.Set the user email query parameter.setFetchLimit
(int fetchLimit) Set the query fetch limit to limit the maximum number of records returned.setFirstName
(String firstName) Set the user first name query parameter.setGlobalAccess
(boolean hasGlobalAccess) Set the user has administrative global organization access.Set the user id (PK) query parameter.setLastName
(String lastName) Set the user last name query parameter.setLoginName
(String loginName) Set the user login name query parameter.Set the user mobile number query parameter.setUserKey
(String userKey) Set the user key query parameter.setUserType
(String userType) Set the user type [ Local | LDAP | SSO ] query parameter.
-
Constructor Details
-
UserQuery
-
-
Method Details
-
setId
Set the user id (PK) query parameter.- Parameters:
id
- the user id (PK) query parameter- Returns:
- the user query
-
setLoginName
Set the user login name query parameter.- Parameters:
loginName
- the user login name query parameter- Returns:
- the user query
-
setAccountStatus
Set the user account status [ Active | Inactive | Locked | Locked Temporarily | Pending | Rejected ] query parameter.- Parameters:
accountStatus
- the user account status [ Active | Inactive | Locked | Locked Temporarily | Pending | Rejected ] query parameter- Returns:
- the user query
-
setEmail
Set the user email query parameter.- Parameters:
email
- the user email query parameter- Returns:
- the user query
-
setFirstName
Set the user first name query parameter.- Parameters:
firstName
- the user first name query parameter- Returns:
- the user query
-
setLastName
Set the user last name query parameter.- Parameters:
lastName
- the user last name query parameter- Returns:
- the user query
-
setMobile
Set the user mobile number query parameter.- Parameters:
mobile
- the user mobile number query parameter- Returns:
- the user query
-
setClientCode
Set the user organization client code query parameter.- Parameters:
clientCode
- the user client organization code query parameter- Returns:
- the user query
-
setUserKey
Set the user key query parameter.- Parameters:
userKey
- the user key query parameter- Returns:
- the user query
-
setUserType
Set the user type [ Local | LDAP | SSO ] query parameter.- Parameters:
userType
- the user type [ Local | LDAP | SSO ] query parameter- Returns:
- the user query
-
addGroup
Add the group name to the user query so that only users belonging to the group are included. Filtering on multiple groups is supported.- Parameters:
groupName
- the group name to query parameter- Returns:
- the user query
- Since:
- 18.11.0
-
addRole
Add the role name to the user query so that only users with this role are included. Filtering on multiple roles is supported.- Parameters:
roleName
- the role name query parameter- Returns:
- the user query
- Since:
- 21.11.0
-
addRoles
Add the roles name to the user query so that only users with these roles are included.For example, The following code shows how to list all users who have specified roles:
import com.avoka.tm.query.* import com.avoka.tm.vo.* List
users = new UserQuery().addRoles(Set.of("Role1", "Role2")).listValues(); - Parameters:
roleNames
- the roles name query parameter- Returns:
- the user query
- Since:
- 21.11.0
-
setGlobalAccess
Set the user has administrative global organization access.- Parameters:
hasGlobalAccess
- the user has administrative global organization access- Returns:
- the user query
-
setFetchLimit
Set the query fetch limit to limit the maximum number of records returned. The default query fetch limit is 100 records.- Parameters:
fetchLimit
- the query fetch limit- Returns:
- the user query
-
addOrderByAsc
Add the sort order by ascending to the query.- Parameters:
orderProperty
- the property to sort by (required)- Returns:
- the user query
-
addOrderByDesc
Add the sort order by descending to the query.- Parameters:
orderProperty
- the property to sort by (required)- Returns:
- the user query
-
count
public int count()Execute a select count query and return the total number of records selected by the query.- Returns:
- the total number of records selected by the query
-
listValues
Execute the user query and return a list of User value objects.- Returns:
- execute the user query and return a list of User value objects
-
listJson
Execute the query and return an users JSON array list.- Returns:
- execute the query and return an users JSON array list
-
firstValue
Execute the query and return the first user value object for the query.- Returns:
- execute the query and return the first user value object for the query
-
firstJson
Execute the query and return the first user JSON value.- Returns:
- execute the query and return the first user JSON value
-