/** Given a file containing the Eclipse UML2 Model returns the model */ public static Model getModel(String pathToModel){ //A collection of related persistent documents. ResourceSet set = new ResourceSetImpl(); //Register the UML Package set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); //Register the MARTE package set.getPackageRegistry().put(org.eclipse.papyrus.MARTE.MARTE_Foundations.Time.TimePackage.eNS_URI, org.eclipse.papyrus.MARTE.MARTE_Foundations.Time.TimePackage.eINSTANCE); set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.PROFILE_FILE_EXTENSION, UMLResource.Factory.INSTANCE); //Define Location for marte set.getURIConverter().getURIMap().put(URI.createURI("pathmap://Papyrus_PROFILES/MARTE.profile.uml"), URI.createFileURI(new File("input/MARTE.profile.uml").getAbsolutePath())); //Add the model file to the resource set URI uri = URI.createFileURI(pathToModel); set.createResource(uri); Resource r = set.getResource(uri, true); LOGGER.info("Printing the content of the model resouce"); for(EObject o: r.getContents()){ LOGGER.info(o); EcoreUtil.resolveAll(o); } Model m=(Model)EcoreUtil.getObjectByType(r.getContents(), UMLPackage.eINSTANCE.getModel()); return m; }