Search in sources :

Example 1 with ForEachNode

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;
}
Also used : ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode)

Example 2 with ForEachNode

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;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) 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) WorkFlowInterpreterException(org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)

Example 3 with ForEachNode

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");
}
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)

Example 4 with ForEachNode

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);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataType(org.apache.airavata.model.application.io.DataType) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 5 with ForEachNode

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;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) 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) WorkFlowInterpreterException(org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)

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