@SuppressWarnings("unchecked")
void writeBpelProcesses(){
BPELResourceFactoryImpl brsf = new BPELResourceFactoryImpl();
Iterator<org.eclipse.bpel.model.Process> processes = classProcessMap.values().iterator();
int bpelCounter = 1;
while (processes.hasNext()){
org.eclipse.bpel.model.Process process = processes.next();
addBpelImports(process);
HashSet<WsdlImportInfo> wsdlImports = new HashSet<WsdlImportInfo>();
Iterator<Definition> bpelWsdlImports = processWsdlDeps.get(process).iterator();
while (bpelWsdlImports.hasNext()){
Definition def = bpelWsdlImports.next();
WsdlImportInfo imp = new WsdlImportInfo();
imp.setLocation(def.getDocumentBaseURI());
imp.setNamespace(def.getTargetNamespace());
wsdlImports.add(imp);
}
WsdlPartnerLinkSerializer plinkSerializer = new WsdlPartnerLinkSerializer();
plinkSerializer.serializePartnerLinkTypes(process.getPartnerLinks(),
process.getTargetNamespace() + "Artifacts",
process.getName() + "Artifacts",
outputDirectory + process.getName() + "Artifacts.wsdl",
wsdlImports,wsdlNsPrefixMap,outputToConsole);
org.eclipse.bpel.model.Import bpelImport = BPELFactory.eINSTANCE.createImport();
bpelImport.setImportType(WSDLConstants.WSDL_NAMESPACE_URI);
bpelImport.setLocation(process.getName() + "Artifacts.wsdl");
bpelImport.setNamespace(process.getTargetNamespace() + "Artifacts");
process.getImports().add(bpelImport);
try {
String fileName = "bpel" + bpelCounter + ".bpel";
String namespacePrefix = "bpel" + bpelCounter++;
//javax.xml.transform.Result result = bpelOutputResolver.createBpelOutput(process.getTargetNamespace(), fileName);
javax.xml.transform.Result result = createBpelOutput(process.getTargetNamespace(), fileName);
if(result instanceof StreamResult) {
final OutputStream outstream = ((StreamResult)result).getOutputStream();
URI uri = URI.createPlatformResourceURI(fileName);
BPELResource resource = (org.eclipse.bpel.model.resource.BPELResource)brsf.createResource(uri);
fixPartnerLinkPrefixes(resource,process,namespacePrefix);
resource.getContents().add(process);
HashSet<XSDSchema> schemaDeps = processSchemaDeps.get(process);
for (XSDSchema schema : schemaDeps){
resource.getPrefixToNamespaceMap().put(schemaNsPrefixMap.get(schema.getTargetNamespace()), schema.getTargetNamespace());