/**
*
*/
public void save() {
Workflow wf = this.engine.getWorkflow();
if (0 == wf.getGraph().getNodes().size()) {
this.engine.getErrorWindow().warning("Workflow is Empty");
return;
}
GpelProcess process;
try {
int returnVal = this.bpelFileChooser.showSaveDialog(this.engine.getGUI().getFrame());
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = this.bpelFileChooser.getSelectedFile();
String path = file.getPath();
// Remove ".bpel" at the end if any
if (path.endsWith(XBayaConstants.BPEL_SUFFIX)) {
path = path.substring(0, path.length() - XBayaConstants.BPEL_SUFFIX.length());
}
// Add ".bpel" at the end of the file name
File bpelFile = new File(path + XBayaConstants.BPEL_SUFFIX);
// Add ".wsdl" at the end of the file name
File wsdlFile = new File(path + XBayaConstants.WSDL_SUFFIX);
// todo this has to fix, for compilation purpose passing dummy value instead of xregistry url
URI temp = null;
try {
temp = new URI("temp");
} catch (URISyntaxException e) {
e.printStackTrace(); // To change body of catch statement use File | Settings | File Templates.
}
process = wf.getOdeProcess(WSDLUtil.appendWSDLQuary(temp), this.engine.getConfiguration().getODEURL());
String processString = process.xmlStringPretty();
FileWriter writer = new FileWriter(bpelFile);
writer.write(processString);
writer.close();
WsdlDefinitions workflowWSDL = wf.getOdeWorkflowWSDL(this.engine.getConfiguration().getDSCURL(),
this.engine.getConfiguration().getODEURL());
String workflowWsdlStr = XmlConstants.BUILDER.serializeToStringPretty(workflowWSDL.xml());
writer = new FileWriter(wsdlFile);
writer.write(workflowWsdlStr);
Map<String, WsdlDefinitions> wsdlMap = wf.getOdeServiceWSDLs(
this.engine.getConfiguration().getDSCURL(), this.engine.getConfiguration().getODEURL());
Set<String> keySet = wsdlMap.keySet();
for (String string : keySet) {
writer = new FileWriter(new File(wsdlFile.getParent(), QName.valueOf(string).getLocalPart()));
writer.write(XmlConstants.BUILDER.serializeToStringPretty(wsdlMap.get(string).xml()));
writer.close();
}
XmlElement deployDescriptor = wf.getODEDeploymentDescriptor(this.engine.getConfiguration().getDSCURL(),
this.engine.getConfiguration().getODEURL());
writer = new FileWriter(new File(wsdlFile.getParent(), "deploy.xml"));
writer.write(XmlConstants.BUILDER.serializeToString(deployDescriptor));
writer.close();