Search in sources :

Example 11 with Node

use of org.apache.airavata.workflow.model.graph.Node 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)

Example 12 with Node

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

the class GraphUtil method getNextNodes.

/**
 * Returns next nodes connected to a specified node.
 *
 * @param node
 *            The specified node.
 * @return The next nodes.
 */
public static List<Node> getNextNodes(Node node) {
    List<Node> nextNodes = getOutputNodes(node);
    for (Port port : node.getControlOutPorts()) {
        Collection<Node> toNodes = port.getToNodes();
        nextNodes.addAll(toNodes);
    }
    return nextNodes;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) DataPort(org.apache.airavata.workflow.model.graph.DataPort) ControlPort(org.apache.airavata.workflow.model.graph.ControlPort) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) EPRPort(org.apache.airavata.workflow.model.graph.EPRPort)

Example 13 with Node

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

the class GraphUtil method partitionGraphOnLabel.

/**
 * @param wsGraph
 * @return
 */
public static HashMap<String, LinkedList<Node>> partitionGraphOnLabel(WSGraph wsGraph) {
    HashMap<String, LinkedList<Node>> returnMap = new HashMap<String, LinkedList<Node>>();
    List<NodeImpl> nodes = wsGraph.getNodes();
    for (NodeImpl node : nodes) {
        if (!isInputOutputNode(node)) {
            LinkedList<Node> list = returnMap.get(node.getLabel());
            if (null == list) {
                list = new LinkedList<Node>();
                returnMap.put(node.getLabel(), list);
            }
            list.add(node);
        }
    }
    return returnMap;
}
Also used : NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) HashMap(java.util.HashMap) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) LinkedList(java.util.LinkedList)

Example 14 with Node

use of org.apache.airavata.workflow.model.graph.Node 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)

Example 15 with Node

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

the class GraphCanvas method deselectNode.

/**
 * Deselects a node that is currently selected if any.
 */
private void deselectNode() {
    if (this.selectedNode != null) {
        NodeController.getGUI(this.selectedNode).setSelectedFlag(false);
        NodeController.getGUI(this.selectedNode).setDraggedFlag(false);
        setSelectedNode(null);
    }
    if (this.multipleSelectedNodes != null) {
        for (Node node : this.multipleSelectedNodes) {
            NodeController.getGUI(node).setSelectedFlag(false);
            NodeController.getGUI(node).setDraggedFlag(false);
        }
        this.multipleSelectedNodes = null;
    }
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) StreamSourceNode(org.apache.airavata.workflow.model.graph.system.StreamSourceNode)

Aggregations

Node (org.apache.airavata.workflow.model.graph.Node)74 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)46 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)40 DataPort (org.apache.airavata.workflow.model.graph.DataPort)31 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)24 Port (org.apache.airavata.workflow.model.graph.Port)20 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)20 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)18 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)16 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)16 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)15 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)14 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)14 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)13 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)12 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)12 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)12 GraphException (org.apache.airavata.workflow.model.graph.GraphException)11 LinkedList (java.util.LinkedList)9 ArrayList (java.util.ArrayList)8