Search in sources :

Example 11 with Workflow

use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.

the class SubWorkflowNodeGUI method openWorkflowTab.

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

Example 12 with Workflow

use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.

the class WorkflowImportWindow method ok.

private void ok() {
    List<RegistrySearchResult> selectedValues = this.list.getSelectedValues();
    try {
        for (RegistrySearchResult result : selectedValues) {
            org.apache.airavata.model.Workflow workflow = getClient().getWorkflow(result.getResourceName());
            XmlElement workflowElement = XMLUtil.stringToXmlElement(workflow.getGraph());
            Workflow w = new Workflow(workflowElement);
            GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
            newGraphCanvas.setWorkflow(w);
            engine.getGUI().getGraphCanvas().setWorkflowFile(null);
        }
        hide();
    } catch (Exception e) {
        engine.getGUI().getErrorWindow().error(e);
    }
}
Also used : RegistrySearchResult(org.apache.airavata.xbaya.ui.experiment.RegistrySearchResult) XmlElement(org.xmlpull.infoset.XmlElement) Workflow(org.apache.airavata.workflow.model.wf.Workflow) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas) InvalidRequestException(org.apache.airavata.model.error.InvalidRequestException) TException(org.apache.thrift.TException) AiravataClientException(org.apache.airavata.model.error.AiravataClientException) AiravataSystemException(org.apache.airavata.model.error.AiravataSystemException)

Example 13 with Workflow

use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.

the class RegistryWorkflowPublisherWindow method ok.

private void ok() {
    String name = this.nameTextField.getText();
    String description = this.descriptionTextArea.getText();
    GraphCanvas graphCanvas = this.engine.getGUI().getGraphCanvas();
    graphCanvas.setNameAndDescription(name, description);
    workflow.setName(name);
    String workflowTemplateName = workflow.getName();
    try {
        ThriftClientData thriftClientData = engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE);
        Client client = AiravataClientFactory.createAiravataClient(thriftClientData.getServerAddress(), thriftClientData.getServerPort());
        if (client.isWorkflowExistWithName(workflowTemplateName)) {
            int result = JOptionPane.showConfirmDialog(this.dialog.getDialog(), "A workflow with the name " + workflowTemplateName + " already exists. Do you want to update it?", "Register Workflow", JOptionPane.YES_NO_CANCEL_OPTION);
            if (result == JOptionPane.NO_OPTION) {
                return;
            } else if (result == JOptionPane.CANCEL_OPTION) {
                hide();
            }
            String workflowAsString = XMLUtil.xmlElementToString(engine.getGUI().getGraphCanvas().getWorkflow().toXML());
            org.apache.airavata.model.Workflow workflowData = new org.apache.airavata.model.Workflow();
            workflowData.setName(workflowTemplateName);
            workflowData.setGraph(workflowAsString);
            client.registerWorkflow(engine.getConfiguration().getThriftClientData(ThriftServiceType.API_SERVICE).getGatewayId(), workflowData);
            hide();
        }
    } catch (Exception e) {
        this.engine.getGUI().getErrorWindow().error(e.getMessage());
    }
}
Also used : ThriftClientData(org.apache.airavata.xbaya.ThriftClientData) Workflow(org.apache.airavata.workflow.model.wf.Workflow) Client(org.apache.airavata.api.Airavata.Client) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 14 with Workflow

use of org.apache.airavata.workflow.model.wf.Workflow in project airavata by apache.

the class XBayaGUI method getNewGraphCanvas.

public GraphCanvas getNewGraphCanvas(String wfName, String wfDescription) {
    GraphCanvas newGraphCanvas = new GraphCanvas(this.engine, wfName);
    newGraphCanvas.setDescription(wfDescription);
    this.graphCanvases.add(newGraphCanvas);
    this.graphTabbedPane.addTab(newGraphCanvas.getWorkflow().getName(), newGraphCanvas.getSwingComponent());
    final int index = graphTabbedPane.getTabCount() - 1;
    TabLabelButton tabLabelButton = new TabLabelButton(graphTabbedPane, "Close this workflow");
    graphTabbedPane.setTabComponentAt(index, tabLabelButton);
    tabLabelButton.setCloseButtonListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeGraphCanvasFromIndex(index);
        }
    });
    graphTabbedPane.addContainerListener(new ContainerListener() {

        @Override
        public void componentAdded(ContainerEvent event) {
        }

        @Override
        public void componentRemoved(ContainerEvent event) {
            List<GraphCanvas> graphCanvases = engine.getGUI().getGraphCanvases();
            for (GraphCanvas graphCanvas : graphCanvases) {
                if (graphCanvas.getSwingComponent() == event.getComponent()) {
                    if (graphCanvas.isWorkflowChanged()) {
                        setFocus(graphCanvas);
                        if (JOptionPane.showConfirmDialog(null, "The workflow '" + graphCanvas.getWorkflow().getName() + "' has been modified. Save changes?", "Save Workflow", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                            graphFiler.saveWorkflow(graphCanvas);
                        }
                    }
                    break;
                }
            }
        }
    });
    newGraphCanvas.addGraphCanvasListener(this.componentViewer);
    newGraphCanvas.addGraphCanvasListener(this.portViewer);
    newGraphCanvas.addGraphCanvasListener(new GraphCanvasListener() {

        public void graphCanvasChanged(GraphCanvasEvent event) {
            GraphCanvasEventType type = event.getType();
            final GraphCanvas graphCanvas = event.getGraphCanvas();
            final Workflow workflow = event.getWorkflow();
            switch(type) {
                case GRAPH_LOADED:
                case NAME_CHANGED:
                    SwingUtilities.invokeLater(new Runnable() {

                        public void run() {
                            String name = workflow.getName();
                            // Change the name of the tab.
                            updateTabTitle(graphCanvas, workflow);
                            // Change the name of the frame.
                            setFrameName(name);
                        }
                    });
                    break;
                case NODE_SELECTED:
                case INPUT_PORT_SELECTED:
                case OUTPUT_PORT_SELECTED:
                // Do nothing
                case WORKFLOW_CHANGED:
                    updateTabTitle(graphCanvas, graphCanvas.getWorkflow());
                    setFrameName(workflow.getName());
                    for (ChangeListener listener : tabChangeListeners) {
                        try {
                            listener.stateChanged(null);
                        } catch (Exception e) {
                            logger.error(e.getMessage(), e);
                        }
                    }
            }
        }

        private void updateTabTitle(final GraphCanvas graphCanvas, final Workflow workflow) {
            int index = XBayaGUI.this.graphTabbedPane.indexOfComponent(graphCanvas.getSwingComponent());
            String newTitle = workflow.getName();
            if (graphCanvas.isWorkflowChanged()) {
                newTitle = "*" + newTitle;
            }
            XBayaGUI.this.graphTabbedPane.setTitleAt(index, newTitle);
        }
    });
    return newGraphCanvas;
}
Also used : ContainerEvent(java.awt.event.ContainerEvent) TabLabelButton(org.apache.airavata.xbaya.ui.widgets.TabLabelButton) ActionEvent(java.awt.event.ActionEvent) Workflow(org.apache.airavata.workflow.model.wf.Workflow) InvocationTargetException(java.lang.reflect.InvocationTargetException) WorkflowRuntimeException(org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException) MonitorException(org.apache.airavata.xbaya.messaging.MonitorException) WorkflowException(org.apache.airavata.workflow.model.exceptions.WorkflowException) ActionListener(java.awt.event.ActionListener) GraphCanvasEventType(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent.GraphCanvasEventType) GraphCanvasListener(org.apache.airavata.xbaya.ui.graph.GraphCanvasListener) ContainerListener(java.awt.event.ContainerListener) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ChangeListener(javax.swing.event.ChangeListener) GraphCanvasEvent(org.apache.airavata.xbaya.ui.graph.GraphCanvasEvent) GraphCanvas(org.apache.airavata.xbaya.ui.graph.GraphCanvas)

Example 15 with Workflow

use of org.apache.airavata.workflow.model.wf.Workflow 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)

Aggregations

Workflow (org.apache.airavata.workflow.model.wf.Workflow)21 GraphException (org.apache.airavata.workflow.model.graph.GraphException)9 File (java.io.File)6 GraphCanvas (org.apache.airavata.xbaya.ui.graph.GraphCanvas)6 ComponentException (org.apache.airavata.workflow.model.component.ComponentException)5 WorkflowRuntimeException (org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException)5 Node (org.apache.airavata.workflow.model.graph.Node)5 WSNode (org.apache.airavata.workflow.model.graph.ws.WSNode)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 WorkflowException (org.apache.airavata.workflow.model.exceptions.WorkflowException)4 DataPort (org.apache.airavata.workflow.model.graph.DataPort)4 InputNode (org.apache.airavata.workflow.model.graph.system.InputNode)4 WSGraph (org.apache.airavata.workflow.model.graph.ws.WSGraph)4 LinkedList (java.util.LinkedList)3 Port (org.apache.airavata.workflow.model.graph.Port)3 NodeImpl (org.apache.airavata.workflow.model.graph.impl.NodeImpl)3 TException (org.apache.thrift.TException)3 Point (java.awt.Point)2 ActionEvent (java.awt.event.ActionEvent)2