Skip to content

Commit

Permalink
8585 - added provenance to metadata-import and itemImport
Browse files Browse the repository at this point in the history
  • Loading branch information
aroman-arvo committed Oct 16, 2023
1 parent c15ac0e commit ea6307d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,10 @@ public List<BulkEditChange> runImport(Context c, boolean change,
wfItem = workflowService.startWithoutNotify(c, wsItem);
}
} else {
// Add provenance info
String provenance = installItemService.getSubmittedByProvenanceMessage(c, wsItem.getItem());
itemService.addMetadata(c, item, MetadataSchemaEnum.DC.getName(),
"description", "provenance", "en", provenance);
// Install the item
installItemService.installItem(c, wsItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,10 @@ protected Item addItem(Context c, List<Collection> mycollections, String path,
// put item in system
if (!isTest) {
try {
// Add provenance info
String provenance = installItemService.getSubmittedByProvenanceMessage(c, wi.getItem());
itemService.addMetadata(c, wi.getItem(), MetadataSchemaEnum.DC.getName(),
"description", "provenance", "en", provenance);
installItemService.installItem(c, wi, myhandle);
} catch (Exception e) {
workspaceItemService.deleteAll(c, wi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,28 @@ public String getBitstreamProvenanceMessage(Context context, Item myitem)

return myMessage.toString();
}

@Override
public String getSubmittedByProvenanceMessage(Context context, Item item) throws SQLException {
// get date
DCDate now = DCDate.getCurrent();

// Create provenance description
StringBuffer provmessage = new StringBuffer();

if (item.getSubmitter() != null) {
provmessage.append("Submitted by ").append(item.getSubmitter().getFullName())
.append(" (").append(item.getSubmitter().getEmail()).append(") on ")
.append(now.toString());
} else {
// else, null submitter
provmessage.append("Submitted by unknown (probably automated) on")
.append(now.toString());
}
provmessage.append("\n");

// add sizes and checksums of bitstreams
provmessage.append(getBitstreamProvenanceMessage(context, item));
return provmessage.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,15 @@ public Item restoreItem(Context c, InProgressSubmission is,
public String getBitstreamProvenanceMessage(Context context, Item myitem)
throws SQLException;

/**
* Generate provenance description of direct item submission (not through workflow).
*
* @param context context
* @param item the item to generate description for
* @return provenance description
* @throws SQLException if database error
*/
public String getSubmittedByProvenanceMessage(Context context, Item item)
throws SQLException;;

}

0 comments on commit ea6307d

Please sign in to comment.