Class UserQuery

java.lang.Object
com.avoka.tm.query.UserQuery

public class UserQuery extends Object

Provides a user value object query class.

Examples Link icon

Please find the user query examples about list, get first and count below.

User Query List Example Link icon

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 Link icon

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 Link icon

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 Details Link icon

  • Method Details Link icon

    • setId Link icon

      public UserQuery setId(Long id)
      Set the user id (PK) query parameter.
      Parameters:
      id - the user id (PK) query parameter
      Returns:
      the user query
    • setLoginName Link icon

      public UserQuery setLoginName(String loginName)
      Set the user login name query parameter.
      Parameters:
      loginName - the user login name query parameter
      Returns:
      the user query
    • setAccountStatus Link icon

      public UserQuery setAccountStatus(String accountStatus)
      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 Link icon

      public UserQuery setEmail(String email)
      Set the user email query parameter.
      Parameters:
      email - the user email query parameter
      Returns:
      the user query
    • setFirstName Link icon

      public UserQuery setFirstName(String firstName)
      Set the user first name query parameter.
      Parameters:
      firstName - the user first name query parameter
      Returns:
      the user query
    • setLastName Link icon

      public UserQuery setLastName(String lastName)
      Set the user last name query parameter.
      Parameters:
      lastName - the user last name query parameter
      Returns:
      the user query
    • setMobile Link icon

      public UserQuery setMobile(String mobile)
      Set the user mobile number query parameter.
      Parameters:
      mobile - the user mobile number query parameter
      Returns:
      the user query
    • setPhone Link icon

      public UserQuery setPhone(String phone)
      Set the user phone number query parameter.
      Parameters:
      phone - the user phone number query parameter
      Returns:
      the user query
      Since:
      22.10.4
    • setClientCode Link icon

      public UserQuery setClientCode(String clientCode)
      Set the user organization client code query parameter.
      Parameters:
      clientCode - the user client organization code query parameter
      Returns:
      the user query
    • setUserKey Link icon

      public UserQuery setUserKey(String userKey)
      Set the user key query parameter.
      Parameters:
      userKey - the user key query parameter
      Returns:
      the user query
    • setUserType Link icon

      public UserQuery setUserType(String userType)
      Set the user type [ Local | LDAP | SSO ] query parameter.
      Parameters:
      userType - the user type [ Local | LDAP | SSO ] query parameter
      Returns:
      the user query
    • addGroup Link icon

      public UserQuery addGroup(String groupName)
      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 Link icon

      public UserQuery addRole(String roleName)
      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 Link icon

      public UserQuery addRoles(Collection<String> roleNames)
      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 Link icon

      public UserQuery setGlobalAccess(boolean hasGlobalAccess)
      Set the user has administrative global organization access.
      Parameters:
      hasGlobalAccess - the user has administrative global organization access
      Returns:
      the user query
    • setFetchLimit Link icon

      public UserQuery setFetchLimit(int fetchLimit)
      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 Link icon

      public UserQuery addOrderByAsc(String orderProperty)
      Add the sort order by ascending to the query.
      Parameters:
      orderProperty - the property to sort by (required)
      Returns:
      the user query
    • addOrderByDesc Link icon

      public UserQuery addOrderByDesc(String orderProperty)
      Add the sort order by descending to the query.
      Parameters:
      orderProperty - the property to sort by (required)
      Returns:
      the user query
    • count Link icon

      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 Link icon

      public List<User> 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 Link icon

      public String listJson()
      Execute the query and return an users JSON array list.
      Returns:
      execute the query and return an users JSON array list
    • firstValue Link icon

      public User 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 Link icon

      public String firstJson()
      Execute the query and return the first user JSON value.
      Returns:
      execute the query and return the first user JSON value