Search in sources :

Example 16 with NodeImpl

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

the class InterpreterUtil method getNodesWithBodyColor.

public static ArrayList<Node> getNodesWithBodyColor(NodeExecutionState state, WSGraph graph) {
    ArrayList<Node> list = new ArrayList<Node>();
    List<NodeImpl> nodes = graph.getNodes();
    for (Node node : nodes) {
        if (node.getState() == state) {
            list.add(node);
        }
    }
    return list;
}
Also used : NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) 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) ArrayList(java.util.ArrayList)

Example 17 with NodeImpl

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

the class LaunchApplicationWindow method show.

/**
 * Shows the dialog.
 */
public void show() {
    this.workflow = this.engine.getGUI().getWorkflow();
    // Create input fields
    // Collection<InputNode> inputNodes = GraphUtil.getInputNodes(this.workflow.getGraph());
    // for (InputNode node : inputNodes) {
    // String id = node.getID();
    // QName parameterType = node.getParameterType();
    // JLabel nameLabel = new JLabel(id);
    // JLabel typeField = new JLabel(parameterType.getLocalPart());
    // XBayaTextField paramField = new XBayaTextField();
    // Object value = node.getDefaultValue();
    // 
    // String valueString;
    // if (value == null) {
    // valueString = "";
    // } else {
    // if (value instanceof XmlElement) {
    // XmlElement valueElement = (XmlElement) value;
    // valueString = XMLUtil.xmlElementToString(valueElement);
    // } else {
    // // Only string comes here for now.
    // valueString = value.toString();
    // }
    // }
    // paramField.setText(valueString);
    List<NodeImpl> nodes = workflow.getGraph().getNodes();
    NodeImpl node = null;
    for (int i = 0; i < nodes.size(); i++) {
        node = nodes.get(i);
        String html = node.getComponent().toHTML();
        String nodeType = html.substring(html.indexOf("<h1>") + 4, html.indexOf(":")).trim();
        if (nodeType.equals("Application")) {
            break;
        }
    }
    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort port : inputPorts) {
        String id = port.getName();
        DataType parameterType = port.getType();
        JLabel nameLabel = new JLabel(id);
        JLabel typeField = new JLabel(parameterType.toString());
        XBayaTextField paramField = new XBayaTextField();
        paramField.setText("");
        this.parameterPanel.add(nameLabel);
        this.parameterPanel.add(typeField);
        this.parameterPanel.add(paramField);
        this.parameterTextFields.add(paramField);
    }
    Map<String, String> hosts = null;
    try {
        hosts = airavataClient.getAllComputeResourceNames();
    } catch (InvalidRequestException e) {
        logger.error(e.getMessage(), e);
    } catch (AiravataClientException e) {
        logger.error(e.getMessage(), e);
    } catch (AiravataSystemException e) {
        logger.error(e.getMessage(), e);
    } catch (TException e) {
        logger.error(e.getMessage(), e);
    }
    hostNames = new HashMap<String, String>();
    Iterator it = hosts.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        String value = (String) pairs.getValue();
        if (!hostNames.containsKey(value)) {
            hostNames.put(value, key);
        }
    }
    host = new JComboBox();
    it = hostNames.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pairs = (Map.Entry) it.next();
        String key = (String) pairs.getKey();
        host.addItem(key);
    }
    host.setSelectedIndex(1);
    XBayaLabel hostLabel = new XBayaLabel("Host", this.host);
    this.parameterPanel.add(hostLabel);
    this.parameterPanel.add(host);
    // this.parameterPanel.layout(inputNodes.size()+1, 2, GridPanel.WEIGHT_NONE, 2);
    this.dialog.show();
}
Also used : TException(org.apache.thrift.TException) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) DataPort(org.apache.airavata.workflow.model.graph.DataPort) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException) Iterator(java.util.Iterator) DataType(org.apache.airavata.model.appcatalog.appinterface.DataType) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) XBayaTextField(org.apache.airavata.xbaya.ui.widgets.XBayaTextField) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) HashMap(java.util.HashMap) Map(java.util.Map) XBayaLabel(org.apache.airavata.xbaya.ui.widgets.XBayaLabel)

Example 18 with NodeImpl

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

the class WorkflowHarvester method cleanLeftOverInputNodes.

/**
 * @param clone
 */
private void cleanLeftOverInputNodes(Workflow clone) {
    List<NodeImpl> nodes = clone.getGraph().getNodes();
    LinkedList<Node> removeList = new LinkedList<Node>();
    for (Node nodeImpl : nodes) {
        if (nodeImpl instanceof InputNode) {
            if (nodeImpl.getOutputPort(0).getToNodes().size() == 0) {
                removeList.add(nodeImpl);
            }
        }
    }
    for (Node node : removeList) {
        try {
            clone.removeNode(node);
        } catch (GraphException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) 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) LinkedList(java.util.LinkedList)

Example 19 with NodeImpl

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

the class WorkflowHarvester method harvest.

public Workflow[] harvest(Workflow workflow, QName dataType) {
    LinkedList<Workflow> harvest = new LinkedList<Workflow>();
    LinkedList<Pair<String, String>> candidates = getCandidates(workflow, dataType);
    for (Pair<String, String> pair : candidates) {
        Workflow clone = workflow.clone();
        NodeImpl node = clone.getGraph().getNode(pair.getLeft());
        if (null == node) {
            throw new WorkflowRuntimeException("Specified node not found:" + pair.getLeft());
        }
        Port candidatePort = null;
        List<DataPort> inPorts = node.getInputPorts();
        for (DataPort dataPort : inPorts) {
            if (pair.getRight().equals(dataPort.getID())) {
                candidatePort = dataPort;
                break;
            }
        }
        if (null == candidatePort) {
            throw new WorkflowRuntimeException("Specifies Port was not found:" + pair.getRight());
        }
        if (!(candidatePort.getFromNode() instanceof InputNode)) {
            removeUnnecessaryNodes(node, candidatePort, clone);
            Node input = clone.addNode(new InputComponent());
            input.setPosition(new Point(Math.max(0, node.getPosition().x - 150), node.getPosition().y));
            // original
            if (clone.getGraph().getNodes().size() < workflow.getGraph().getNodes().size() && // its not the same as one already harvested
            !isWorkflowAlreadyHarvested(harvest, clone)) {
                try {
                    clone.getGraph().addEdge(input.getOutputPort(0), candidatePort);
                    cleanLeftOverInputNodes(clone);
                } catch (GraphException e) {
                    throw new RuntimeException(e);
                }
                harvest.add(clone);
            }
        }
    }
    return harvest.toArray(new Workflow[0]);
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataPort(org.apache.airavata.workflow.model.graph.DataPort) Port(org.apache.airavata.workflow.model.graph.Port) 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) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Point(java.awt.Point) LinkedList(java.util.LinkedList) DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) Pair(org.apache.airavata.common.utils.Pair)

Example 20 with NodeImpl

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

the class Workflow method getWorkflowServiceNodeIDs.

public List<String> getWorkflowServiceNodeIDs() {
    List<NodeImpl> nodes = getGraph().getNodes();
    ArrayList<String> nodeIDs = new ArrayList<String>();
    for (Node node : nodes) {
        if (node instanceof WSNode) {
            nodeIDs.add(node.getID());
        }
    }
    return nodeIDs;
}
Also used : WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) 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) OutputNode(org.apache.airavata.workflow.model.graph.system.OutputNode) ArrayList(java.util.ArrayList)

Aggregations

NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)24 Node (org.apache.airavata.workflow.model.graph.Node)14 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)14 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)12 LinkedList (java.util.LinkedList)11 DataPort (org.apache.airavata.workflow.model.graph.DataPort)8 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)6 GraphException (org.apache.airavata.workflow.model.graph.GraphException)5 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)5 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)5 Pair (org.apache.airavata.common.utils.Pair)4 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)4 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)4 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)4 StreamSourceNode (org.apache.airavata.workflow.model.graph.system.StreamSourceNode)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)3 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 RegistryException (org.apache.airavata.registry.cpi.RegistryException)2