Search in sources :

Example 21 with InputNode

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

the class JythonScript method writeOutput.

private void writeOutput(OutputNode node, PrintWriter pw) throws GraphException {
    String id = node.getID();
    Port port = node.getPort();
    Node fromNode = port.getFromNode();
    if (fromNode == null) {
        throw new GraphException("Output parameter has to be connected to some node.");
    }
    Port fromPort = port.getFromPort();
    if (fromNode instanceof InputNode) {
        // The OutputNode is directly connected to an InputNode.
        pw.println(TAB + id + VALUE_SUFFIX + " = " + PROPERTIES_VARIABLE + "." + GET_PROPERTY_METHOD + "('" + fromNode.getID() + "')");
    } else {
        pw.println(TAB + "# Wait output " + id);
        pw.println(TAB + id + VALUE_SUFFIX + " = " + fromNode.getID() + INVOKER_SUFFIX + "." + GET_OUTPUT_METHOD + "('" + fromPort.getName() + "')");
    }
    pw.println(TAB + "print '" + id + " = ', " + id + VALUE_SUFFIX);
    // This might try to remove a node that has been removed
    // already, but it's OK.
    this.executingNodes.remove(fromNode);
    pw.println();
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) Port(org.apache.airavata.workflow.model.graph.Port) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) IfNode(org.apache.airavata.workflow.model.graph.system.IfNode) MemoNode(org.apache.airavata.workflow.model.graph.system.MemoNode) Node(org.apache.airavata.workflow.model.graph.Node) 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 22 with InputNode

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

the class JythonScript method writeParameters.

/**
 * Handles parameters
 *
 * @param pw
 */
private void writeParameters(PrintWriter pw) {
    pw.println(PROPERTIES_VARIABLE + " = Properties()");
    pw.println();
    pw.println("# Set up defaut parameter values.");
    writeSetProperty(BROKER_URL_VARIABLE, XBayaConstants.DEFAULT_BROKER_URL, pw);
    writeSetProperty(MESSAGE_BOX_URL_VARIABLE, this.configuration.getMessageBoxURL(), pw);
    writeSetProperty(TOPIC_VARIABLE, XBayaConstants.DEFAULT_TOPIC, pw);
    for (InputNode paramNode : this.inputNodes) {
        writeParameter(paramNode, pw);
        this.notYetInvokedNodes.remove(paramNode);
    }
    pw.println();
}
Also used : InputNode(org.apache.airavata.workflow.model.graph.system.InputNode)

Example 23 with InputNode

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

the class WorkflowModifier method createInputNodes.

/**
 * @param graph
 * @param originalFromPorts
 * @throws GraphException
 */
private void createInputNodes(WSGraph graph, Set<WSPort> originalFromPorts) throws GraphException {
    InputComponent inputComponent = new InputComponent();
    for (WSPort originalFromPort : originalFromPorts) {
        InputNode inputNode = inputComponent.createNode(graph);
        List<Port> originalToPorts = originalFromPort.getToPorts();
        boolean first = true;
        for (Port originalToPort : originalToPorts) {
            String toPortID = originalToPort.getID();
            Port toPort = graph.getPort(toPortID);
            graph.addEdge(inputNode.getPort(), toPort);
            if (first) {
                first = false;
                Point position = NodeController.getGUI(originalToPort).getPosition();
                Point inputNodePosition = new Point(0, position.y);
                inputNode.setPosition(inputNodePosition);
            }
        }
    }
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) Point(java.awt.Point)

Example 24 with InputNode

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

the class WorkflowModifier method createDifference.

/**
 * @return The workflow that needs to be executed.
 * @throws GraphException
 * @throws MonitorException
 */
public Workflow createDifference() throws GraphException, MonitorException {
    WSGraph originalGraph = this.modifiedWorkflow.getGraph();
    Workflow workflow = this.modifiedWorkflow.clone();
    String name = workflow.getName();
    name += " (diff)";
    workflow.setName(name);
    WSGraph graph = workflow.getGraph();
    // Remove the finished node.
    removeFinishedNodes(originalGraph, graph);
    Set<WSPort> originalFromPorts = getFinalOutputPorts(originalGraph, graph);
    // Create input nodes for unconnected input ports.
    createInputNodes(graph, originalFromPorts);
    // Set default values.
    for (WSPort originalFromPort : originalFromPorts) {
        // TODO handle the case that node is not WSNode.
        Node originalFromNode = originalFromPort.getNode();
        String fromNodeID = originalFromNode.getID();
        String output;
        if (originalFromNode instanceof InputNode) {
            // notification that includes the input of the workflow.
            output = getWorkflowInput(fromNodeID);
        } else if (originalFromNode instanceof WSNode) {
            // Retrieve input value from notification.
            WSComponent component = ((WSNode) originalFromNode).getComponent();
            String messageName = component.getOutputTypeName();
            String parameterName = originalFromPort.getComponentPort().getName();
            output = getOutput(fromNodeID, messageName, parameterName);
        } else {
            // This should not happen.
            throw new WorkflowRuntimeException(originalFromNode.getClass().getName());
        }
        Port originalToPort = originalFromPort.getToPorts().get(0);
        PortImpl toPort = graph.getPort(originalToPort.getID());
        InputNode inputNode = (InputNode) toPort.getFromNode();
        inputNode.setDefaultValue(output);
    }
    return workflow;
}
Also used : WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) InputNode(org.apache.airavata.workflow.model.graph.system.InputNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) 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) Port(org.apache.airavata.workflow.model.graph.Port) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) PortImpl(org.apache.airavata.workflow.model.graph.impl.PortImpl)

Example 25 with InputNode

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

Aggregations

InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)29 Node (org.apache.airavata.workflow.model.graph.Node)14 OutputNode (org.apache.airavata.workflow.model.graph.system.OutputNode)10 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)10 Port (org.apache.airavata.workflow.model.graph.Port)9 DataPort (org.apache.airavata.workflow.model.graph.DataPort)7 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)7 EndForEachNode (org.apache.airavata.workflow.model.graph.system.EndForEachNode)7 ForEachNode (org.apache.airavata.workflow.model.graph.system.ForEachNode)7 GraphException (org.apache.airavata.workflow.model.graph.GraphException)6 ConstantNode (org.apache.airavata.workflow.model.graph.system.ConstantNode)6 EndifNode (org.apache.airavata.workflow.model.graph.system.EndifNode)6 IfNode (org.apache.airavata.workflow.model.graph.system.IfNode)6 MemoNode (org.apache.airavata.workflow.model.graph.system.MemoNode)6 LinkedList (java.util.LinkedList)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)4 WorkFlowInterpreterException (org.apache.airavata.workflow.engine.interpretor.WorkFlowInterpreterException)3