Search in sources :

Example 26 with Node

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

the class XBayaGUI method activeTabChanged.

private void activeTabChanged() {
    GraphCanvas graphPanel = getGraphCanvas();
    if (graphPanel != null) {
        // Reset the port viewers.
        Port inputPort = graphPanel.getSelectedInputPort();
        Port outputPort = graphPanel.getSelectedOutputPort();
        this.portViewer.setInputPort(inputPort);
        this.portViewer.setOutputPort(outputPort);
        // Reset component viewer.
        Node node = graphPanel.getSelectedNode();
        Component component;
        if (node != null) {
            component = node.getComponent();
        } else {
            component = this.componentSelector.getSelectedComponent();
        }
        this.componentViewer.setComponent(component);
        String name = graphPanel.getWorkflow().getName();
        setFrameName(name);
    } else {
    // TODO what to do when no tabs are present???
    }
}
Also used : Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node) Component(org.apache.airavata.workflow.model.component.Component) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 27 with Node

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

the class WorkflowModifier method removeFinishedNodes.

/**
 * @param originalGraph
 * @param graph
 * @throws GraphException
 */
private void removeFinishedNodes(WSGraph originalGraph, WSGraph graph) throws GraphException {
    ArrayList<Node> finishedNodes = new ArrayList<Node>();
    for (Node node : originalGraph.getNodes()) {
        Color color = NodeController.getGUI(node).getBodyColor();
        if (NodeState.FINISHED.color.equals(color)) {
            finishedNodes.add(node);
        }
    }
    for (Node finishedNode : finishedNodes) {
        Node node = graph.getNode(finishedNode.getID());
        graph.removeNode(node);
    }
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Node(org.apache.airavata.workflow.model.graph.Node) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) Color(java.awt.Color) ArrayList(java.util.ArrayList)

Example 28 with Node

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

the class BPELScript method getWSDLs.

/**
 * Returns the WSDLs of components in the workflow.
 *
 * @return The WSDLs of components.
 */
public Collection<XmlElement> getWSDLs() {
    Collection<XmlElement> wsdls = new ArrayList<XmlElement>();
    for (Node node : this.graph.getNodes()) {
        if (node instanceof WSNode) {
            WSNode wsNode = (WSNode) node;
            WSComponent component = wsNode.getComponent();
            wsdls.add(component.toXML());
        }
    }
    return wsdls;
}
Also used : WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ArrayList(java.util.ArrayList) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) XmlElement(org.xmlpull.infoset.XmlElement)

Example 29 with Node

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

the class BPELScript method getSpecialBlock.

/**
 * @param node
 * @param depth
 * @param block
 *            It's a set so that duplicated nodes won't be added.
 * @param startClass
 * @param endClass
 * @throws GraphException
 */
private void getSpecialBlock(Node node, int depth, Set<Node> block, Class startClass, Class endClass) throws GraphException {
    List<Node> nextNodes = GraphUtil.getNextNodes(node);
    for (Node nextNode : nextNodes) {
        if (nextNode instanceof OutputNode) {
            throw new GraphException("Nodes after " + startClass.getName() + " cannot be connected to the output without going through " + endClass.getName() + ".");
        } else if (endClass.isInstance(nextNode)) {
            block.add(nextNode);
            if (depth == 0) {
            // Stop the recursion here.
            } else {
                getSpecialBlock(nextNode, depth - 1, block, startClass, endClass);
            }
        } else if (startClass.isInstance(nextNode)) {
            // handle embedded forEach
            block.add(nextNode);
            getSpecialBlock(nextNode, depth + 1, block, startClass, endClass);
        } else {
            block.add(nextNode);
            getSpecialBlock(nextNode, depth, block, startClass, endClass);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode)

Example 30 with Node

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

the class BPELScript method isExecutable.

private <S extends Node, E extends Node> boolean isExecutable(S node, Collection<Node> nodes, Class<S> startClass, Class<E> endClass) throws GraphException {
    // copy remainNodes so that it doesn't break the original one.
    LinkedList<Node> copiedRemainNodes = new LinkedList<Node>(nodes);
    Set<Node> block = new HashSet<Node>();
    getSpecialBlock(node, 0, block, startClass, endClass);
    copiedRemainNodes.remove(node);
    while (block.size() > 0) {
        List<Node> doneNodeInBlock = new LinkedList<Node>();
        for (Node nodeInBlock : block) {
            if (isExecutable(nodeInBlock, copiedRemainNodes)) {
                copiedRemainNodes.remove(nodeInBlock);
                doneNodeInBlock.add(nodeInBlock);
            }
        }
        if (doneNodeInBlock.size() == 0) {
            // on outer nodes that haven't finished.
            return false;
        }
        block.removeAll(doneNodeInBlock);
    }
    return true;
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) BlockNode(org.apache.airavata.workflow.model.graph.system.BlockNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) EndBlockNode(org.apache.airavata.workflow.model.graph.system.EndBlockNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) ConstantNode(org.apache.airavata.workflow.model.graph.system.ConstantNode) EndifNode(org.apache.airavata.workflow.model.graph.system.EndifNode) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

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