Search in sources :

Example 1 with ComponentException

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

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

use of org.apache.airavata.workflow.model.component.ComponentException in project airavata by apache.

the class ComponentSelector method select.

/**
 * This method is called when a component is selected. It reads the component information from the server and set
 * the selectedComponent.
 *
 * @param treePath
 *            The path of the selected selectedComponent.
 */
private void select(TreePath treePath) {
    final ComponentTreeNode selectedNode = (ComponentTreeNode) treePath.getLastPathComponent();
    final ComponentReference componentReference = selectedNode.getComponentReference();
    selectComponent(null);
    this.selectedComponentReference = null;
    if (componentReference != null) {
        this.selectedComponentReference = componentReference;
        new Thread() {

            @Override
            public void run() {
                try {
                    // get all components and check the number of
                    // components. If there are multiple, expand the tree.
                    final List<? extends Component> components = componentReference.getComponents();
                    if (components.size() == 1) {
                        selectComponent(components.get(0));
                    } else {
                        SwingUtilities.invokeLater(new Runnable() {

                            public void run() {
                                expandTreeLeaf(selectedNode, components);
                            }
                        });
                    }
                } catch (ComponentException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_ERROR, e);
                } catch (ComponentRegistryException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                } catch (RuntimeException e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                } catch (Exception e) {
                    selectComponent(null);
                    ComponentSelector.this.engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_LOAD_ERROR, e);
                }
            }
        }.start();
    }
}
Also used : WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) WSComponent(org.apache.airavata.workflow.model.component.ws.WSComponent) Component(org.apache.airavata.workflow.model.component.Component) XBayaComponent(org.apache.airavata.xbaya.ui.widgets.XBayaComponent) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)

Example 4 with ComponentException

use of org.apache.airavata.workflow.model.component.ComponentException in project airavata by apache.

the class WSComponentFactory method createComponent.

/**
 * @param wsdl
 * @param portTypeQName
 * @param operationName
 * @return The component created.
 * @throws ComponentException
 */
public static WSComponent createComponent(ApplicationInterfaceDescription application, String operationName) throws ComponentException {
    try {
        WSComponent component;
        component = new WSComponent(new WSComponentApplication(application));
        return component;
    } catch (RuntimeException e) {
        throw new ComponentException(MessageConstants.COMPONENT_FORMAT_ERROR, e);
    }
}
Also used : ComponentException(org.apache.airavata.workflow.model.component.ComponentException)

Example 5 with ComponentException

use of org.apache.airavata.workflow.model.component.ComponentException in project airavata by apache.

the class GraphCanvas method drop.

private void drop(final DropTargetDropEvent event) {
    logger.debug("Event:" + event);
    Transferable transferable = event.getTransferable();
    try {
        // Cannot cast transferable.
        final ComponentReference componentReference = (ComponentReference) transferable.getTransferData(ComponentSourceTransferable.FLAVOR);
        final Point location = event.getLocation();
        // The component might not have loaded if the network is slow.
        new Thread() {

            @Override
            public void run() {
                try {
                    Component component = componentReference.getComponent();
                    addNode(component, location);
                    // To be able to delete the added node by the keyboard.
                    GraphCanvas.this.panel.requestFocusInWindow();
                    // XXX this sometimes throws exception.
                    event.dropComplete(true);
                } catch (ComponentException e) {
                    // If there is any error, the component tree viewer
                    // shows the error dialog.
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                } catch (ComponentRegistryException e) {
                    logger.error(e.getMessage(), e);
                    event.dropComplete(false);
                }
            }
        }.start();
    } catch (UnsupportedFlavorException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        // Should not happen.
        logger.error(e.getMessage(), e);
    }
}
Also used : ComponentSourceTransferable(org.apache.airavata.xbaya.ui.widgets.component.ComponentSourceTransferable) Transferable(java.awt.datatransfer.Transferable) ComponentReference(org.apache.airavata.workflow.model.component.ComponentReference) ComponentException(org.apache.airavata.workflow.model.component.ComponentException) Point(java.awt.Point) ComponentRegistryException(org.apache.airavata.workflow.model.component.ComponentRegistryException) IOException(java.io.IOException) InputComponent(org.apache.airavata.workflow.model.component.system.InputComponent) Component(org.apache.airavata.workflow.model.component.Component) OutputComponent(org.apache.airavata.workflow.model.component.system.OutputComponent) JComponent(javax.swing.JComponent) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException)

Aggregations

ComponentException (org.apache.airavata.workflow.model.component.ComponentException)10 GraphException (org.apache.airavata.workflow.model.graph.GraphException)5 Workflow (org.apache.airavata.workflow.model.wf.Workflow)5 IOException (java.io.IOException)4 File (java.io.File)3 WSComponent (org.apache.airavata.workflow.model.component.ws.WSComponent)3 WSGraph (org.apache.airavata.workflow.model.graph.ws.WSGraph)3 XmlElement (org.xmlpull.infoset.XmlElement)3 JsonObject (com.google.gson.JsonObject)2 Component (org.apache.airavata.workflow.model.component.Component)2 ComponentReference (org.apache.airavata.workflow.model.component.ComponentReference)2 ComponentRegistryException (org.apache.airavata.workflow.model.component.ComponentRegistryException)2 WSComponentApplication (org.apache.airavata.workflow.model.component.ws.WSComponentApplication)2 GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)2 Point (java.awt.Point)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1