Class ItemDAOImpl

All Implemented Interfaces:
DSpaceObjectDAO<Item>, DSpaceObjectLegacySupportDAO<Item>, ItemDAO, GenericDAO<Item>

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

    • ItemDAOImpl

      protected ItemDAOImpl()
  • Method Details

    • findAll

      public Iterator<Item> findAll(Context context, boolean archived) throws SQLException
      Specified by:
      findAll in interface ItemDAO
      Throws:
      SQLException
    • findAll

      public Iterator<Item> findAll(Context context, boolean archived, int limit, int offset) throws SQLException
      Specified by:
      findAll in interface ItemDAO
      Throws:
      SQLException
    • findAll

      public Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn) throws SQLException
      Specified by:
      findAll in interface ItemDAO
      Throws:
      SQLException
    • findAllRegularItems

      public Iterator<Item> findAllRegularItems(Context context) throws SQLException
      Description copied from interface: ItemDAO
      Find all items that are: - NOT in the workspace - NOT in the workflow - NOT a template item for e.g. a collection This implies that the result also contains older versions of items and withdrawn items.
      Specified by:
      findAllRegularItems in interface ItemDAO
      Parameters:
      context - the DSpace context.
      Returns:
      iterator over all regular items.
      Throws:
      SQLException - if database error.
    • findAll

      public Iterator<Item> findAll(Context context, boolean archived, boolean withdrawn, boolean discoverable, Instant lastModified) throws SQLException
      Description copied from interface: ItemDAO
      Get all Items installed or withdrawn, discoverable, and modified since a Date.
      Specified by:
      findAll in interface ItemDAO
      Parameters:
      context - context
      archived - whether to find archived
      withdrawn - whether to find withdrawn
      discoverable - whether to find discoverable
      lastModified - earliest interesting last-modified date.
      Returns:
      iterator over items
      Throws:
      SQLException - if database error
    • findBySubmitter

      public Iterator<Item> findBySubmitter(Context context, EPerson eperson) throws SQLException
      Specified by:
      findBySubmitter in interface ItemDAO
      Throws:
      SQLException
    • findBySubmitter

      public Iterator<Item> findBySubmitter(Context context, EPerson eperson, boolean retrieveAllItems) throws SQLException
      Description copied from interface: ItemDAO
      Find all the items by a given submitter. The order is indeterminate. All items are included.
      Specified by:
      findBySubmitter in interface ItemDAO
      Parameters:
      context - DSpace context object
      eperson - the submitter
      retrieveAllItems - flag to determine if only archive should be returned
      Returns:
      an iterator over the items submitted by eperson
      Throws:
      SQLException - if database error
    • findBySubmitter

      public Iterator<Item> findBySubmitter(Context context, EPerson eperson, MetadataField metadataField, int limit) throws SQLException
      Specified by:
      findBySubmitter in interface ItemDAO
      Throws:
      SQLException
    • findByMetadataField

      public Iterator<Item> findByMetadataField(Context context, MetadataField metadataField, String value, boolean inArchive) throws SQLException
      Specified by:
      findByMetadataField in interface ItemDAO
      Throws:
      SQLException
    • findByMetadataQuery

      public List<Item> findByMetadataQuery(Context context, List<QueryPredicate> queryPredicates, List<UUID> collectionUuids, String regexClause, long offset, int limit) throws SQLException
      Description copied from interface: ItemDAO
      Returns all the Items that belong to the specified aollections (if any) and match the provided predicates.
      Specified by:
      findByMetadataQuery in interface ItemDAO
      Parameters:
      context - The relevant DSpace context
      queryPredicates - List of predicates that returned items are required to match
      collectionUuids - UUIDs of the collections to search. If none are provided, the entire repository will be searched.
      regexClause - Syntactic expression used to query the database using a regular expression (e.g.: "value ~ ?")
      offset - The offset for the query
      limit - Maximum number of items to return
      Returns:
      A list containing the items that match the provided criteria
      Throws:
      SQLException - if something goes wrong
    • countForMetadataQuery

      public long countForMetadataQuery(Context context, List<QueryPredicate> queryPredicates, List<UUID> collectionUuids, String regexClause) throws SQLException
      Specified by:
      countForMetadataQuery in interface ItemDAO
      Throws:
      SQLException
    • findByAuthorityValue

      public Iterator<Item> findByAuthorityValue(Context context, MetadataField metadataField, String authority, boolean inArchive) throws SQLException
      Specified by:
      findByAuthorityValue in interface ItemDAO
      Throws:
      SQLException
    • findArchivedByCollection

      public Iterator<Item> findArchivedByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException
      Specified by:
      findArchivedByCollection in interface ItemDAO
      Throws:
      SQLException
    • findArchivedByCollectionExcludingOwning

      public Iterator<Item> findArchivedByCollectionExcludingOwning(Context context, Collection collection, Integer limit, Integer offset) throws SQLException
      Description copied from interface: ItemDAO
      Returns all the Items in an iterator that are archived and for which the given Collection is part of the Item's Collections but it is not the owning collection
      Specified by:
      findArchivedByCollectionExcludingOwning in interface ItemDAO
      Parameters:
      context - The relevant DSpace context
      collection - The collection to check on
      limit - The limit for the query
      offset - The offset for the query
      Returns:
      An iterator containing the items for which the constraints hold true
      Throws:
      SQLException - If something goes wrong
    • countArchivedByCollectionExcludingOwning

      public int countArchivedByCollectionExcludingOwning(Context context, Collection collection) throws SQLException
      Description copied from interface: ItemDAO
      Counts all the items that are archived and for which the given Collection is part of the Item's Collections but it is not the owning Collection
      Specified by:
      countArchivedByCollectionExcludingOwning in interface ItemDAO
      Parameters:
      context - The relevant DSpace context
      collection - The collection to check on
      Returns:
      The total amount of items that fit the constraints
      Throws:
      SQLException - If something goes wrong
    • findAllByCollection

      public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException
      Specified by:
      findAllByCollection in interface ItemDAO
      Throws:
      SQLException
    • findAllByCollection

      public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException
      Specified by:
      findAllByCollection in interface ItemDAO
      Throws:
      SQLException
    • countItems

      public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException
      Description copied from interface: ItemDAO
      Count number of items in a given collection
      Specified by:
      countItems in interface ItemDAO
      Parameters:
      context - context
      collection - the collection
      includeArchived - whether to include archived items in count
      includeWithdrawn - whether to include withdrawn items in count
      Returns:
      item count
      Throws:
      SQLException - if database error
    • countItems

      public int countItems(Context context, List<Collection> collections, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException
      Description copied from interface: ItemDAO
      Count number of unique items across several collections at once. This method can be used with CommunityService.getAllCollections(Context, Community) to determine the unique number of items in a Community.
      Specified by:
      countItems in interface ItemDAO
      Parameters:
      context - context
      collections - the list of collections
      includeArchived - whether to include archived items in count
      includeWithdrawn - whether to include withdrawn items in count
      Returns:
      item count
      Throws:
      SQLException - if database error
    • findByLastModifiedSince

      public Iterator<Item> findByLastModifiedSince(Context context, Instant since) throws SQLException
      Description copied from interface: ItemDAO
      Find all Items modified since a Date.
      Specified by:
      findByLastModifiedSince in interface ItemDAO
      Parameters:
      context - Context
      since - Earliest interesting last-modified date.
      Returns:
      iterator over items
      Throws:
      SQLException - if database error
    • countRows

      public int countRows(Context context) throws SQLException
      Description copied from interface: ItemDAO
      Count total number of items (rows in item table)
      Specified by:
      countRows in interface ItemDAO
      Parameters:
      context - context
      Returns:
      total count
      Throws:
      SQLException - if database error
    • countItems

      public int countItems(Context context, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException
      Description copied from interface: ItemDAO
      Count number of items based on specific status flags
      Specified by:
      countItems in interface ItemDAO
      Parameters:
      context - context
      includeArchived - whether to include archived items in count
      includeWithdrawn - whether to include withdrawn items in count
      Returns:
      count of items
      Throws:
      SQLException - if database error
    • countItems

      public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException
      Description copied from interface: ItemDAO
      Count number of items from the specified submitter based on specific status flags
      Specified by:
      countItems in interface ItemDAO
      Parameters:
      context - context
      submitter - the submitter
      includeArchived - whether to include archived items in count
      includeWithdrawn - whether to include withdrawn items in count
      Returns:
      count of items
      Throws:
      SQLException - if database error