Class GroupDAOImpl

All Implemented Interfaces:
DSpaceObjectDAO<Group>, DSpaceObjectLegacySupportDAO<Group>, GenericDAO<Group>, GroupDAO

public class GroupDAOImpl extends AbstractHibernateDSODAO<Group> implements GroupDAO
Hibernate implementation of the Database Access Object interface class for the Group object. This class is responsible for all database calls for the Group object and is autowired by spring This class should never be accessed directly.
Author:
kevinvandevelde at atmire.com
  • Constructor Details

    • GroupDAOImpl

      protected GroupDAOImpl()
  • Method Details

    • findByMetadataField

      public List<Group> findByMetadataField(Context context, String searchValue, MetadataField metadataField) throws SQLException
      Description copied from interface: GroupDAO
      Look up groups based on their value for a certain metadata field (NOTE: name is not stored as metadata)
      Specified by:
      findByMetadataField in interface GroupDAO
      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 - if database error
    • findAll

      public List<Group> findAll(Context context, List<MetadataField> sortMetadataFields, int pageSize, int offset) throws SQLException
      Description copied from interface: GroupDAO
      Find all groups ordered by the specified metadata fields ascending
      Specified by:
      findAll in interface GroupDAO
      Parameters:
      context - The DSpace context
      sortMetadataFields - The metadata fields to sort on
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      A list of all groups, ordered by metadata fields
      Throws:
      SQLException - if database error
    • findAll

      public List<Group> findAll(Context context, int pageSize, int offset) throws SQLException
      Description copied from interface: GroupDAO
      Find all groups ordered by name ascending
      Specified by:
      findAll in interface GroupDAO
      Parameters:
      context - The DSpace context
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      A list of all groups, ordered by name
      Throws:
      SQLException - if database error
    • findByEPerson

      public List<Group> findByEPerson(Context context, EPerson ePerson) throws SQLException
      Description copied from interface: GroupDAO
      Find all groups that the given ePerson belongs to
      Specified by:
      findByEPerson in interface GroupDAO
      Parameters:
      context - The DSpace context
      ePerson - The EPerson to match
      Returns:
      A list of all groups to which the given EPerson belongs
      Throws:
      SQLException - if database error
    • findByName

      public Group findByName(Context context, String name) throws SQLException
      Description copied from interface: GroupDAO
      Find a group by its name (exact match)
      Specified by:
      findByName in interface GroupDAO
      Parameters:
      context - The DSpace context
      name - The name of the group to look for
      Returns:
      The group with the specified name
      Throws:
      SQLException - if database error
    • findByIdAndMembership

      public Group findByIdAndMembership(Context context, UUID id, EPerson ePerson) throws SQLException
      Description copied from interface: GroupDAO
      Find a group by its name and the membership of the given EPerson
      Specified by:
      findByIdAndMembership in interface GroupDAO
      Parameters:
      context - The DSpace context
      id - The id of the group to look for
      ePerson - The EPerson which has to be a member
      Returns:
      The group with the specified name
      Throws:
      SQLException - if database error
    • findByNameLike

      public List<Group> findByNameLike(Context context, String groupName, int offset, int limit) throws SQLException
      Description copied from interface: GroupDAO
      Find a group by its name (fuzzy match)
      Specified by:
      findByNameLike in interface GroupDAO
      Parameters:
      context - The DSpace context
      groupName - Part of the group's name to search for
      offset - Offset to use for pagination (-1 to disable)
      limit - The maximum number of results to return (-1 to disable)
      Returns:
      Groups matching the query
      Throws:
      SQLException - if database error
    • countByNameLike

      public int countByNameLike(Context context, String groupName) throws SQLException
      Description copied from interface: GroupDAO
      Count the number of groups that have a name that contains the given string
      Specified by:
      countByNameLike in interface GroupDAO
      Parameters:
      context - The DSpace context
      groupName - Part of the group's name to search for
      Returns:
      The number of matching groups
      Throws:
      SQLException - if database error
    • findByNameLikeAndNotMember

      public List<Group> findByNameLikeAndNotMember(Context context, String groupName, Group excludeParent, int offset, int limit) throws SQLException
      Description copied from interface: GroupDAO
      Search all groups via their name (fuzzy match), limited to those groups which are NOT a member of the given parent group. This may be used to search across groups which are valid to add to the given parent group.

      NOTE: The parent group itself is also excluded from the search.

      Specified by:
      findByNameLikeAndNotMember in interface GroupDAO
      Parameters:
      context - The DSpace context
      groupName - Group name to fuzzy match against.
      excludeParent - Parent Group to exclude results from. Groups under this parent will never be returned.
      offset - Offset to use for pagination (-1 to disable)
      limit - The maximum number of results to return (-1 to disable)
      Returns:
      Groups matching the query (which are not members of the given parent)
      Throws:
      SQLException - if database error
    • countByNameLikeAndNotMember

      public int countByNameLikeAndNotMember(Context context, String groupName, Group excludeParent) throws SQLException
      Description copied from interface: GroupDAO
      Count number of groups that match a given name (fuzzy match), limited to those groups which are NOT a member of the given parent group. This may be used (with findByNameLikeAndNotMember()) to search across groups which are valid to add to the given parent group.

      NOTE: The parent group itself is also excluded from the count.

      Specified by:
      countByNameLikeAndNotMember in interface GroupDAO
      Parameters:
      context - The DSpace context
      groupName - Group name to fuzzy match against.
      excludeParent - Parent Group to exclude results from. Groups under this parent will never be returned.
      Returns:
      Groups matching the query (which are not members of the given parent)
      Throws:
      SQLException - if database error
    • delete

      public void delete(Context context, Group group) throws SQLException
      Description copied from interface: GenericDAO
      Remove an instance from the database.
      Specified by:
      delete in interface GenericDAO<Group>
      Overrides:
      delete in class AbstractHibernateDAO<Group>
      Parameters:
      context - current DSpace context.
      group - type of the instance to be removed.
      Throws:
      SQLException - passed through.
    • getGroup2GroupResults

      public List<org.apache.commons.lang3.tuple.Pair<UUID,UUID>> getGroup2GroupResults(Context context, boolean flushQueries) throws SQLException
      Description copied from interface: GroupDAO
      Get a list of all direct parent - child group relations in the database
      Specified by:
      getGroup2GroupResults in interface GroupDAO
      Parameters:
      context - The DSpace context
      flushQueries - Flush all pending queries
      Returns:
      A list of pairs indicating parent - child
      Throws:
      SQLException - if database error
    • getEmptyGroups

      public List<Group> getEmptyGroups(Context context) throws SQLException
      Description copied from interface: GroupDAO
      Return all empty groups
      Specified by:
      getEmptyGroups in interface GroupDAO
      Parameters:
      context - The DSpace context
      Returns:
      All empty groups
      Throws:
      SQLException - if database error
    • countRows

      public int countRows(Context context) throws SQLException
      Description copied from interface: GroupDAO
      Count the number of groups in DSpace
      Specified by:
      countRows in interface GroupDAO
      Parameters:
      context - The DSpace context
      Returns:
      The number of groups
      Throws:
      SQLException - if database error
    • findByParent

      public List<Group> findByParent(Context context, Group parent, int pageSize, int offset) throws SQLException
      Description copied from interface: GroupDAO
      Find all groups which are members of a given parent group. This provides the same behavior as group.getMemberGroups(), but in a paginated fashion.
      Specified by:
      findByParent in interface GroupDAO
      Parameters:
      context - The DSpace context
      parent - Parent Group to search within
      pageSize - how many results return
      offset - the position of the first result to return
      Returns:
      Groups matching the query
      Throws:
      SQLException - if database error
    • countByParent

      public int countByParent(Context context, Group parent) throws SQLException
      Description copied from interface: GroupDAO
      Returns the number of groups which are members of a given parent group. This provides the same behavior as group.getMemberGroups().size(), but with better performance for large groups. This method may be used with findByParent() to perform pagination.
      Specified by:
      countByParent in interface GroupDAO
      Parameters:
      context - The DSpace context
      parent - Parent Group to search within
      Returns:
      Number of Groups matching the query
      Throws:
      SQLException - if database error