Search in sources :

Example 16 with WSPort

use of org.apache.airavata.workflow.model.graph.ws.WSPort 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 17 with WSPort

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

the class WorkflowInterpreter method setupNodeDetailsInput.

private void setupNodeDetailsInput(Node node, WorkflowNodeDetails nodeDetails) {
    List<DataPort> inputPorts = node.getInputPorts();
    for (DataPort dataPort : inputPorts) {
        Node fromNode = dataPort.getFromNode();
        String portInputValue = null;
        if (fromNode instanceof InputNode) {
            portInputValue = (String) ((InputNode) fromNode).getDefaultValue();
        } else if (fromNode instanceof WSNode) {
            Map<String, String> outputData = nodeOutputData.get(fromNode);
            portInputValue = outputData.get(dataPort.getName());
            if (portInputValue == null) {
                portInputValue = outputData.get(dataPort.getEdge(0).getFromPort().getName());
            }
        }
        // 123456789
        InputDataObjectType elem = new InputDataObjectType();
        elem.setName(dataPort.getName());
        elem.setValue(portInputValue);
        if (dataPort instanceof WSPort) {
            WSPort port = (WSPort) dataPort;
            elem.setInputOrder(port.getComponentPort().getInputOrder());
            elem.setApplicationArgument((port.getComponentPort().getApplicationArgument() != null ? port.getComponentPort().getApplicationArgument() : ""));
            elem.setType(port.getType());
        }
        nodeDetails.addToNodeInputs(elem);
    }
    try {
        getExperimentCatalog().update(ExperimentCatalogModelType.WORKFLOW_NODE_DETAIL, nodeDetails, nodeDetails.getNodeInstanceId());
    } catch (RegistryException e) {
        log.error(e.getMessage(), e);
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) WSPort(org.apache.airavata.workflow.model.graph.ws.WSPort) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) DynamicNode(org.apache.airavata.workflow.model.graph.dynamic.DynamicNode) Node(org.apache.airavata.workflow.model.graph.Node) SubWorkflowNode(org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode) WSNode(org.apache.airavata.workflow.model.graph.ws.WSNode) RegistryException(org.apache.airavata.registry.cpi.RegistryException)

Aggregations

WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)17 DataPort (org.apache.airavata.workflow.model.graph.DataPort)12 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)11 Port (org.apache.airavata.workflow.model.graph.Port)7 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)6 DataType (org.apache.airavata.model.application.io.DataType)5 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)4 WSComponentPort (org.apache.airavata.workflow.model.component.ws.WSComponentPort)4 Edge (org.apache.airavata.workflow.model.graph.Edge)4 GraphException (org.apache.airavata.workflow.model.graph.GraphException)4 Node (org.apache.airavata.workflow.model.graph.Node)3 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)3 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)3 DynamicNode (org.apache.airavata.workflow.model.graph.dynamic.DynamicNode)2 SubWorkflowNode (org.apache.airavata.workflow.model.graph.subworkflow.SubWorkflowNode)2 Point (java.awt.Point)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 ExpCatChildDataType (org.apache.airavata.registry.cpi.ExpCatChildDataType)1 RegistryException (org.apache.airavata.registry.cpi.RegistryException)1