use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.
the class ForEachComponent method createNode.
/**
* @see org.apache.airavata.workflow.model.component.Component#createNode(org.apache.airavata.workflow.model.graph.Graph)
*/
@Override
public Node createNode(Graph graph) {
ForEachNode node = new ForEachNode(graph);
node.setName(NAME);
node.setComponent(this);
// Creates a unique ID for the node. This has to be after setName().
node.createID();
createPorts(node);
return node;
}
use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.
the class InterpreterUtil method getNumberOfInputsForForEachNode.
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 = StringUtil.getElementsFromString(returnValForProvenance.toString());
inputNumbers[inputPorts.indexOf(forEachInputPort)] = vals.length;
}
}
return inputNumbers;
}
use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.
the class XBayaUtil method findEndForEachFor.
/**
* @param node
* @return
*/
public static Node findEndForEachFor(ForEachNode node) {
Collection<Node> toNodes = node.getOutputPort(0).getToNodes();
if (toNodes.size() != 1) {
throw new WorkflowRuntimeException("ForEach output does not contain single out-edge");
}
Node middleNode = toNodes.iterator().next();
List<DataPort> outputPorts = middleNode.getOutputPorts();
for (DataPort dataPort : outputPorts) {
if (dataPort.getToNodes().size() == 1) {
Node possibleEndForEachNode = dataPort.getToNodes().get(0);
if (possibleEndForEachNode instanceof EndForEachNode) {
return possibleEndForEachNode;
}
}
}
throw new WorkflowRuntimeException("EndForEachNode not found");
}
use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.
the class WSPort method copyType.
/**
* @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
*/
@Override
public void copyType(DataPort port) throws GraphException {
DataType newType = port.getType();
DataType type = getType();
NodeImpl node = port.getNode();
if (node instanceof ForEachNode || node instanceof EndForEachNode) {
// from WSDL.
return;
}
if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
String message = "The type (" + newType + ") must be same as the type " + " (" + type + ") of " + getID() + ".";
throw new GraphException(message);
}
}
use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.
the class XBayaUtil method getInputsForForEachNode.
public static Object getInputsForForEachNode(final ForEachNode forEachNode, final LinkedList<String> listOfValues, Map<Node, Invoker> invokerMap) throws WorkflowException {
Node forEachInputNode = forEachNode.getInputPort(0).getFromNode();
// if input node for for-each is WSNode
Object returnValForProvenance = null;
if (forEachInputNode instanceof InputNode) {
for (DataPort dataPort : forEachNode.getInputPorts()) {
returnValForProvenance = XBayaUtil.findInputFromPort(dataPort, invokerMap);
if (null == returnValForProvenance) {
throw new WorkFlowInterpreterException("Unable to find input for the node:" + forEachNode.getID());
}
String[] vals = StringUtil.getElementsFromString(returnValForProvenance.toString());
listOfValues.addAll(Arrays.asList(vals));
}
}
return returnValForProvenance;
}
Aggregations