public void runCAML2TOSCATypes(URI camlProfile, String toscaModelPath) throws IOException { ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv(); ResourceSet rs = new ResourceSetImpl(); rs.getPackageRegistry().put(ToscaPackage.eINSTANCE.getNsURI(), ToscaPackage.eINSTANCE); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl()); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new XMIResourceFactoryImpl()); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd", new XMLResourceFactoryImpl()); rs.getPackageRegistry().put(UMLPackage.eINSTANCE.getNsURI(), UMLPackage.eINSTANCE); rs.getResourceFactoryRegistry().getExtensionToFactoryMap() .put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); ToscaUtil.init(rs, "model/"); // TODO: Maybe there is a better solution for 'resetting' the extended metadata // We changed the annotation already in the tosca.ecore EClassifierExtendedMetaData.Holder holder = (EClassifierExtendedMetaData.Holder)ToscaPackage.eINSTANCE.getDefinitionsType(); EClassifierExtendedMetaData result = holder.getExtendedMetaData(); result.setName("Definitions"); // Load metamodels Metamodel umlMM = EmftvmFactory.eINSTANCE.createMetamodel(); umlMM.setResource(rs.getResource(URI.createURI("http://www.eclipse.org/uml2/4.0.0/UML"), true)); env.registerMetaModel("UMLMM", umlMM); Metamodel toscaMM = EmftvmFactory.eINSTANCE.createMetamodel(); toscaMM.setResource(rs.getResource(URI.createURI("http://docs.oasis-open.org/tosca/ns/2011/12"), true)); env.registerMetaModel("TOSCA", toscaMM); // ##### INPUT Models ##### // the CAML library Model cL = EmftvmFactory.eINSTANCE.createModel(); URI libraryURI = URI.createPlatformPluginURI("eu.artist.migration.caml", true); libraryURI = libraryURI.appendSegments(new String[]{"umllibraries", "CAMLLibrary.uml"}); cL.setResource(rs.getResource(libraryURI, true)); env.registerInputModel("CL", cL); // the CAML profile Model cP = EmftvmFactory.eINSTANCE.createModel(); cP.setResource(rs.getResource(camlProfile, true)); env.registerInputModel("CP", cP); // Model cCP = EmftvmFactory.eINSTANCE.createModel(); // profileURI = URI.createPlatformPluginURI("eu.artist.migration.caml", true); // profileURI = profileURI.appendSegments(new String[]{"umlprofiles", "CommonCloudProfile.profile.uml"}); // cCP.setResource(rs.getResource(profileURI, true)); // env.registerInputModel("CCP", cCP); // ##### OUTPUT Modles ##### // the TOSCA deployment model Model toscaM = EmftvmFactory.eINSTANCE.createModel(); toscaM.setResource(rs.createResource(URI.createFileURI(new File(toscaModelPath).getAbsolutePath()))); env.registerOutputModel("TM", toscaM); // Load and run module DefaultModuleResolver mr = new DefaultModuleResolver(moduleLocation, new ResourceSetImpl()); TimingData td = new TimingData(); env.loadModule(mr, typesTrafo); td.finishLoading(); env.run(td); td.finish(); toscaM.getResource().save(Collections.emptyMap()); }
public void runCAML2TOSCATemplates(String camlModelPath, String toscaModelPath) throws IOException { ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv(); ResourceSet rs = new ResourceSetImpl(); rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new XMIResourceFactoryImpl()); rs.getPackageRegistry().put(ToscaPackage.eINSTANCE.getNsURI(), ToscaPackage.eINSTANCE); rs.getPackageRegistry().put(UMLPackage.eINSTANCE.getNsURI(), UMLPackage.eINSTANCE); rs.getResourceFactoryRegistry().getExtensionToFactoryMap() .put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); ToscaUtil.init(rs, "model/"); // TODO: Maybe there is a better solution for 'resetting' the extended metadata // We changed the annotation already in the tosca.ecore EClassifierExtendedMetaData.Holder holder = (EClassifierExtendedMetaData.Holder)ToscaPackage.eINSTANCE.getDefinitionsType(); EClassifierExtendedMetaData result = holder.getExtendedMetaData(); result.setName("Definitions"); // Load metamodels Metamodel umlMM = EmftvmFactory.eINSTANCE.createMetamodel(); umlMM.setResource(rs.getResource(URI.createURI("http://www.eclipse.org/uml2/4.0.0/UML"), true)); env.registerMetaModel("UMLMM", umlMM); Metamodel toscaMM = EmftvmFactory.eINSTANCE.createMetamodel(); toscaMM.setResource(rs.getResource(URI.createURI("http://docs.oasis-open.org/tosca/ns/2011/12"), true)); env.registerMetaModel("TOSCA", toscaMM); // ##### INPUT Models ##### // the CAML deployment model Model umlM = EmftvmFactory.eINSTANCE.createModel(); // umlM.setResource(rs.getResource(URI.createURI(camlModelPath, true), true)); umlM.setResource(rs.getResource(URI.createFileURI(new File(camlModelPath).getAbsolutePath()), true)); env.registerInputModel("UMLM", umlM); // the CAML library Model cL = EmftvmFactory.eINSTANCE.createModel(); URI libraryURI = URI.createPlatformPluginURI("eu.artist.migration.caml", true); libraryURI = libraryURI.appendSegments(new String[]{"umllibraries", "CAMLLibrary.uml"}); cL.setResource(rs.getResource(libraryURI, true)); env.registerInputModel("CL", cL); // the CAML platfrom library // Model cPL = EmftvmFactory.eINSTANCE.createModel(); // libraryURI = URI.createPlatformPluginURI("eu.artist.migration.caml.operatingenvironments", true); // libraryURI = libraryURI.appendSegments(new String[]{"umllibraries", "webOperatingEnvironment.uml"}); // cPL.setResource(rs.getResource(libraryURI, true)); // env.registerInputModel("CPL", cPL); // the CAML profile Model cP = EmftvmFactory.eINSTANCE.createModel(); URI profileURI = URI.createPlatformPluginURI("eu.artist.migration.caml", true); // profileURI = profileURI.appendSegments(new String[]{"umlprofiles", "GoogleAppEngineProfile.profile.uml"}); // profileURI = profileURI.appendSegments(new String[]{"umlprofiles", "AmazonAWSProfile.profile.uml"}); profileURI = profileURI.appendSegments(new String[]{"umlprofiles", "OpenStackProfile.profile.uml"}); cP.setResource(rs.getResource(profileURI, true)); env.registerInputModel("CP", cP); Model cCP = EmftvmFactory.eINSTANCE.createModel(); profileURI = URI.createPlatformPluginURI("eu.artist.migration.caml", true); profileURI = profileURI.appendSegments(new String[]{"umlprofiles", "CommonCloudProfile.profile.uml"}); cCP.setResource(rs.getResource(profileURI, true)); env.registerInputModel("CCP", cCP); // ##### OUTPUT Modles ##### // the TOSCA deployment model Model toscaM = EmftvmFactory.eINSTANCE.createModel(); toscaM.setResource(rs.createResource(URI.createFileURI(new File(toscaModelPath).getAbsolutePath()))); env.registerOutputModel("TM", toscaM); // Load and run module DefaultModuleResolver mr = new DefaultModuleResolver(moduleLocation, new ResourceSetImpl()); TimingData td = new TimingData(); env.loadModule(mr, templatesTrafo); td.finishLoading(); env.run(td); td.finish(); toscaM.getResource().save(Collections.emptyMap()); }
@Override public void setExtendedMetaData( EClassifierExtendedMetaData eClassifierExtendedMetaData) { // TODO Auto-generated method stub }
@Override public EClassifierExtendedMetaData getExtendedMetaData() { // TODO Auto-generated method stub return null; }
@Override public EClassifierExtendedMetaData getExtendedMetaData() { return eClassifierExtendedMetaData; }
@Override public void setExtendedMetaData(EClassifierExtendedMetaData eClassifierExtendedMetaData) { this.eClassifierExtendedMetaData = eClassifierExtendedMetaData; }