Skip to content

Commit

Permalink
Merge pull request DSpace#9110 from arvoConsultores/8585
Browse files Browse the repository at this point in the history
DSpace#8585 Add submitter information to provenance metadata
  • Loading branch information
alanorth authored Oct 17, 2023
2 parents 92844f0 + 4fba787 commit 2af0232
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 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;;

}
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public XmlWorkflowItem start(Context context, WorkspaceItem wsi)
//Get our next step, if none is found, archive our item
firstStep = wf.getNextStep(context, wfi, firstStep, ActionResult.OUTCOME_COMPLETE);
if (firstStep == null) {
// record the submitted provenance message
recordStart(context, wfi.getItem(),null);
archive(context, wfi);
} else {
activateFirstStep(context, wf, firstStep, wfi);
Expand Down Expand Up @@ -1187,25 +1189,30 @@ protected void recordStart(Context context, Item myitem, Action action)
DCDate now = DCDate.getCurrent();

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

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

// add sizes and checksums of bitstreams
provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem);
provmessage.append(installItemService.getBitstreamProvenanceMessage(context, myitem));

// Add message to the DC
itemService
.addMetadata(context, myitem, MetadataSchemaEnum.DC.getName(),
"description", "provenance", "en", provmessage);
"description", "provenance", "en", provmessage.toString());
itemService.update(context, myitem);
}

Expand Down

0 comments on commit 2af0232

Please sign in to comment.