Interface GroupProvider

All Superinterfaces:
GroupLookupProvider, Provider
All Known Subinterfaces:
CacheRealmProvider
All Known Implementing Classes:
GroupStorageManager, JpaRealmProvider, RealmCacheSession

public interface GroupProvider extends Provider, GroupLookupProvider
Provider of group records
Author:
mhajas
  • Method Details

    • getGroupsStream

      Stream<GroupModel> getGroupsStream(RealmModel realm)
      Returns groups for the given realm.
      Parameters:
      realm - Realm.
      Returns:
      Stream of groups in the Realm.
    • getGroupsStream

      default Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids)
      Returns a stream of groups with given ids. Effectively the same as getGroupsStream(realm, ids, null, null, null).
      Parameters:
      realm - Realm.
      ids - Stream of ids.
      Returns:
      Stream of GroupModels with the specified ids
    • getGroupsStream

      Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max)
      Returns a paginated stream of groups with given ids and given search value in group names.
      Parameters:
      realm - Realm.
      ids - Stream of ids.
      search - Case insensitive string which will be searched for. Ignored if null.
      first - Index of the first result to return. Ignored if negative or null.
      max - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of desired groups. Never returns null.
    • getGroupsStream

      default Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max)
      Returns a paginated stream of groups with given ids. Effectively the same as getGroupsStream(realm, ids, null, first, max).
      Parameters:
      realm - Realm.
      ids - Stream of ids.
      first - Index of the first result to return. Ignored if negative or null.
      max - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of GroupModels with the specified ids
    • getGroupsCount

      default Long getGroupsCount(RealmModel realm, Stream<String> ids, String search)
      Returns a number of groups that contains the search string in the name
      Parameters:
      realm - Realm.
      ids - List of ids.
      search - Case insensitive string which will be searched for. Ignored if null.
      Returns:
      Number of groups.
    • getGroupsCount

      Long getGroupsCount(RealmModel realm, Boolean onlyTopGroups)
      Returns a number of groups/top level groups (i.e. groups without parent group) for the given realm.
      Parameters:
      realm - Realm.
      onlyTopGroups - When true the function returns a count of top level groups only.
      Returns:
      Number of groups/top level groups.
    • getGroupsCountByNameContaining

      Long getGroupsCountByNameContaining(RealmModel realm, String search)
      Returns the number of top level groups containing groups with the given string in name for the given realm.
      Parameters:
      realm - Realm.
      search - Case insensitive string which will be searched for.
      Returns:
      Number of groups with the given string in its name.
    • getGroupsByRoleStream

      Stream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)
      Returns groups with the given role in the given realm.
      Parameters:
      realm - Realm.
      role - Role.
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of groups with the given role. Never returns null.
    • getTopLevelGroupsStream

      default Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm)
      Returns all top level groups (i.e. groups without parent group) for the given realm.
      Parameters:
      realm - Realm.
      Returns:
      Stream of all top level groups in the realm. Never returns null.
    • getTopLevelGroupsStream

      default Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, Integer firstResult, Integer maxResults)
      Returns top level groups (i.e. groups without parent group) for the given realm.
      Parameters:
      realm - Realm.
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of top level groups in the realm. Never returns null.
    • getTopLevelGroupsStream

      Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults)
      Returns top level groups (i.e. groups without parent group) for the given realm.
      Parameters:
      realm - Realm.
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      search - The name that should be matched
      Returns:
      Stream of top level groups in the realm. Never returns null.
    • createGroup

      default GroupModel createGroup(RealmModel realm, String name)
      Creates a new group with the given name in the given realm. Effectively the same as createGroup(realm, null, name, null).
      Parameters:
      realm - Realm.
      name - Name.
      Returns:
      Model of the created group.
      Throws:
      ModelDuplicateException - If there is already a top-level group with the given name
    • createGroup

      default GroupModel createGroup(RealmModel realm, String id, String name)
      Creates a new group with the given id and name in the given realm. Effectively the same as createGroup(realm, id, name, null)
      Parameters:
      realm - Realm.
      id - Id.
      name - Name.
      Returns:
      Model of the created group
      Throws:
      ModelDuplicateException - If a group with given id already exists or there is a top-level group with the given name
    • createGroup

      default GroupModel createGroup(RealmModel realm, String name, GroupModel toParent)
      Creates a new group with the given name and parent to the given realm. Effectively the same as createGroup(realm, null, name, toParent).
      Parameters:
      realm - Realm.
      name - Name.
      toParent - Parent group.
      Returns:
      Model of the created group.
      Throws:
      ModelDuplicateException - If the toParent group already has a subgroup with the given name
    • createGroup

      GroupModel createGroup(RealmModel realm, String id, String name, GroupModel toParent)
      Creates a new group with the given name, id, name and parent to the given realm.
      Parameters:
      realm - Realm.
      id - Id, will be generated if null.
      name - Name.
      toParent - Parent group, or null if the group is top level group
      Returns:
      Model of the created group
      Throws:
      ModelDuplicateException - If a group with the given id already exists or the toParent group has a subgroup with the given name
    • removeGroup

      boolean removeGroup(RealmModel realm, GroupModel group)
      Removes the given group for the given realm.
      Parameters:
      realm - Realm.
      group - Group.
      Returns:
      true if the group was removed, false if group doesn't exist or doesn't belong to the given realm
    • moveGroup

      void moveGroup(RealmModel realm, GroupModel group, GroupModel toParent)
      This method is used for moving groups in group structure, for example:
      • making an existing child group child group of some other group,
      • setting a top level group (i.e. group without parent group) child of some group,
      • making a child group top level group (i.e. removing its parent group).
        Parameters:
        realm - Realm owning this group.
        group - Group to update.
        toParent - New parent group, or null if we are moving the group to top level group.
        Throws:
        ModelDuplicateException - If there is already a group with group.name under the toParent group (or top-level if toParent is null)
      • addTopLevelGroup

        void addTopLevelGroup(RealmModel realm, GroupModel subGroup)
        Removes parent group for the given group in the given realm.
        Parameters:
        realm - Realm.
        subGroup - Group.
        Throws:
        ModelDuplicateException - If there is already a top level group name with the same name