[ATL] Using own model implementation instances instead of DynamicEObjImpl as in/output [message #697901] |
Mon, 18 July 2011 06:08  |
Eclipse User |
|
|
|
Hello,
I am experimenting with ATL these days. As far as I understood the input and the output of a transformation is an XMIResourceImpl instance. I have as input the instance of my source metamodel and I also need as output an instance of the target metamodel and not DynamicEObjectImpl instances. Is there an elegant way to do this? How can I make the conversion between DynamicEObjImpl instances and "MyModelImpl" instances?
Thanks,
Eszter
|
|
|
|
Re: [ATL] Using own model implementation instances instead of DynamicEObjImpl as in/output [message #698404 is a reply to message #698018] |
Tue, 19 July 2011 08:32   |
Eclipse User |
|
|
|
Hi,
for launching the transformation I am using the main method generated by the New > ATL Plugin Wizard.
In the method loadModels I registered my packages:
public void loadModels(String inModelPath) throws ATLCoreException {
ModelFactory factory = new EMFModelFactory();
ResourceSet resourceSet = factory.getResourceSet();
Registry registry = factory.getResourceSet().getPackageRegistry();
Map<String, Object> extMap = resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
extMap.put("ecore", new EcoreResourceFactoryImpl()); //$NON-NLS-1$
extMap.put("cache", new CacheResourceFactoryImpl());
extMap.put("om", new OMResourceFactoryImpl());
CachePackage.eINSTANCE.eClass();
OmPackage.eINSTANCE.eClass();
registry.put(CachePackage.eNS_URI, CachePackage.eINSTANCE);
registry.put(OmPackage.eNS_URI, OmPackage.eINSTANCE);
// the generated code
IInjector injector = new EMFInjector();
IReferenceModel cacheMetamodel = factory.newReferenceModel();
injector.inject(cacheMetamodel, getMetamodelUri("cache"));
IReferenceModel omMetamodel = factory.newReferenceModel();
injector.inject(omMetamodel, getMetamodelUri("om"));
this.inModel = factory.newModel(cacheMetamodel);
injector.inject(inModel, inModelPath);
this.outModel = factory.newModel(omMetamodel);
}
Now loading works fine, but as result I still get DynamicEObjImpl instances.
I also tried to register my packages to the global package registry, but the result didn't change.
What else am I missing?
Eszter
|
|
|
Re: [ATL] Using own model implementation instances instead of DynamicEObjImpl as in/output [message #698537 is a reply to message #698404] |
Tue, 19 July 2011 12:08   |
Eclipse User |
|
|
|
What's the nsURI of the model for which you're ending up with dynamic
instances, i.e., what's the value of
eObject.eClass().getEPackage().getNsURI() for the problematic
instance? Is that URI registered?
On 19/07/2011 5:32 AM, Eszter Hofmann wrote:
> Hi,
>
> for launching the transformation I am using the main method generated
> by the New > ATL Plugin Wizard.
> In the method loadModels I registered my packages:
> public void loadModels(String inModelPath) throws ATLCoreException {
> ModelFactory factory = new EMFModelFactory();
> ResourceSet resourceSet = factory.getResourceSet();
> Registry registry = factory.getResourceSet().getPackageRegistry();
>
> Map<String, Object> extMap =
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap();
> extMap.put("ecore", new EcoreResourceFactoryImpl()); //$NON-NLS-1$
> extMap.put("cache", new CacheResourceFactoryImpl());
> extMap.put("om", new OMResourceFactoryImpl());
>
> CachePackage.eINSTANCE.eClass();
> OmPackage.eINSTANCE.eClass();
>
> registry.put(CachePackage.eNS_URI, CachePackage.eINSTANCE);
> registry.put(OmPackage.eNS_URI, OmPackage.eINSTANCE);
>
> // the generated code
> IInjector injector = new EMFInjector();
> IReferenceModel cacheMetamodel = factory.newReferenceModel();
> injector.inject(cacheMetamodel, getMetamodelUri("cache"));
> IReferenceModel omMetamodel = factory.newReferenceModel();
> injector.inject(omMetamodel, getMetamodelUri("om"));
> this.inModel = factory.newModel(cacheMetamodel);
> injector.inject(inModel, inModelPath);
> this.outModel = factory.newModel(omMetamodel);
> }
>
> Now loading works fine, but as result I still get DynamicEObjImpl
> instances.
> I also tried to register my packages to the global package registry,
> but the result didn't change.
> What else am I missing?
>
> Eszter
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09108 seconds