Skip to content

Commit

Permalink
Merge branch 'dspace-cris-2023_02_x' into main-cris
Browse files Browse the repository at this point in the history
  • Loading branch information
abollini committed Jan 19, 2024
2 parents 99c0144 + 733343c commit a399ac0
Show file tree
Hide file tree
Showing 10 changed files with 148 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.SelfNamedPlugin;
import org.dspace.core.UUIDIterator;
import org.dspace.eperson.Group;
import org.dspace.eperson.service.GroupService;
import org.dspace.scripts.handler.DSpaceRunnableHandler;
Expand Down Expand Up @@ -135,17 +134,13 @@ public void applyFiltersCommunity(Context context, Community community)
throws Exception { //only apply filters if community not in skip-list
if (!inSkipList(community.getHandle())) {
List<Community> subcommunities = community.getSubcommunities();
List<Collection> collections = community.getCollections();

UUIDIterator<Community> communityIterator = new UUIDIterator<>(context, subcommunities, Community.class);
UUIDIterator<Collection> collectionIterator = new UUIDIterator<>(context, collections, Collection.class);

while (communityIterator.hasNext()) {
applyFiltersCommunity(context, communityIterator.next());
for (Community subcommunity : subcommunities) {
applyFiltersCommunity(context, subcommunity);
}

while (collectionIterator.hasNext()) {
applyFiltersCollection(context, collectionIterator.next());
List<Collection> collections = community.getCollections();
for (Collection collection : collections) {
applyFiltersCollection(context, collection);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public RequestItem findByToken(Context context, String token) throws SQLExceptio
public Iterator<RequestItem> findByItem(Context context, Item item) throws SQLException {
Query query = createQuery(context, "FROM RequestItem WHERE item_id= :uuid");
query.setParameter("uuid", item.getID());
return iterate(context, query, RequestItem.class);
return iterate(query);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1844,7 +1844,7 @@ public boolean isItemListedForUser(Context context, Item item) {
@Override
public Iterator<Item> findByIds(Context context, List<String> ids) throws SQLException {
return itemDAO.findByIds(context,
ids.stream().map(uuid -> UUID.fromString(uuid)).collect(Collectors.toList()));
ids.stream().map(uuid -> UUID.fromString(uuid)).distinct().collect(Collectors.toList()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.dspace.core.AbstractHibernateDSODAO;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.core.UUIDIterator;

/**
* Hibernate implementation of the Database Access Object interface class for the Bitstream object.
Expand Down Expand Up @@ -77,48 +78,51 @@ public List<Bitstream> findBitstreamsWithNoRecentChecksum(Context context) throw

@Override
public Iterator<Bitstream> findByCommunity(Context context, Community community) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
Query query = createQuery(context, "select b.id from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.items item " +
"join item.collections itemColl " +
"join itemColl.communities community " +
"WHERE :community IN community");

query.setParameter("community", community);

return iterate(context, query, Bitstream.class);
@SuppressWarnings("unchecked")
List<UUID> uuids = query.getResultList();
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
}

@Override
public Iterator<Bitstream> findByCollection(Context context, Collection collection) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
Query query = createQuery(context, "select b.id from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.items item " +
"join item.collections c " +
"WHERE :collection IN c");

query.setParameter("collection", collection);

return iterate(context, query, Bitstream.class);
@SuppressWarnings("unchecked")
List<UUID> uuids = query.getResultList();
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
}

@Override
public Iterator<Bitstream> findByItem(Context context, Item item) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b " +
Query query = createQuery(context, "select b.id from Bitstream b " +
"join b.bundles bitBundles " +
"join bitBundles.items item " +
"WHERE :item IN item");

query.setParameter("item", item);

return iterate(context, query, Bitstream.class);
@SuppressWarnings("unchecked")
List<UUID> uuids = query.getResultList();
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
}

@Override
public Iterator<Bitstream> findShowableByItem(Context context, UUID itemId, String bundleName) throws SQLException {
Query query = createQuery(
context,
"select b from Bitstream b " +
"select b.id from Bitstream b " +
"join b.bundles bitBundle " +
"join bitBundle.items item " +
"WHERE item.id = :itemId " +
Expand Down Expand Up @@ -150,15 +154,18 @@ public Iterator<Bitstream> findShowableByItem(Context context, UUID itemId, Stri

query.setParameter("itemId", itemId);
query.setParameter("bundleName", bundleName);

return iterate(context, query, Bitstream.class);
@SuppressWarnings("unchecked")
List<UUID> uuids = query.getResultList();
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
}

@Override
public Iterator<Bitstream> findByStoreNumber(Context context, Integer storeNumber) throws SQLException {
Query query = createQuery(context, "select b from Bitstream b where b.storeNumber = :storeNumber");
Query query = createQuery(context, "select b.id from Bitstream b where b.storeNumber = :storeNumber");
query.setParameter("storeNumber", storeNumber);
return iterate(context, query, Bitstream.class);
@SuppressWarnings("unchecked")
List<UUID> uuids = query.getResultList();
return new UUIDIterator<Bitstream>(context, uuids, Bitstream.class, this);
}

@Override
Expand Down
Loading

0 comments on commit a399ac0

Please sign in to comment.