Merge pull request #1277 from tdonohue/DS-3039

DS-3039 : Fix Community item counting logic. Also cleanup item counting elsewhere in code
This commit is contained in:
Tim Donohue
2016-02-19 14:05:20 -06:00
12 changed files with 301 additions and 235 deletions

View File

@@ -1121,12 +1121,11 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
@Override
public int countItems(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);
int itemCount = 0;
for(Collection collection : collections) {
itemCount += countItems(context, collection);
}
return itemCount;
// Now, lets count unique items across that list of collections
return itemDAO.countItems(context, collections, true, false);
}
@Override
@@ -1166,12 +1165,14 @@ public class ItemServiceImpl extends DSpaceObjectServiceImpl<Item> implements It
}
@Override
public int getNotArchivedItemsCount(Context context) throws SQLException {
return itemDAO.countNotArchived(context);
public int countNotArchivedItems(Context context) throws SQLException {
// return count of items not in archive and also not withdrawn
return itemDAO.countItems(context, false, false);
}
@Override
public int countWithdrawnItems(Context context) throws SQLException {
return itemDAO.countWithdrawn(context);
// return count of items that are in archive and withdrawn
return itemDAO.countItems(context, true, true);
}
}