use of org.apache.airavata.workflow.model.graph.GraphException 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.GraphException 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.GraphException in project airavata by apache.
the class WorkflowHarvester method removeUnnecessaryNodes.
/**
* @param pair
* @param clone
*/
private void removeUnnecessaryNodes(Node node, Port candidatePort, Workflow workflow) {
if (candidatePort.getFromPort().getEdges().size() == 1) {
Node fromNode = candidatePort.getFromNode();
try {
List<DataPort> inputPorts = fromNode.getInputPorts();
for (DataPort dataPort : inputPorts) {
removeUnnecessaryNodes(fromNode, dataPort, workflow);
}
workflow.removeNode(fromNode);
} catch (GraphException e) {
throw new WorkflowRuntimeException(e);
}
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class WSPort method copyType.
/**
* @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
*/
@Override
public void copyType(DataPort port) throws GraphException {
DataType newType = port.getType();
DataType type = getType();
NodeImpl node = port.getNode();
if (node instanceof ForEachNode || node instanceof EndForEachNode) {
// from WSDL.
return;
}
if (!(newType == null || newType.equals(WSConstants.XSD_ANY_TYPE) || type == null || type.equals(WSConstants.XSD_ANY_TYPE) || newType.equals(type))) {
String message = "The type (" + newType + ") must be same as the type " + " (" + type + ") of " + getID() + ".";
throw new GraphException(message);
}
}
use of org.apache.airavata.workflow.model.graph.GraphException in project airavata by apache.
the class Workflow method clone.
/**
* @see java.lang.Object#clone()
*/
@Override
public Workflow clone() {
XmlElement originalXML = toXML();
try {
XmlElement newXML = XMLUtil.deepClone(originalXML);
Workflow newWorkflow = new Workflow(newXML);
return newWorkflow;
} catch (GraphException e) {
// This should not happen.
throw new WorkflowRuntimeException(e);
} catch (WorkflowException e) {
// This should not happen.
throw new WorkflowRuntimeException(e);
} catch (AiravataException e) {
// This should not happen.
throw new WorkflowRuntimeException(e);
}
}
Aggregations