Merge remote-tracking branch 'origin/refactor_item_counter' into refactor_item_counter

This commit is contained in:
damian
2024-05-24 16:11:05 +02:00
2 changed files with 16 additions and 8 deletions

View File

@@ -145,7 +145,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return item count
* @throws SQLException if database error
*/
int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn,
boolean discoverable)
throws SQLException;
/**
@@ -197,7 +198,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return count of items
* @throws SQLException if database error
*/
int countItems(Context context, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) 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 +211,8 @@ 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, boolean discoverable)
int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn,
boolean discoverable)
throws SQLException;
}

View File

@@ -401,7 +401,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
}
@Override
public int countItems(Context context, Collection collection, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
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
@@ -426,7 +427,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
}
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 AND discoverable=:discoverable");
"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);
@@ -452,7 +454,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
}
@Override
public int countItems(Context context, boolean includeArchived, boolean includeWithdrawn, boolean discoverable) 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 AND discoverable=:discoverable");
@@ -463,11 +466,13 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
}
@Override
public int countItems(Context context, EPerson submitter, boolean includeArchived, boolean includeWithdrawn, boolean discoverable)
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 AND discoverable=:discoverable");
"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);