Skip to content

Commit

Permalink
DURACOM-225 fix lazy initialization traversing comms/colls
Browse files Browse the repository at this point in the history
  • Loading branch information
abollini committed Jan 20, 2024
1 parent 729e389 commit 29fa737
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public Options getOptions() {
options.addOption("v", "verbose", false, "print all extracted text and other details to STDOUT");
options.addOption("q", "quiet", false, "do not print anything except in the event of errors.");
options.addOption("f", "force", false, "force all bitstreams to be processed");
options.addOption("i", "identifier", true, "ONLY process bitstreams belonging to identifier");
options.addOption("i", "identifier", true,
"ONLY process bitstreams belonging to the provided handle identifier");
options.addOption("m", "maximum", true, "process no more than maximum items");
options.addOption("h", "help", false, "help");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ 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();
for (Community subcommunity : subcommunities) {
applyFiltersCommunity(context, subcommunity);
}

// 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);
Expand All @@ -148,6 +154,9 @@ public void applyFiltersCommunity(Context context, Community community)
@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

0 comments on commit 29fa737

Please sign in to comment.