Hi,
I want to use the EMF for Code Generation, so I wrote some methods to load my UML2 File which I generated myself. This works fine with the following code:
protected void registerResources() {
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
String resourcesJarPath = Thread.currentThread().getContextClassLoader().getResource("org.eclipse.uml2.uml.resources_2.2.0.v200805131030").toExternalForm();
URI baseUri = URI.createURI(resourcesJarPath);
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), baseUri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), baseUri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), baseUri.appendSegment("profiles").appendSegment(""));
}
public Package loadPackage(URI uri) {
Resource resource = resourceSet.getResource(uri, true);
return (Package) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE);
}
But now, I wanted to export an Magicdraw-Domainmodel to an EMF UML2 XMI, and there I get 5 Files. One project.uml and 4 Profile Files (UML_Standard_Profile.MagicDraw_Profile.DSL_Customization.profile.uml, UML_Standard_Profile.MagicDraw_Profile.profile.uml, UML_Standard_Profile.UML_Standard_Profile.profile.uml, UML_Standard_Profile.Validation_Profile.profile.uml). So if I want to load the project.uml with the loadPackageclass, my Package is null.
Does anyone have an example app, how to load an MagicDraw-exported UML DomainModel?
Dominik