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

        @Deprecated
        default Stream<UserModel> getUsersStream​(RealmModel realm,
                                                 Integer firstResult,
                                                 Integer maxResults)
        Deprecated.
        Use searchForUserStream(RealmModel, Map, Integer, Integer) with an empty params map instead.
        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.
      • 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.
      • searchForUserStream

        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.
      • 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.
      • searchForUserStream

        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.
      • 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.
      • getGroupMembersStream

        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.
      • 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.
      • 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.
      • searchForUserByUserAttributeStream

        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.