private void saveNodeOutputs(Node node,
Map<Node, Invoker> invokerMap, String workflowName)
throws WorkflowException {
if (null != node && !(node instanceof InputNode)) {
XmlElement elem = XmlConstants.BUILDER.newFragment("previousdat");
XmlElement inputs = null;
if (node instanceof WSNode) {
String nodeID = node.getComponent().getName();
XmlElement nodeElement = elem.newElement("wsnode");
elem.addChild(nodeElement);
nodeElement.addChild(nodeID);
inputs = elem.newElement("inputs");
elem.addChild(inputs);
List<DataPort> portsToBeSaved = node.getInputPorts();
for (DataPort savePort : portsToBeSaved) {
String portID = savePort.getName();
XmlElement portElem = inputs.newElement(portID);
inputs.addChild(portElem);
Object portInput = XBayaUtil.findInputFromPort(
savePort, invokerMap);
if (portInput instanceof org.xmlpull.v1.builder.XmlElement) {
portInput = XMLUtil
.xmlElement3ToXmlElement5((org.xmlpull.v1.builder.XmlElement) portInput);
}
portElem.addChild(portInput);
}
} else if (node instanceof EndForEachNode) {
// here we save the inputs for the entire foreach block
Node middleNode = node.getInputPort(0).getFromNode();
String nodeID = middleNode.getComponent().getName();
XmlElement nodeElement = elem.newElement("foreach");
elem.addChild(nodeElement);
nodeElement.addChild(nodeID);
inputs = elem.newElement("inputs");
elem.addChild(inputs);
XmlConstants.BUILDER.serializeToString(elem);
if (middleNode instanceof ForEachExecutableNode) {
List<DataPort> portsToBeSaved = middleNode.getInputPorts();
for (DataPort savePort : portsToBeSaved) {
// we will save all the inputs
// these are static inputs and
// input to the foreach node
if (savePort.getFromNode() instanceof ForEachNode) {
// this is the foreach node rest are simple
// inputs
Object value = XBayaUtil
.getInputsForForEachNode(
(ForEachNode) savePort
.getFromNode(),
new LinkedList<String>(),
invokerMap);
if (value instanceof org.xmlpull.v1.builder.XmlElement) {
value = XMLUtil
.xmlElement3ToXmlElement5((org.xmlpull.v1.builder.XmlElement) value);
}
XmlElement portElement = inputs.newElement(savePort
.getName());
inputs.addChild(portElement);
portElement.addChild(value);
} else {
String portID = savePort.getName();
XmlElement portElem = inputs.newElement(portID);
inputs.addChild(portElem);
Object portInput = XBayaUtil
.findInputFromPort(savePort, invokerMap);
if (portInput instanceof org.xmlpull.v1.builder.XmlElement) {
portInput = XMLUtil
.xmlElement3ToXmlElement5((org.xmlpull.v1.builder.XmlElement) portInput);
}
portElem.addChild(portInput);
}
}
} else {
// error but we will let it pass because it will be
// caught at higher level
}
}
if (inputs!=null) {
try {
this.airavataAPI.getProvenanceManager().setWorkflowInstanceNodeInput(new WorkflowInstanceNode(new WorkflowExecution(experimentId, experimentId), node.getID()), xsul5.XmlConstants.BUILDER.serializeToString(inputs));
} catch (AiravataAPIInvocationException e) {
throw new WorkflowException(e);
}
// deal with the outputs
}
XmlElement outputs = elem.newElement("outputs");
elem.addChild(outputs);
List<DataPort> outputPorts = node.getOutputPorts();
for (DataPort outputPort : outputPorts) {
String outputName = outputPort.getName();
XmlElement outputParamElement = outputs.newElement(outputName);
outputs.addChild(outputParamElement);
Object ouputParamValue = invokerMap.get(node).getOutput(
outputName);
if (ouputParamValue instanceof org.xmlpull.v1.builder.XmlElement) {
ouputParamValue = XMLUtil
.xmlElement3ToXmlElement5((org.xmlpull.v1.builder.XmlElement) ouputParamValue);
}
if (ouputParamValue != null) {
outputParamElement.addChild(ouputParamValue);
} else {
outputParamElement.addChild("null");
}
}
try {
this.airavataAPI.getProvenanceManager().setWorkflowInstanceNodeOutput(new WorkflowInstanceNode(new WorkflowExecution(experimentId,experimentId),node.getID()),xsul5.XmlConstants.BUILDER.serializeToString(outputs));
} catch (AiravataAPIInvocationException e) {