Skip to content

Commit

Permalink
Merge branch 'dspace-cris-2023_02_x' into DSC-963
Browse files Browse the repository at this point in the history
# Conflicts:
#	dspace-api/src/test/java/org/dspace/orcid/service/OrcidProfileSectionFactoryServiceIT.java
  • Loading branch information
atarix83 committed Jan 30, 2024
2 parents 1f1f6f4 + f295c43 commit fa6e74f
Show file tree
Hide file tree
Showing 31 changed files with 1,483 additions and 946 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 @@ -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 fa6e74f

Please sign in to comment.