Skip to content

Commit

Permalink
Merge branch 'dspace-cris-2023_02_x' of https://bitbucket.org/4Scienc…
Browse files Browse the repository at this point in the history
…e/dspace-cris into DSC-1458
  • Loading branch information
abollini committed Feb 5, 2024
2 parents cdcd959 + 1677cb0 commit 6dc77b0
Show file tree
Hide file tree
Showing 67 changed files with 2,320 additions and 1,443 deletions.
2 changes: 1 addition & 1 deletion dspace-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.dspace</groupId>
<artifactId>dspace-parent</artifactId>
<version>cris-2023.02.01-SNAPSHOT</version>
<version>cris-2023.02.02-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

Expand Down
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 @@ -133,26 +132,31 @@ public void applyFiltersAllItems(Context context) throws Exception {
@Override
public void applyFiltersCommunity(Context context, Community community)
throws Exception { //only apply filters if community not in skip-list
// ensure that the community is attached to the current hibernate session
// as we are committing after each item (handles, sub-communties and
// collections are lazy attributes)
community = context.reloadEntity(community);
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());
// ensure that the community is attached to the current hibernate session
// as we are committing after each item
community = context.reloadEntity(community);
List<Collection> collections = community.getCollections();
for (Collection collection : collections) {
applyFiltersCollection(context, collection);
}
}
}

@Override
public void applyFiltersCollection(Context context, Collection collection)
throws Exception {
// ensure that the collection is attached to the current hibernate session
// as we are committing after each item (handles are lazy attributes)
collection = context.reloadEntity(collection);
//only apply filters if collection not in skip-list
if (!inSkipList(collection.getHandle())) {
Iterator<Item> itemIterator = itemService.findAllByCollection(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 6dc77b0

Please sign in to comment.