Search in sources :

Example 1 with WSGraph

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

the class WorkflowFiler method getWorkflow.

/**
 * @param workflow
 * @return
 */
public Workflow getWorkflow() {
    Workflow workflow = null;
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        logger.debug(file.getPath());
        try {
            String path = file.getPath();
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph graph = WSGraphFactory.createGraph(file);
                workflow = Workflow.graphToWorkflow(graph);
            } else {
                XmlElement workflowElement = XMLUtil.loadXML(file);
                workflow = new Workflow(workflowElement);
            }
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
    return workflow;
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XmlElement(org.xmlpull.infoset.XmlElement) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File)

Example 2 with WSGraph

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

the class WorkflowFiler method importWorkflow.

/**
 * Imports a workflow from the local file to the current workflow.
 */
public void importWorkflow() {
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        try {
            String path = file.getPath();
            Workflow importedWorkflow;
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph importedGraph = WSGraphFactory.createGraph(file);
                importedWorkflow = Workflow.graphToWorkflow(importedGraph);
            } else {
                XmlElement importedWorkflowElement = XMLUtil.loadXML(file);
                importedWorkflow = new Workflow(importedWorkflowElement);
            }
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(importedWorkflow);
            this.engine.getGUI().setWorkflow(importedWorkflow);
            engine.getGUI().getGraphCanvas().setWorkflowFile(file);
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) XmlElement(org.xmlpull.infoset.XmlElement) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 3 with WSGraph

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

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

the class WorkflowFiler method openWorkflow.

/**
 * Opens a current workflow from the local file.
 */
public void openWorkflow() {
    Workflow workflow = null;
    int returnVal = this.graphFileChooser.showOpenDialog(this.engine.getGUI().getFrame());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File file = this.graphFileChooser.getSelectedFile();
        logger.debug(file.getPath());
        try {
            String path = file.getPath();
            if (path.endsWith(XBayaConstants.GRAPH_FILE_SUFFIX)) {
                WSGraph graph = WSGraphFactory.createGraph(file);
                workflow = Workflow.graphToWorkflow(graph);
            } else {
                JsonObject workflowObject = JSONUtil.loadJSON(file);
                // XmlElement workflowElement = XMLUtil.loadXML(file);
                // workflow = new Workflow(workflowElement);
                workflow = new Workflow(workflowObject);
            }
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(workflow);
            // this.engine.setWorkflow(workflow);
            engine.getGUI().getGraphCanvas().setWorkflowFile(file);
        } catch (IOException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.OPEN_FILE_ERROR, e);
        } catch (GraphException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (ComponentException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
        } catch (RuntimeException e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        } catch (Error e) {
            this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Workflow(org.apache.airavata.workflow.model.wf.Workflow) JsonObject(com.google.gson.JsonObject) IOException(java.io.IOException) WSGraph(org.apache.airavata.workflow.model.graph.ws.WSGraph) File(java.io.File) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Aggregations

WSGraph (org.apache.airavata.workflow.model.graph.ws.WSGraph)4 Workflow (org.apache.airavata.workflow.model.wf.Workflow)4 File (java.io.File)3 IOException (java.io.IOException)3 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)3 GraphException (org.apache.airavata.workflow.model.graph.GraphException)3 GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)2 XmlElement (org.xmlpull.infoset.XmlElement)2 JsonObject (com.google.gson.JsonObject)1 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)1 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)1 Node (org.apache.airavata.workflow.model.graph.Node)1 Port (org.apache.airavata.workflow.model.graph.Port)1 PortImpl (org.apache.airavata.workflow.model.graph.impl.PortImpl)1 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)1 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)1 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)1