Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Loading a UML2 model exported with MagicDraw along with profiles
Loading a UML2 model exported with MagicDraw along with profiles [message #628200] Wed, 20 January 2010 19:32
Luca  is currently offline Luca Friend
Messages: 6
Registered: October 2009
Junior Member
I'm trying to execute an atl transformation in a standalone application (clearly it works fine in eclipse...), using eclipse modeling 3.5, atl 3.0.0, uml 2.0.0 and emf 2.2.0 (the last two because the exported EMF UML2 (v.2.x) XMI models from MagicDraw 16.6 have the xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML").

I have created a java project following the "new" approach for ATL ( http://wiki.eclipse.org/ATL/Developer_Guide#ATL_Architecture and http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/examples/org.eclipse.m2m.atl.examples.publi c2private.ui/src/org/eclipse/m2m/atl/examples/public2private /ui/PrivatizeAction.java?root=Modeling_Project&view=mark up), namely using these imports:

import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IExtractor;
import org.eclipse.m2m.atl.core.IInjector;
import org.eclipse.m2m.atl.core.IModel;
import org.eclipse.m2m.atl.core.IReferenceModel;
import org.eclipse.m2m.atl.core.ModelFactory;
import org.eclipse.m2m.atl.core.emf.EMFExtractor;
import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.core.service.CoreService;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.UMLPackage;
import org.eclipse.uml2.uml.resource.UMLResource;

I first register the package (schema), the resource factory, and the "pathmaps" for UML:
resourceSet = new ResourceSetImpl();
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();
String umlResourcesFile = new File(
"lib/org.eclipse.uml2.uml.resources_2.0.0.v200606221411.jar").getAbsolutePath();
URI uri = URI.createURI("jar:file://" + umlResourcesFile +"!/");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));

then the EMF's stuff:
CoreService.registerLauncher(new EMFVMLauncher());
CoreService.registerFactory("EMF", EMFModelFactory.class);
factory = CoreService.createModelFactory("EMF");
CoreService.registerExtractor("EMF", new EMFExtractor());
CoreService.registerInjector("EMF", new EMFInjector());
injector = CoreService.getInjector("EMF");
extractor = CoreService.getExtractor("EMF");

I load the metamodels (UML 2.0.0 and Persons, actually it's a pure example):
umlMetamodel = factory.newReferenceModel();
injector.inject(umlMetamodel, "http://www.eclipse.org/uml2/2.0.0/UML");
outputMetamodel = factory.newReferenceModel();
injector.inject(outputMetamodel, new File(metamodelsPath + "Persons.ecore").getAbsolutePath());

Then the input model:
umlModel = factory.newModel(umlMetamodel);
injector.inject(umlModel, (new File(modelsPath + "input_model.uml").getAbsolutePath()));

In this last line, I obtain the following exception:
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http:///schemas/MagicDrawProfile/_yTCU4AHvEd-Q248yC_s0OA/0' not found.
pointing at the bottom of the model file at the end of this line (the last in the file):
<MagicDrawProfile:auxiliaryResource xmi:id="_yZNOUgHvEd-Q248yC_s0OA" base_Element="magicdraw_uml_standard_profile_v_0001" base_Package="magicdraw_uml_standard_profile_v_0001"/>,
while at the top the namespace is:
xmlns:MagicDrawProfile="http:///schemas/MagicDrawProfile/_yTCU4AHvEd-Q248yC_s0OA/0"
and the schemaLocation:
xsi:schemaLocation="http:///schemas/MagicDrawProfile/_yTCU4AHvEd-Q248yC_s0OA/0 UML_Standard_Profile.MagicDraw_Profile.profile.uml#_yTQXUgHv Ed-Q248yC_s0OA "

I imagine this is related to the 4 profiles that are applied in the model (MagicDraw applies them, so I have the 4 files‪: UML_Standard_Profile.MagicDraw_Profile.DSL_Customization.pro file.uml, UML_Standard_Profile.MagicDraw_Profile.profile.uml, UML_Standard_Profile.UML_Standard_Profile.profile.uml, UML_Standard_Profile.Validation_Profile.profile.uml).

I suppose their nsURI are not automatically resolved, so my question is how to register them properly (I tried to follow http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_register_ a_dynamic_package.3F, but without success...I think I miss something...)?

Thanks in advance

Luca
Previous Topic:Loading a UML2 model exported with MagicDraw along with profiles
Next Topic: getting all attributes
Goto Forum:
  


Current Time: Thu Apr 25 20:15:21 GMT 2024

Powered by FUDForum. Page generated in 0.03203 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top