in taverna-provenanceconnector/src/main/java/org/apache/taverna/provenance/opm/OPMImporter.java [475:555]
private void processWDF(WasDerivedFrom dep) {
List<AccountRef> accountIDs = dep.getAccount();
ArtifactRef fromArtId = dep.getCause();
ArtifactRef toArtId = dep.getEffect();
List<String> accNames = new ArrayList<>();
for (AccountRef accId : accountIDs)
accNames.add(((Account) accId.getRef()).getId());
accNames.add(OPM_DEF_ACCOUNT);
for (String accName:accNames) {
int varCounter = 0;
String workflowId = accountToWorkflow.get(accName);
String workflowRun = workflowToInstance.get(workflowId);
List<String> generatingProcesses = null, usingProcesses = null;
// look for any triple fromArtId wasGeneratedBy P within this account
Map<String, List<String>> wgbArtifacts = wgbArtifactsByAccount
.get(accName);
if (wgbArtifacts != null) {
String toArtifactName = ((Artifact) toArtId.getRef()).getId();
generatingProcesses = wgbArtifacts.get(toArtifactName);
if (generatingProcesses != null)
logger.debug("artifact " + toArtifactName
+ " wgby one or more processes...");
}
// look for any triple (P used toArtId) within this account
// get map for this account
Map<String, List<String>> usedArtifacts = usedArtifactsByAccount
.get(accName);
if (usedArtifacts != null) {
String fromArtifactName = ((Artifact) fromArtId.getRef())
.getId();
usingProcesses = usedArtifacts.get(fromArtifactName);
if (usingProcesses != null)
logger.debug("artifact " + fromArtifactName
+ " was used by one or more processes...");
}
if (generatingProcesses != null && usingProcesses != null)
for (String gp : generatingProcesses)
if (usingProcesses.contains(gp)) {
logger.debug("intersection between process sets not empty, this WDF is redundant");
return;
}
/* We only postulate a new process if the native one was not found */
String procName = PROC_NAME+"_"+procNameCounter++;
try {
pw.addProcessor(procName, workflowId, false);
logger.info("created non-native added processor " + procName
+ " to workflow " + workflowId);
} catch (SQLException e) { // no panic -- just catch duplicates
logger.warn(e.getMessage());
}
// create a role for fromArtId from the procName
String inputPortName = procName + "_" + varCounter++;
String inputValue = ((Artifact) fromArtId.getRef()).getId();
// add to DB
processProcessArtifactDep(procName, inputValue, inputPortName,
workflowId, workflowRun, true);
// create a role for toArtId
String outputPortName = procName + "_" + varCounter++;
String outputValue = ((Artifact) toArtId.getRef()).getId();
// add to DB
processProcessArtifactDep(procName, outputValue, outputPortName,
workflowId, workflowRun, false);
}
}