Merge pull request #9128 from DSpace/backport-9110-to-dspace-7_x

[Port dspace-7_x] #8585 Add submitter information to provenance metadata
This commit is contained in:
Alan Orth
2023-10-17 12:52:11 +03:00
committed by GitHub
5 changed files with 58 additions and 8 deletions

View File

@@ -578,6 +578,10 @@ public class MetadataImport extends DSpaceRunnable<MetadataImportScriptConfigura
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);
}

View File

@@ -774,6 +774,10 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
// 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);

View File

@@ -271,4 +271,28 @@ public class InstallItemServiceImpl implements InstallItemService {
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();
}
}

View File

@@ -83,4 +83,15 @@ public interface InstallItemService {
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;;
}

View File

@@ -221,6 +221,8 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
//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);
@@ -1187,25 +1189,30 @@ public class XmlWorkflowServiceImpl implements XmlWorkflowService {
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);
}