Search in sources :

Example 11 with ForEachNode

use of org.apache.airavata.workflow.model.graph.system.ForEachNode in project airavata by apache.

the class InterpreterUtil 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");
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Aggregations

ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)11 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)10 Node (org.apache.airavata.workflow.model.graph.Node)8 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)8 DataPort (org.apache.airavata.workflow.model.graph.DataPort)6 WorkFlowInterpreterException (org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)3 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)3 BlockNode (org.apache.airavata.workflow.model.graph.system.BlockNode)3 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)3 EndBlockNode (org.apache.airavata.workflow.model.graph.system.EndBlockNode)3 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)3 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)3 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)3 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)3 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)2 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)2 ArrayList (java.util.ArrayList)1 DataType (org.apache.airavata.model.application.io.DataType)1 ComponentPort (org.apache.airavata.workflow.model.component.ComponentPort)1 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)1