Interface UserQueryProvider

    • Method Detail

      • getUsersCount

        default int getUsersCount​(RealmModel realm)
        Returns the number of users, without consider any service account.
        Parameters:
        realm - the realm
        Returns:
        the number of users
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  Set<String> groupIds)
        Returns the number of users that are in at least one of the groups given.
        Parameters:
        realm - the realm
        groupIds - set of groups IDs, the returned user needs to belong to at least one of them
        Returns:
        the number of users that are in at least one of the groups
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  String search)
        Returns the number of users that would be returned by a call to searchForUserStream
        Parameters:
        realm - the realm
        search - case insensitive list of strings separated by whitespaces.
        Returns:
        number of users that match the search
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  String search,
                                  Set<String> groupIds)
        Returns the number of users that would be returned by a call to searchForUserStream and are members of at least one of the groups given by the groupIds set.
        Parameters:
        realm - the realm
        search - case insensitive list of strings separated by whitespaces.
        groupIds - set of groups IDs, the returned user needs to belong to at least one of them
        Returns:
        number of users that match the search and given groups
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  Map<String,​String> params)
        Returns the number of users that match the given filter parameters.
        Parameters:
        realm - the realm
        params - filter parameters
        Returns:
        number of users that match the given filters
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  Map<String,​String> params,
                                  Set<String> groupIds)
        Returns the number of users that match the given filter parameters and is in at least one of the given groups.
        Parameters:
        params - filter parameters
        realm - the realm
        groupIds - set if groups to check for
        Returns:
        number of users that match the given filters and groups
      • countUsersInGroups

        static int countUsersInGroups​(Stream<UserModel> users,
                                      Set<String> groupIds)
        Returns the number of users from the given list of users that are in at least one of the groups given in the groups set.
        Parameters:
        users - list of users to check
        groupIds - id of groups that should be checked for
        Returns:
        number of users that are in at least one of the groups
      • getUsersCount

        default int getUsersCount​(RealmModel realm,
                                  boolean includeServiceAccount)
        Returns the number of users.
        Parameters:
        realm - the realm
        includeServiceAccount - if true, the number of users will also include service accounts. Otherwise, only the number of users.
        Returns:
        the number of users
      • getUsersStream

        default Stream<UserModel> getUsersStream​(RealmModel realm)
        Searches all users in the realm.
        Parameters:
        realm - a reference to the realm.
        Returns:
        a non-null Stream of users.
      • getUsersStream

        default Stream<UserModel> getUsersStream​(RealmModel realm,
                                                 Integer firstResult,
                                                 Integer maxResults)
        Searches all users in the realm, starting from the firstResult and containing at most maxResults.
        Parameters:
        realm - a reference to the realm.
        firstResult - first result to return. Ignored if negative or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of users.
      • searchForUser

        @Deprecated
        List<UserModel> searchForUser​(String search,
                                      RealmModel realm)
        Deprecated.
        Use searchForUserStream instead.
        Searches for users whose username, email, first name or last name contain any of the strings in search separated by whitespace.

        If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE.

        This method is used by the admin console search box

        Parameters:
        search - case insensitive list of string separated by whitespaces.
        realm - realm to search within
        Returns:
        list of users that satisfies the given search condition
      • searchForUserStream

        default Stream<UserModel> searchForUserStream​(RealmModel realm,
                                                      String search)
        Searches for users whose username, email, first name or last name contain any of the strings in search separated by whitespace.

        If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE).

        This method is used by the admin console search box

        Parameters:
        realm - a reference to the realm.
        search - case insensitive list of string separated by whitespaces.
        Returns:
        a non-null Stream of users that match the search string.
      • searchForUser

        @Deprecated
        List<UserModel> searchForUser​(String search,
                                      RealmModel realm,
                                      int firstResult,
                                      int maxResults)
        Deprecated.
        Use searchForUserStream instead.
        Searches for users whose username, email, first name or last name contain any of the strings in search separated by whitespace. The resulting user list should be paginated with respect to parameters firstResult and maxResults

        If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE.

        This method is used by the admin console search box

        Parameters:
        search - case insensitive list of string separated by whitespaces.
        realm - a reference to the realm
        firstResult - first result to return. Ignored if negative or zero.
        maxResults - maximum number of results to return. Ignored if negative.
        Returns:
        paginated list of users from the realm that satisfies given search
      • searchForUserStream

        default Stream<UserModel> searchForUserStream​(RealmModel realm,
                                                      String search,
                                                      Integer firstResult,
                                                      Integer maxResults)
        Searches for users whose username, email, first name or last name contain any of the strings in search separated by whitespace.

        If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE).

        This method is used by the admin console search box

        Parameters:
        realm - a reference to the realm.
        search - case insensitive list of string separated by whitespaces.
        firstResult - first result to return. Ignored if negative, zero, or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of users that match the search criteria.
      • searchForUser

        @Deprecated
        List<UserModel> searchForUser​(Map<String,​String> params,
                                      RealmModel realm)
        Deprecated.
        Use searchForUserStream instead.
        Search for user by a map of parameters.

        Valid parameters are:

        If possible, implementations should treat the parameter values as partial match patterns i.e. in RDMBS terms use LIKE.

        This method is used by the REST API when querying users.

        Parameters:
        params - a map containing the search parameters
        realm - a reference to the realm
        Returns:
        list of users that satisfies given search conditions
      • searchForUserStream

        default Stream<UserModel> searchForUserStream​(RealmModel realm,
                                                      Map<String,​String> params)
        Searches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE).

        Valid parameters are:

        This method is used by the REST API when querying users.
        Parameters:
        realm - a reference to the realm.
        params - a map containing the search parameters.
        Returns:
        a non-null Stream of users that match the search parameters.
      • searchForUser

        @Deprecated
        List<UserModel> searchForUser​(Map<String,​String> params,
                                      RealmModel realm,
                                      int firstResult,
                                      int maxResults)
        Deprecated.
        Use searchForUserStream instead.
        Search for user by parameter.

        Valid parameters are:

        If possible, implementations should treat the parameter values as patterns i.e. in RDMBS terms use LIKE.

        This method is used by the REST API when querying users.

        Parameters:
        params - a map containing the search parameters.
        realm - a reference to the realm.
        firstResult - first result to return. Ignored if negative.
        maxResults - maximum number of results to return. Ignored if negative.
        Returns:
        a non-null Stream of users that match the search criteria.
      • searchForUserStream

        default Stream<UserModel> searchForUserStream​(RealmModel realm,
                                                      Map<String,​String> params,
                                                      Integer firstResult,
                                                      Integer maxResults)
        Searches for user by parameter. If possible, implementations should treat the parameter values as partial match patterns (i.e. in RDMBS terms use LIKE).

        Valid parameters are:

        Any other parameters will be treated as custom user attributes. This method is used by the REST API when querying users.
        Parameters:
        realm - a reference to the realm.
        params - a map containing the search parameters.
        firstResult - first result to return. Ignored if negative, zero, or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of users that match the search criteria.
      • getGroupMembers

        @Deprecated
        List<UserModel> getGroupMembers​(RealmModel realm,
                                        GroupModel group)
        Deprecated.
        Get users that belong to a specific group.
        Parameters:
        realm - a reference to the realm
        group - a reference to the group
        Returns:
        a list of all users that are members of the given group
      • getGroupMembersStream

        default Stream<UserModel> getGroupMembersStream​(RealmModel realm,
                                                        GroupModel group)
        Obtains users that belong to a specific group.
        Parameters:
        realm - a reference to the realm.
        group - a reference to the group.
        Returns:
        a non-null Stream of users that belong to the group.
      • getGroupMembers

        @Deprecated
        List<UserModel> getGroupMembers​(RealmModel realm,
                                        GroupModel group,
                                        int firstResult,
                                        int maxResults)
        Deprecated.
        Gets paginated list of users that belong to a specific group.
        Parameters:
        realm - a reference to the realm
        group - a reference to the group
        firstResult - first result to return. Ignored if negative or zero.
        maxResults - maximum number of results to return. Ignored if negative.
        Returns:
        paginated list of members of the given group
      • getGroupMembersStream

        default Stream<UserModel> getGroupMembersStream​(RealmModel realm,
                                                        GroupModel group,
                                                        Integer firstResult,
                                                        Integer maxResults)
        Obtains users that belong to a specific group.
        Parameters:
        realm - a reference to the realm.
        group - a reference to the group.
        firstResult - first result to return. Ignored if negative, zero, or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of users that belong to the group.
      • getRoleMembers

        @Deprecated
        default List<UserModel> getRoleMembers​(RealmModel realm,
                                               RoleModel role)
        Deprecated.
        Get users that belong to a specific role.
        Parameters:
        realm - a reference to the realm
        role - a reference to the role
        Returns:
        a list of users that has the given role assigned
      • getRoleMembersStream

        default Stream<UserModel> getRoleMembersStream​(RealmModel realm,
                                                       RoleModel role)
        Obtains users that have the specified role.
        Parameters:
        realm - a reference to the realm.
        role - a reference to the role.
        Returns:
        a non-null Stream of users that have the specified role.
      • getRoleMembers

        @Deprecated
        default List<UserModel> getRoleMembers​(RealmModel realm,
                                               RoleModel role,
                                               int firstResult,
                                               int maxResults)
        Deprecated.
        Search for users that have a specific role with a specific roleId.
        Parameters:
        realm - a reference to the realm
        role - a reference to the role
        firstResult - first result to return. Ignored if negative or zero.
        maxResults - maximum number of results to return. Ignored if negative.
        Returns:
        a paginated list of users that has the given role assigned
      • getRoleMembersStream

        default Stream<UserModel> getRoleMembersStream​(RealmModel realm,
                                                       RoleModel role,
                                                       Integer firstResult,
                                                       Integer maxResults)
        Searches for users that have the specified role.
        Parameters:
        realm - a reference to the realm.
        role - a reference to the role.
        firstResult - first result to return. Ignored if negative or null.
        maxResults - maximum number of results to return. Ignored if negative or null.
        Returns:
        a non-null Stream of users that have the specified role.
      • searchForUserByUserAttribute

        @Deprecated
        List<UserModel> searchForUserByUserAttribute​(String attrName,
                                                     String attrValue,
                                                     RealmModel realm)
        Deprecated.
        Search for users that have a specific attribute with a specific value.
        Parameters:
        attrName - a name of the attribute that will be searched
        attrValue - a value of the attribute that will be searched
        realm - a reference to the realm
        Returns:
        list of users with the given attribute name and value
      • searchForUserByUserAttributeStream

        default Stream<UserModel> searchForUserByUserAttributeStream​(RealmModel realm,
                                                                     String attrName,
                                                                     String attrValue)
        Searches for users that have a specific attribute with a specific value.
        Parameters:
        realm - a reference to the realm.
        attrName - the attribute name.
        attrValue - the attribute value.
        Returns:
        a non-null Stream of users that match the search criteria.