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
committed by Tim Donohue
parent a5901af564
commit ab0b80e57a
2 changed files with 16 additions and 8 deletions

View File

@@ -128,7 +128,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return item count * @return item count
* @throws SQLException if database error * @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; throws SQLException;
/** /**
@@ -180,7 +181,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return count of items * @return count of items
* @throws SQLException if database error * @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 * Count number of items from the specified submitter based on specific status flags
@@ -192,7 +194,8 @@ public interface ItemDAO extends DSpaceObjectLegacySupportDAO<Item> {
* @return count of items * @return count of items
* @throws SQLException if database error * @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; throws SQLException;
} }

View File

@@ -374,7 +374,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
} }
@Override @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 { throws SQLException {
Query query = createQuery(context, Query query = createQuery(context,
"select count(i) from Item i join i.collections c " + "select count(i) from Item i join i.collections c " +
@@ -396,7 +397,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
} }
Query query = createQuery(context, "select count(distinct i) from Item i " + Query query = createQuery(context, "select count(distinct i) from Item i " +
"join i.collections collection " + "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("collections", collections);
query.setParameter("in_archive", includeArchived); query.setParameter("in_archive", includeArchived);
query.setParameter("withdrawn", includeWithdrawn); query.setParameter("withdrawn", includeWithdrawn);
@@ -420,7 +422,8 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
} }
@Override @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, Query query = createQuery(context,
"SELECT count(*) FROM Item i " + "SELECT count(*) FROM Item i " +
"WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND discoverable=:discoverable"); "WHERE i.inArchive=:in_archive AND i.withdrawn=:withdrawn AND discoverable=:discoverable");
@@ -431,11 +434,13 @@ public class ItemDAOImpl extends AbstractHibernateDSODAO<Item> implements ItemDA
} }
@Override @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 { throws SQLException {
Query query = createQuery(context, Query query = createQuery(context,
"SELECT count(*) FROM Item i join i.submitter submitter " + "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("submitter", submitter);
query.setParameter("in_archive", includeArchived); query.setParameter("in_archive", includeArchived);
query.setParameter("withdrawn", includeWithdrawn); query.setParameter("withdrawn", includeWithdrawn);