mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-15 22:13:08 +00:00
Level up counting items methods - both now use the same flags from Item model (discoverable, archived, withdrawn)
This commit is contained in:
@@ -105,7 +105,8 @@ public class ItemCountDAOSolr implements ItemCountDAO {
|
||||
DiscoveryConfigurationParameters.SORT.COUNT));
|
||||
query.addFilterQueries("search.resourcetype:" + IndexableItem.TYPE); // count only items
|
||||
query.addFilterQueries("NOT(discoverable:false)"); // only discoverable
|
||||
query.addFilterQueries("withdrawn:false"); // only discoverable
|
||||
query.addFilterQueries("withdrawn:false"); // only not withdrawn
|
||||
query.addFilterQueries("archived:true"); // only archived
|
||||
query.setMaxResults(0);
|
||||
|
||||
DiscoverResult sResponse;
|
||||
|
@@ -1631,13 +1631,13 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, Collection collection) throws SQLException {
|
||||
return itemDAO.countItems(context, collection, true, false);
|
||||
return itemDAO.countItems(context, collection, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countAllItems(Context context, Collection collection) throws SQLException {
|
||||
return itemDAO.countItems(context, collection, true, false) + itemDAO.countItems(context, collection,
|
||||
false, true);
|
||||
return itemDAO.countItems(context, collection, true, false, true) + itemDAO.countItems(context, collection,
|
||||
false, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1646,7 +1646,7 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
List<Collection> collections = communityService.getAllCollections(context, community);
|
||||
|
||||
// Now, lets count unique items across that list of collections
|
||||
return itemDAO.countItems(context, collections, true, false);
|
||||
return itemDAO.countItems(context, collections, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1655,8 +1655,8 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
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);
|
||||
return itemDAO.countItems(context, collections, true, false, true) + itemDAO.countItems(context, collections,
|
||||
false, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1699,19 +1699,19 @@ prevent the generation of resource policy entry values with null dspace_object a
|
||||
@Override
|
||||
public int countNotArchivedItems(Context context) throws SQLException {
|
||||
// return count of items not in archive and also not withdrawn
|
||||
return itemDAO.countItems(context, false, false);
|
||||
return itemDAO.countItems(context, false, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countArchivedItems(Context context) throws SQLException {
|
||||
// return count of items in archive and also not withdrawn
|
||||
return itemDAO.countItems(context, true, false);
|
||||
return itemDAO.countItems(context, true, false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countWithdrawnItems(Context context) throws SQLException {
|
||||
// return count of items that are not in archive and withdrawn
|
||||
return itemDAO.countItems(context, false, true);
|
||||
return itemDAO.countItems(context, false, true, true );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -145,7 +145,7 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
|
||||
* @return item count
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn)
|
||||
int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
|
||||
throws SQLException;
|
||||
|
||||
/**
|
||||
@@ -162,7 +162,7 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countItems(Context context, List<Collection> collections, boolean includeArchived,
|
||||
boolean includeWithdrawn) throws SQLException;
|
||||
boolean includeWithdrawn, boolean discoverable) throws SQLException;
|
||||
|
||||
/**
|
||||
* Get all Items installed or withdrawn, discoverable, and modified since a Date.
|
||||
@@ -197,7 +197,7 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
|
||||
* @return count of items
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countItems(Context context, boolean includeArchived, boolean includeWithdrawn) throws SQLException;
|
||||
int countItems(Context context, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException;
|
||||
|
||||
/**
|
||||
* Count number of items from the specified submitter based on specific status flags
|
||||
@@ -209,7 +209,7 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
|
||||
* @return count of items
|
||||
* @throws SQLException if database error
|
||||
*/
|
||||
int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
|
||||
int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
|
||||
throws SQLException;
|
||||
|
||||
}
|
||||
|
@@ -401,7 +401,7 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn)
|
||||
public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
|
||||
throws SQLException {
|
||||
// Build query to select all Items have this "collection" in their list of collections
|
||||
// AND also have the inArchive or isWithdrawn set as specified
|
||||
@@ -412,6 +412,7 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
criteriaQuery.where(criteriaBuilder.and(
|
||||
criteriaBuilder.equal(itemRoot.get(Item_.inArchive), includeArchived),
|
||||
criteriaBuilder.equal(itemRoot.get(Item_.withdrawn), includeWithdrawn),
|
||||
criteriaBuilder.equal(itemRoot.get(Item_.discoverable), discoverable),
|
||||
criteriaBuilder.isMember(collection, itemRoot.get(Item_.collections))));
|
||||
// Execute and return count
|
||||
return count(context, criteriaQuery, criteriaBuilder, itemRoot);
|
||||
@@ -419,16 +420,17 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, List<Collection> collections, boolean includeArchived,
|
||||
boolean includeWithdrawn) throws SQLException {
|
||||
boolean includeWithdrawn, boolean discoverable) throws SQLException {
|
||||
if (collections.size() == 0) {
|
||||
return 0;
|
||||
}
|
||||
Query query = createQuery(context, "select count(distinct i) from Item i " +
|
||||
"join i.collections collection " +
|
||||
"WHERE collection IN (:collections) AND i.inArchive=:in_archive AND i.withdrawn=:withdrawn");
|
||||
"WHERE collection IN (:collections) AND i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND discoverable=:discoverable");
|
||||
query.setParameter("collections", collections);
|
||||
query.setParameter("in_archive", includeArchived);
|
||||
query.setParameter("withdrawn", includeWithdrawn);
|
||||
query.setParameter("discoverable", discoverable);
|
||||
|
||||
return count(query);
|
||||
}
|
||||
@@ -450,24 +452,26 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, boolean includeArchived, boolean includeWithdrawn) throws SQLException {
|
||||
public int countItems(Context context, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"SELECT count(*) FROM Item i " +
|
||||
"WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn");
|
||||
"WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND discoverable=:discoverable");
|
||||
query.setParameter("in_archive", includeArchived);
|
||||
query.setParameter("withdrawn", includeWithdrawn);
|
||||
query.setParameter("discoverable", discoverable);
|
||||
return count(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn)
|
||||
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
|
||||
throws SQLException {
|
||||
Query query = createQuery(context,
|
||||
"SELECT count(*) FROM Item i join i.submitter submitter " +
|
||||
"WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND submitter = :submitter");
|
||||
"WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND submitter = :submitter AND discoverable=:discoverable");
|
||||
query.setParameter("submitter", submitter);
|
||||
query.setParameter("in_archive", includeArchived);
|
||||
query.setParameter("withdrawn", includeWithdrawn);
|
||||
query.setParameter("discoverable", discoverable);
|
||||
return count(query);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user