Merge pull request #1988 from Georgetown-University-Libraries/ds3714m

[DS-3714] port pr 1862 to master
This commit is contained in:
Tim Donohue
2018-03-16 15:24:55 -05:00
committed by GitHub
5 changed files with 79 additions and 5 deletions

View File

@@ -244,6 +244,12 @@ 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 {
@@ -1161,6 +1167,12 @@ prevent the generation of resource policy entry values with null dspace_object a
return itemDAO.countItems(context, collection, true, false);
}
@Override
public int countAllItems(Context context, Collection collection) throws SQLException {
return itemDAO.countItems(context, collection, true, false) + itemDAO.countItems(context, collection,
false, true);
}
@Override
public int countItems(Context context, Community community) throws SQLException {
// First we need a list of all collections under this community in the hierarchy
@@ -1170,6 +1182,16 @@ prevent the generation of resource policy entry values with null dspace_object a
return itemDAO.countItems(context, collections, true, false);
}
@Override
public int countAllItems(Context context, Community community) throws SQLException {
// First we need a list of all collections under this community in the hierarchy
List<Collection> collections = communityService.getAllCollections(context, community);
// Now, lets count unique items across that list of collections
return itemDAO.countItems(context, collections, true, false) + itemDAO.countItems(context, collections,
false, true);
}
@Override
protected void getAuthoritiesAndConfidences(String fieldKey, Collection collection, List<String> values,
List<String> authorities, List<Integer> confidences, int i) {

View File

@@ -64,6 +64,9 @@ 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
*

View File

@@ -247,6 +247,22 @@ 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 {

View File

@@ -123,7 +123,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
throws SQLException;
/**
* Get all the items in this collection. The order is indeterminate.
* Get all the archived items in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
@@ -133,7 +133,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
public Iterator<Item> findByCollection(Context context, Collection collection) throws SQLException;
/**
* Get all the items in this collection. The order is indeterminate.
* Get all the archived items in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
@@ -145,6 +145,19 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
public Iterator<Item> findByCollection(Context context, Collection collection, Integer limit, Integer offset)
throws SQLException;
/**
* Get all the items (including private and withdrawn) 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;
/**
* Get all Items installed or withdrawn, discoverable, and modified since a Date.
*
@@ -157,7 +170,7 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
throws SQLException;
/**
* Get all the items in this collection. The order is indeterminate.
* Get all the items (including private and withdrawn) in this collection. The order is indeterminate.
*
* @param context DSpace context object
* @param collection Collection (parent)
@@ -539,6 +552,16 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
*/
public int countItems(Context context, Collection collection) throws SQLException;
/**
* counts all items in the given collection including withdrawn items
*
* @param context DSpace context object
* @param collection Collection
* @return total items
* @throws SQLException if database error
*/
public int countAllItems(Context context, Collection collection) throws SQLException;
/**
* Find all Items modified since a Date.
*
@@ -560,6 +583,16 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
*/
public int countItems(Context context, Community community) throws SQLException;
/**
* counts all items in the given community including withdrawn
*
* @param context DSpace context object
* @param community Community
* @return total items
* @throws SQLException if database error
*/
public int countAllItems(Context context, Community community) throws SQLException;
/**
* counts all items
*

View File

@@ -120,7 +120,7 @@ public class FilteredCollection extends DSpaceObject {
this.setNumberItemsProcessed(0);
if (itemFilters.size() > 0) {
Iterator<org.dspace.content.Item> childItems = itemService
.findByCollection(context, collection, limit, offset);
.findAllByCollection(context, collection, limit, offset);
int numProc = itemFilterSet
.processSaveItems(context, servletContext, childItems, items, reportItems, expand);
this.setNumberItemsProcessed(numProc);
@@ -129,7 +129,7 @@ public class FilteredCollection extends DSpaceObject {
if (!expandFields.contains("all")) {
this.addExpand("all");
}
this.setNumberItems(itemService.countItems(context, collection));
this.setNumberItems(itemService.countAllItems(context, collection));
}
public Integer getNumberItems() {