Add itemService.countItems(Context, Community)

A convenience method to get community item count
This commit is contained in:
Peter Dietz
2015-08-20 18:14:45 -04:00
parent db38e9a305
commit d0e628178e
2 changed files with 18 additions and 1 deletions

View File

@@ -1109,6 +1109,16 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
return itemDAO.countItems(context, collection, true, false); return itemDAO.countItems(context, collection, true, false);
} }
@Override
public int countItems(Context context, Community community) throws SQLException {
List<Collection> collections = communityService.getAllCollections(context, community);
int itemCount = 0;
for(Collection collection : collections) {
itemCount += countItems(context, collection);
}
return itemCount;
}
@Override @Override
protected void getAuthoritiesAndConfidences(String fieldKey, Collection collection, List<String> values, List<String> authorities, List<Integer> confidences, int i) { protected void getAuthoritiesAndConfidences(String fieldKey, Collection collection, List<String> values, List<String> authorities, List<Integer> confidences, int i) {
Choices c = choiceAuthorityService.getBestMatch(fieldKey, values.get(i), collection, null); Choices c = choiceAuthorityService.getBestMatch(fieldKey, values.get(i), collection, null);

View File

@@ -449,4 +449,11 @@ public interface ItemService extends DSpaceObjectService<Item>, DSpaceObjectLega
*/ */
public Iterator<Item> findByLastModifiedSince(Context context, Date last) public Iterator<Item> findByLastModifiedSince(Context context, Date last)
throws SQLException; throws SQLException;
/**
* counts items in the given community
*
* @return total items
*/
public int countItems(Context context, Community community) throws SQLException;
} }