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);
}
}
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);
}
}
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());
}
}
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;
}
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;
}
Aggregations