Search in sources :

Example 1 with GraphException

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

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

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

the class WorkflowHarvester method removeUnnecessaryNodes.

/**
 * @param pair
 * @param clone
 */
private void removeUnnecessaryNodes(Node node, Port candidatePort, Workflow workflow) {
    if (candidatePort.getFromPort().getEdges().size() == 1) {
        Node fromNode = candidatePort.getFromNode();
        try {
            List<DataPort> inputPorts = fromNode.getInputPorts();
            for (DataPort dataPort : inputPorts) {
                removeUnnecessaryNodes(fromNode, dataPort, workflow);
            }
            workflow.removeNode(fromNode);
        } catch (GraphException e) {
            throw new WorkflowRuntimeException(e);
        }
    }
}
Also used : DataPort(org.apache.airavata.workflow.model.graph.DataPort) GraphException(org.apache.airavata.workflow.model.graph.GraphException) 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)

Example 4 with GraphException

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

the class WSPort method copyType.

/**
 * @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
 */
@Override
public void copyType(DataPort port) throws GraphException {
    DataType newType = port.getType();
    DataType type = getType();
    NodeImpl node = port.getNode();
    if (node instanceof ForEachNode || node instanceof EndForEachNode) {
        // from WSDL.
        return;
    }
    if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
        String message = "The type (" + newType + ")  must be same as the type  " + " (" + type + ") of " + getID() + ".";
        throw new GraphException(message);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) NodeImpl(org.apache.airavata.workflow.model.graph.impl.NodeImpl) DataType(org.apache.airavata.model.application.io.DataType) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode) ForEachNode(org.apache.airavata.workflow.model.graph.system.ForEachNode) EndForEachNode(org.apache.airavata.workflow.model.graph.system.EndForEachNode)

Example 5 with GraphException

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

the class Workflow method clone.

/**
 * @see java.lang.Object#clone()
 */
@Override
public Workflow clone() {
    XmlElement originalXML = toXML();
    try {
        XmlElement newXML = XMLUtil.deepClone(originalXML);
        Workflow newWorkflow = new Workflow(newXML);
        return newWorkflow;
    } catch (GraphException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (WorkflowException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    } catch (AiravataException e) {
        // This should not happen.
        throw new WorkflowRuntimeException(e);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) XmlElement(org.xmlpull.infoset.XmlElement) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) AiravataException(org.apache.airavata.common.exception.AiravataException)

Aggregations

GraphException (org.apache.airavata.workflow.model.graph.GraphException)38 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)18 DataPort (org.apache.airavata.workflow.model.graph.DataPort)15 Node (org.apache.airavata.workflow.model.graph.Node)11 DataEdge (org.apache.airavata.workflow.model.graph.DataEdge)10 Port (org.apache.airavata.workflow.model.graph.Port)9 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)9 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)9 Workflow (org.apache.airavata.workflow.model.wf.Workflow)9 IOException (java.io.IOException)6 DataType (org.apache.airavata.model.application.io.DataType)6 LinkedList (java.util.LinkedList)5 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)5 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)5 WSPort (org.apache.airavata.workflow.model.graph.ws.WSPort)5 XmlElement (org.xmlpull.infoset.XmlElement)5 Point (java.awt.Point)4 File (java.io.File)4 JsonObject (com.google.gson.JsonObject)3 DataType (org.apache.airavata.model.appcatalog.appinterface.DataType)3