mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
add pagination methods to find all
This commit is contained in:
@@ -237,6 +237,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
|
||||
return itemDAO.findAllByCollection(context, collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException {
|
||||
return itemDAO.findAllByCollection(context, collection, limit, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findInArchiveOrWithdrawnDiscoverableModifiedSince(Context context, Date since)
|
||||
throws SQLException
|
||||
|
@@ -57,6 +57,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item>
|
||||
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException;
|
||||
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException;
|
||||
|
||||
/**
|
||||
* Count number of items in a given collection
|
||||
* @param context context
|
||||
|
@@ -233,6 +233,24 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
return iterate(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException {
|
||||
Query query = createQuery(context, "select i from Item i join i.collections c WHERE :collection IN c");
|
||||
query.setParameter("collection", collection);
|
||||
|
||||
if(offset != null)
|
||||
{
|
||||
query.setFirstResult(offset);
|
||||
}
|
||||
if(limit != null)
|
||||
{
|
||||
query.setMaxResults(limit);
|
||||
}
|
||||
|
||||
return iterate(query);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn) throws SQLException {
|
||||
Query query = createQuery(context, "select count(i) from Item i join i.collections c WHERE :collection IN c AND i.inArchive=:in_archive AND i.withdrawn=:withdrawn");
|
||||
|
@@ -146,6 +146,18 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
|
||||
*/
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get all the items in this collection. The order is indeterminate.
|
||||
*
|
||||
* @param context DSpace context object
|
||||
* @param collection Collection (parent)
|
||||
* @return an iterator over the items in the collection.
|
||||
* @param limit limited number of items
|
||||
* @param offset offset value
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
public Iterator<Item> findAllByCollection(Context context, Collection collection, Integer limit, Integer offset) throws SQLException;
|
||||
|
||||
/**
|
||||
* See whether this Item is contained by a given Collection.
|
||||
* @param item Item
|
||||
|
Reference in New Issue
Block a user