public static Integer[] getNumberOfInputsForForEachNode(final ForEachNode forEachNode, Map<Node, Invoker> invokerMap) throws WorkflowException {
List<DataPort> inputPorts = forEachNode.getInputPorts();
Integer[] inputNumbers = new Integer[inputPorts.size()];
for (DataPort forEachInputPort : inputPorts) {
// if input node for for-each is WSNode
Node forEachInputNode = forEachInputPort.getFromNode();
int index = 0;
Object returnValForProvenance = null;
if (forEachInputNode instanceof InputNode) {
returnValForProvenance = InterpreterUtil.findInputFromPort(forEachInputPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = returnValForProvenance.toString().split(",");
inputNumbers[inputPorts.indexOf(forEachInputPort)] = vals.length;
} else {
Invoker workflowInvoker = invokerMap.get(forEachInputNode);
if (workflowInvoker != null) {
if (workflowInvoker instanceof GenericInvoker) {
returnValForProvenance = ((GenericInvoker) workflowInvoker).getOutputs();
String message = returnValForProvenance.toString();
XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString(message);
Iterator children = msgElmt.children().iterator();
while (children.hasNext()) {
Object object = children.next();
// foreachWSNode.getInputPort(0).getType()
if (object instanceof XmlElement) {
index++;
}
}
} else if (workflowInvoker instanceof WorkflowInvokerWrapperForGFacInvoker) {
String outputName = forEachInputNode.getOutputPort(0).getName();
returnValForProvenance = workflowInvoker.getOutput(outputName);
org.xmlpull.v1.builder.XmlElement msgElmt = (org.xmlpull.v1.builder.XmlElement) returnValForProvenance;
Iterator children = msgElmt.children();
while (children.hasNext()) {
Object object = children.next();
if (object instanceof org.xmlpull.v1.builder.XmlElement) {
org.xmlpull.v1.builder.XmlElement child = (org.xmlpull.v1.builder.XmlElement) object;
Iterator valItr = child.children();
if (valItr.hasNext()) {
Object object2 = valItr.next();
if (object2 instanceof String) {
index++;
}
}
}
}
inputNumbers[inputPorts.indexOf(forEachInputPort)] = index;
} else if (workflowInvoker instanceof SystemComponentInvoker) {
int portIndex = forEachInputNode.getOutputPorts().indexOf(forEachInputPort.getEdge(0).getFromPort());
String outputName = "";
if (forEachInputNode.getInputPort(portIndex) instanceof SystemDataPort) {
outputName = ((SystemDataPort) forEachInputNode.getInputPort(portIndex)).getWSComponentPort().getName();
} else if (forEachInputNode.getInputPort(portIndex) instanceof WSPort) {
outputName = ((WSPort) forEachInputNode.getInputPort(portIndex)).getComponentPort().getName();
}
returnValForProvenance = workflowInvoker.getOutput(outputName);
XmlElement msgElmt = XmlConstants.BUILDER.parseFragmentFromString("<temp>" + returnValForProvenance + "</temp>");
Iterator valItr = msgElmt.children().iterator();
while (valItr.hasNext()) {