use of org.apache.airavata.workflow.model.graph.ws.WSGraph 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;
}
use of org.apache.airavata.workflow.model.graph.ws.WSGraph 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);
}
}
}
use of org.apache.airavata.workflow.model.graph.ws.WSGraph 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;
}
use of org.apache.airavata.workflow.model.graph.ws.WSGraph in project airavata by apache.
the class WorkflowFiler method openWorkflow.
/**
* Opens a current workflow from the local file.
*/
public void openWorkflow() {
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 {
JsonObject workflowObject = JSONUtil.loadJSON(file);
// XmlElement workflowElement = XMLUtil.loadXML(file);
// workflow = new Workflow(workflowElement);
workflow = new Workflow(workflowObject);
}
GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(true);
newGraphCanvas.setWorkflow(workflow);
// this.engine.setWorkflow(workflow);
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);
}
}
}
Aggregations