/** SOA2WSDL sample transformation script by Istvan Rath @id soa2wsdl @name SOA2WSDL VIATRA2 transformation script @description Transforms SOA-tagged UML2 models into WSDL description files @function soa2wsdl Executes the transformation @param soa2wsdl umlFileName The absolute path to the UML file to read from @param soa2wsdl outputDirectory The absolute path of the output directory to write files to (can be null; in that case, output is posted to the blackboard) */ function soa2wsdl(umlFileName, outputDirectory) { viatra = sCore.findToolByName("Viatra").getServiceInterface(); vU = sCore.findToolByName("vUtil").getServiceInterface(); fw = viatra.createFramework(); print("Loading VPML modelspace..."); vpml = vU.getInputStream(vU.getFileFromBundle("hu.bme.mit.viatra.integration.sensoria","model/uml2soa_clean.vpml")); viatra.mergeVPML(fw,vpml); print("done.\n"); print("Importing UML model..."); umlmodel_file = vU.getFile(umlFileName); /* umlmodel_file = sCore.retrieveFromBoardByToolId("hu.bme.mit.viatra.integration.sensoria.utility.UtilityTool"); */ /* umlmodel_file = vU.getFileFromWorkspace(viatra.getOption("file_to_import")); */ /* umlmodel_file = umlmodel_file.toArray()[0]; */ /* WARNING: can be used only once!!! */ /* umlmodel = vU.getFileFromWorkspace("demonstrator_vpm2soa/AutomotiveSpec/export/OnRoadRepair.uml"); */ viatra.nativeImportFromFile(fw,umlmodel_file,"uml"); print("done.\n"); print("Running transformation on '"); /* extract model name */ /* umlmodel = viatra.getOption("file_to_import"); */ umlmodel = umlFileName.substring(umlFileName.lastIndexOf("/")+1, umlFileName.lastIndexOf(".")); print(umlmodel+"_uml' ..."); result = viatra.runTransformation(fw,"transformations.uml2soa2wsdl","Model=uml2.models."+umlmodel+"_uml"); viatra.disposeFramework(fw); print("done.\n"); /* sCore.postToBoard(result); */ /* output_dir = viatra.getOption("output_directory"); */ output_dir = outputDirectory; for (ix in result.getBuffers().keySet().toArray()) { key = result.getBuffers().keySet().toArray()[ix]; if (key == "default") continue; print("Writing "+key+"..."); buffer = result.getBuffers().get(key); formatted = vU.formatXML(buffer); print("formatted..."); if (output_dir == null) { sCore.postToBoard(formatted); print("posted.\n"); } else { /* vU.writeStringToFile(formatted,vU.getFileFromWorkspace(output_dir+"/"+key)); */ vU.writeStringToFile(formatted,vU.getFile(output_dir+"/"+key)); print("written.\n"); } } }