Interface GroupService

    • Method Detail

      • setName

        void setName​(Group group,
                     String name)
              throws SQLException
        set name of group
        Parameters:
        group - DSpace group
        name - new group name
        Throws:
        SQLException - if database error
      • addMember

        void addMember​(Context context,
                       Group group,
                       EPerson e)
        add an eperson member
        Parameters:
        context - DSpace context object
        group - DSpace group
        e - eperson
      • addMember

        void addMember​(Context context,
                       Group groupParent,
                       Group groupChild)
                throws SQLException
        add group to this group
        Parameters:
        context - DSpace context object
        groupParent - parent group
        groupChild - child group
        Throws:
        SQLException - if database error
      • removeMember

        void removeMember​(Context context,
                          Group group,
                          EPerson ePerson)
        remove an eperson from a group
        Parameters:
        context - DSpace context object
        group - DSpace group
        ePerson - eperson
      • removeMember

        void removeMember​(Context context,
                          Group groupParent,
                          Group childGroup)
                   throws SQLException
        remove group from this group
        Parameters:
        context - DSpace context object
        groupParent - parent group
        childGroup - child group
        Throws:
        SQLException - if database error
      • isDirectMember

        boolean isDirectMember​(Group group,
                               EPerson ePerson)
        check to see if an eperson is a direct member. If the eperson is a member via a subgroup will be returned false
        Parameters:
        group - DSpace group
        ePerson - eperson to check membership
        Returns:
        true or false
      • isMember

        boolean isMember​(Group owningGroup,
                         Group childGroup)
        Check to see if childGroup is a direct group member of owningGroup. If childGroup is a subgroup via another group will be returned false
        Parameters:
        owningGroup - parent group
        childGroup - child group
        Returns:
        true or false
      • isParentOf

        boolean isParentOf​(Context context,
                           Group parentGroup,
                           Group childGroup)
                    throws SQLException
        Check to see if parentGroup is a direct or in-direct parent of a childGroup.
        Parameters:
        parentGroup - parent group
        childGroup - child group
        Returns:
        true or false
        Throws:
        SQLException
      • isMember

        boolean isMember​(Context context,
                         Group group)
                  throws SQLException
        fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method
        Parameters:
        context - context
        group - group to check
        Returns:
        true or false
        Throws:
        SQLException - if database error
      • isMember

        boolean isMember​(Context context,
                         String groupName)
                  throws SQLException
        fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method. This method uses context.getCurrentUser() as eperson whos membership should be checked.
        Parameters:
        context - context
        groupName - the name of the group to check
        Returns:
        true or false
        Throws:
        SQLException - if database error
      • isMember

        boolean isMember​(Context context,
                         EPerson epersonToCheck,
                         String groupName)
                  throws SQLException
        fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method. The eperson whos membership should be checked must be defined as method attribute.
        Parameters:
        context - context
        groupName - the name of the group to check
        Returns:
        true or false
        Throws:
        SQLException - if database error
      • isMember

        boolean isMember​(Context context,
                         EPerson eperson,
                         Group group)
                  throws SQLException
        fast check to see if an eperson is a member called with eperson id, does database lookup without instantiating all of the epeople objects and is thus a static method
        Parameters:
        context - DSpace context object.
        eperson - EPerson whos membership should be checked.
        group - The group to check against.
        Returns:
        true or false
        Throws:
        SQLException - if database error
      • allMemberGroups

        List<Group> allMemberGroups​(Context context,
                                    EPerson ePerson)
                             throws SQLException
        Get all of the groups that an eperson is a member of.
        Parameters:
        context - DSpace contenxt
        ePerson - ePerson object
        Returns:
        list of Group objects
        Throws:
        SQLException - if database error
      • allMembers

        List<EPerson> allMembers​(Context context,
                                 Group group)
                          throws SQLException
        Get all of the epeople who are a member of the specified group, or a member of a sub-group of the specified group, etc.
        Parameters:
        context - The relevant DSpace Context.
        group - Group object
        Returns:
        List of EPerson objects
        Throws:
        SQLException - if error
      • findByName

        Group findByName​(Context context,
                         String name)
                  throws SQLException
        Find the group by its name - assumes name is unique
        Parameters:
        context - The relevant DSpace Context.
        name - Group name to search for
        Returns:
        the named Group, or null if not found
        Throws:
        SQLException - if error
      • findAll

        List<Group> findAll​(Context context,
                            List<MetadataField> metadataSortFields,
                            int pageSize,
                            int offset)
                     throws SQLException
        Finds all groups in the site
        Parameters:
        context - The relevant DSpace Context.
        metadataSortFields - metadata fields to sort by, leave empty to sort by Name
        pageSize - how many results return
        offset - the position of the first result to return
        Returns:
        List of all groups in the site
        Throws:
        SQLException - if error
      • findAll

        List<Group> findAll​(Context context,
                            List<MetadataField> metadataSortFields)
                     throws SQLException
        Deprecated.
        Please use findAll(Context context, List<MetadataField> metadataFieldsSort, int pageSize, int offset) instead
        Parameters:
        context - The relevant DSpace Context.
        metadataSortFields - metadata fields to sort by, leave empty to sort by Name
        Returns:
        List of all groups in the site
        Throws:
        SQLException - if error
      • findAll

        @Deprecated
        List<Group> findAll​(Context context,
                            int sortField)
                     throws SQLException
        Deprecated.
        DEPRECATED: Please use findAll(Context context, List<MetadataField> metadataFieldsSort) instead
        Parameters:
        context - DSpace context
        sortField - sort field index
        Returns:
        List of all groups in the site
        Throws:
        SQLException - if error
      • search

        List<Group> search​(Context context,
                           String groupIdentifier)
                    throws SQLException
        Find the groups that match the search query across eperson_group_id or name
        Parameters:
        context - DSpace context
        groupIdentifier - The group name or group ID
        Returns:
        array of Group objects
        Throws:
        SQLException - if error
      • search

        List<Group> search​(Context context,
                           String groupIdentifier,
                           int offset,
                           int limit)
                    throws SQLException
        Find the groups that match the search query across eperson_group_id or name
        Parameters:
        context - DSpace context
        groupIdentifier - The group name or group ID
        offset - Inclusive offset
        limit - Maximum number of matches returned
        Returns:
        array of Group objects
        Throws:
        SQLException - if error
      • searchResultCount

        int searchResultCount​(Context context,
                              String query)
                       throws SQLException
        Returns the total number of groups returned by a specific query, without the overhead of creating the Group objects to store the results.
        Parameters:
        context - DSpace context
        query - The search string
        Returns:
        the number of groups matching the query
        Throws:
        SQLException - if error
      • isEmpty

        boolean isEmpty​(Group group)
        Return true if group has no direct or indirect members
        Parameters:
        group - DSpace group
        Returns:
        true or false
      • getEmptyGroups

        List<Group> getEmptyGroups​(Context context)
                            throws SQLException
        Find all empty groups in DSpace
        Parameters:
        context - The DSpace context
        Returns:
        All empty groups
        Throws:
        SQLException - database exception
      • countTotal

        int countTotal​(Context context)
                throws SQLException
        Count the total number of groups in DSpace
        Parameters:
        context - The DSpace context
        Returns:
        The total number of groups
        Throws:
        SQLException - database exception
      • findByMetadataField

        List<Group> findByMetadataField​(Context context,
                                        String searchValue,
                                        MetadataField metadataField)
                                 throws SQLException
        Look up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)
        Parameters:
        context - The DSpace context
        searchValue - The value to match
        metadataField - The metadata field to search in
        Returns:
        The groups that have a matching value for specified metadata field
        Throws:
        SQLException - database exception