Search in sources :

Example 16 with GraphException

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

the class XBayaToolBar method init.

private void init() {
    this.toolbar = new JToolBar();
    this.toolbar.setFloatable(false);
    Border border = BorderFactory.createEtchedBorder();
    this.toolbar.setBorder(border);
    JButton addNodeButton = new JButton("Add Node");
    addNodeButton.addActionListener(new AbstractAction() {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event) {
            try {
                XBayaToolBar.this.engine.getGUI().addNode();
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    });
    JButton removeNodeButton = new JButton("Remove Node");
    removeNodeButton.addActionListener(new AbstractAction() {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event) {
            try {
                XBayaToolBar.this.engine.getGUI().getGraphCanvas().removeSelectedNode();
            } catch (GraphException e) {
                // Should not happen
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    });
    JButton connectEdgeButton = new JButton("Connect/Disconnect");
    connectEdgeButton.addActionListener(new AbstractAction() {

        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent event) {
            try {
                XBayaToolBar.this.engine.getGUI().getGraphCanvas().addOrRemoveEdge();
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    });
    this.play = new JButton();
    PAUSE_ICON = SwingUtil.createImageIcon(IMAGES_PAUSE_JPEG);
    PLAY_ICON = SwingUtil.createImageIcon(IMAGES_PLAY_JPEG);
    this.playAction = new AbstractAction(null, PAUSE_ICON) {

        /**
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         */
        public void actionPerformed(ActionEvent e1) {
            try {
                Workflow workflow = engine.getGUI().getWorkflow();
                WorkflowExecutionState executionState = workflow.getExecutionState();
                if (executionState == WorkflowExecutionState.RUNNING || executionState == WorkflowExecutionState.STEP) {
                    workflow.setExecutionState(WorkflowExecutionState.PAUSED);
                    play.setIcon(PLAY_ICON);
                } else if (executionState == WorkflowExecutionState.PAUSED) {
                    workflow.setExecutionState(WorkflowExecutionState.RUNNING);
                    play.setIcon(PAUSE_ICON);
                } else {
                    throw new IllegalStateException("Unknown state :" + executionState);
                }
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    };
    this.play.setAction(this.playAction);
    this.step = new JButton();
    this.stepAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STEP_JPEG)) {

        /**
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         */
        public void actionPerformed(ActionEvent e2) {
            try {
                if (engine.getGUI().getWorkflow().getExecutionState() == WorkflowExecutionState.PAUSED) {
                    engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STEP);
                } else {
                    throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
                }
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    };
    this.step.setAction(stepAction);
    this.stop = new JButton();
    this.stopAction = new AbstractAction(null, SwingUtil.createImageIcon(IMAGES_STOP_JPEG)) {

        /**
         * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         */
        public void actionPerformed(ActionEvent e1) {
            try {
                if (engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.NONE || engine.getGUI().getWorkflow().getExecutionState() != WorkflowExecutionState.STOPPED) {
                    engine.getGUI().getWorkflow().setExecutionState(WorkflowExecutionState.STOPPED);
                } else {
                    throw new IllegalStateException("Unknown state :" + engine.getGUI().getWorkflow().getExecutionState());
                }
            } catch (RuntimeException e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            } catch (Error e) {
                XBayaToolBar.this.engine.getGUI().getErrorWindow().error(ErrorMessages.UNEXPECTED_ERROR, e);
            }
        }
    };
    this.stop.setAction(stopAction);
// this.toolbar.add(addNodeButton);
// this.toolbar.add(removeNodeButton);
// this.toolbar.addSeparator();
// this.toolbar.add(connectEdgeButton);
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) WorkflowExecutionState(org.apache.airavata.workflow.model.wf.WorkflowExecutionState) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Workflow(org.apache.airavata.workflow.model.wf.Workflow) JToolBar(javax.swing.JToolBar) Border(javax.swing.border.Border) AbstractAction(javax.swing.AbstractAction)

Example 17 with GraphException

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

the class InstanceNode method edgeWasAdded.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    super.edgeWasAdded(edge);
    if (edge instanceof ControlEdge) {
        Port toPort = edge.getToPort();
        Node toNode = toPort.getNode();
        /*
             * check if there is already more than instance node connecting to destination node
             */
        if (!(toNode instanceof InstanceNode)) {
            for (Node node : toNode.getControlInPort().getFromNodes()) {
                if ((node instanceof InstanceNode) && this != node) {
                    throw new GraphException("Cannot connect more than one instance node to another node.");
                }
            }
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node) ControlEdge(org.apache.airavata.workflow.model.graph.ControlEdge)

Example 18 with GraphException

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

the class ResourceNode method edgeWasAdded.

/**
 * @see org.apache.airavata.workflow.model.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.workflow.model.graph.Edge)
 */
@Override
protected void edgeWasAdded(Edge edge) throws GraphException {
    super.edgeWasAdded(edge);
    if (edge instanceof DataEdge) {
        Port toPort = edge.getToPort();
        Node toNode = toPort.getNode();
        Port fromPort = edge.getFromPort();
        Node fromNode = fromPort.getNode();
        if (!(toNode instanceof ResourceNode && fromNode instanceof ResourceNode)) {
            throw new GraphException("Cannot connect Resource Node to other type of nodes");
        }
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) DataEdge(org.apache.airavata.workflow.model.graph.DataEdge) Port(org.apache.airavata.workflow.model.graph.Port) Node(org.apache.airavata.workflow.model.graph.Node)

Example 19 with GraphException

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

the class GraphImpl method importGraph.

/**
 * @throws GraphException
 * @see org.apache.airavata.workflow.model.graph.Graph#importGraph(org.apache.airavata.workflow.model.graph.Graph)
 */
public void importGraph(Graph graph) throws GraphException {
    // Does not support other implementations.
    if (!(graph instanceof GraphImpl)) {
        throw new GraphException("Cannot import this graph implementation");
    }
    GraphImpl graphImpl = (GraphImpl) graph;
    for (NodeImpl node : graphImpl.getNodes()) {
        addNode(node);
        // Recreates the ID so that it doesn't conflict with the existing
        // one.
        node.createID();
        // Changes the position.
        Point position = node.getPosition();
        node.setPosition(new Point(position.x + 5, position.y + 5));
    }
    for (PortImpl port : graphImpl.getPorts()) {
        addPort(port);
    }
    for (EdgeImpl edge : graphImpl.getEdges()) {
        addEdge(edge);
    }
}
Also used : GraphException(org.apache.airavata.workflow.model.graph.GraphException) Point(java.awt.Point)

Example 20 with GraphException

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

the class WorkflowNodeGUI method openWorkflowTab.

public void openWorkflowTab(XBayaEngine engine) {
    try {
        Workflow workflow = this.node.getComponent().getWorkflow();
        engine.getGUI().selectOrCreateGraphCanvas(workflow);
    } catch (GraphException e) {
        engine.getGUI().getErrorWindow().error(ErrorMessages.GRAPH_FORMAT_ERROR, e);
    } catch (ComponentException e) {
        engine.getGUI().getErrorWindow().error(ErrorMessages.COMPONENT_FORMAT_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)

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