Search in sources :

Example 6 with DataPort

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

the class WorkflowHarvester method getCandidates.

/**
 * @param workflow
 * @param dataType
 * @return pair of nodeid and portid
 */
private LinkedList<Pair<String, String>> getCandidates(Workflow workflow, QName dataType) {
    LinkedList<Pair<String, String>> candidates = new LinkedList<Pair<String, String>>();
    List<NodeImpl> nodes = workflow.getGraph().getNodes();
    for (NodeImpl node : nodes) {
        if (node instanceof WSNode) {
            List<DataPort> inputPorts = ((WSNode) node).getInputPorts();
            for (DataPort dataPort : inputPorts) {
                if (dataType.equals(dataPort.getType())) {
                    candidates.add(new Pair<String, String>(node.getID(), dataPort.getID()));
                }
            }
        }
    }
    return candidates;
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) LinkedList(java.util.LinkedList) Pair(org.apache.airavata.common.utils.Pair)

Example 7 with DataPort

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

the class ExitComponent method createPorts.

protected void createPorts(NodeImpl node) {
    for (ComponentDataPort input : getInputPorts()) {
        DataPort port = input.createPort();
        node.addInputPort(port);
    }
    for (ComponentDataPort output : getOutputPorts()) {
        DataPort port = output.createPort();
        node.addOutputPort(port);
    }
    if (this.controlInPort != null) {
        ControlPort port = this.controlInPort.createPort();
        node.setControlInPort(port);
    }
    for (ComponentControlPort componentPort : this.controlOutPorts) {
        ControlPort port = componentPort.createPort();
        node.addControlOutPort(port);
    }
    if (this.eprPort != null) {
        EPRPort port = this.eprPort.createPort();
        node.setEPRPort(port);
    }
}
Also used : SystemComponentDataPort(org.apache.airavata.workflow.model.component.system.SystemComponentDataPort) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) ComponentControlPort(org.apache.airavata.workflow.model.component.ComponentControlPort) ComponentControlPort(org.apache.airavata.workflow.model.component.ComponentControlPort) SystemComponentDataPort(org.apache.airavata.workflow.model.component.system.SystemComponentDataPort) ComponentDataPort(org.apache.airavata.workflow.model.component.ComponentDataPort)

Example 8 with DataPort

use of org.apache.airavata.workflow.model.graph.DataPort 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 9 with DataPort

use of org.apache.airavata.workflow.model.graph.DataPort 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 10 with DataPort

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

the class WorkflowHarvester method removeUnnecessaryNodes.

/**
 * @param pair
 * @param clone
 */
private void removeUnnecessaryNodes(Node node, Port candidatePort, Workflow workflow) {
    if (candidatePort.getFromPort().getEdges().size() == 1) {
        Node fromNode = candidatePort.getFromNode();
        try {
            List<DataPort> inputPorts = fromNode.getInputPorts();
            for (DataPort dataPort : inputPorts) {
                removeUnnecessaryNodes(fromNode, dataPort, workflow);
            }
            workflow.removeNode(fromNode);
        } catch (GraphException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Node(org.apache.airavata.workflow.model.graph.Node) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Aggregations

DataPort (org.apache.airavata.workflow.model.graph.DataPort)100 ComponentDataPort (org.apache.airavata.workflow.model.component.ComponentDataPort)39 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)26 Node (org.apache.airavata.workflow.model.graph.Node)26 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)20 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)16 GraphException (org.apache.airavata.workflow.model.graph.GraphException)15 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)13 DataType (org.apache.airavata.model.application.io.DataType)12 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)12 Port (org.apache.airavata.workflow.model.graph.Port)11 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)10 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)9 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)8 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)8 LinkedList (java.util.LinkedList)7 ControlPort (org.apache.airavata.workflow.model.graph.ControlPort)7 EPRPort (org.apache.airavata.workflow.model.graph.EPRPort)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)6 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)6