Skip to content

Commit

Permalink
Update also rights label
Browse files Browse the repository at this point in the history
In theory this could be ommited if we ensure curation tasks are run
  • Loading branch information
kosarko committed Dec 9, 2020
1 parent ae92323 commit d5ede84
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,26 @@ protected void replaceItems(Context c, Collection[] mycollections, String source
c.commit();
c.clearCache();

// attach license, license label requires an update
functionalities.openSession();
for(Item i : processedItems){
final String licenseURI = i.getMetadata("dc.rights.uri");
if(licenseURI != null) {
final int licenseId = functionalities.getLicenseByDefinition(licenseURI).getLicenseId();
final LicenseDefinition license = functionalities.getLicenseByDefinition(licenseURI);
final int licenseId = license.getLicenseId();
for(Bundle bundle : i.getBundles("ORIGINAL")){
for(Bitstream b : bundle.getBitstreams()){
functionalities.detachLicenses(b.getID());
functionalities.attachLicense(licenseId, b.getID());
}
}
i.clearMetadata("dc", "rights", "label", Item.ANY);
i.addMetadata("dc", "rights", "label", Item.ANY, license.getLicenseLabel().getLabel());
i.update();
}
}
c.commit();
c.clearCache();
functionalities.closeSession();
}
}

0 comments on commit d5ede84

Please sign in to comment.