[Solved][ATL] problem running ATL programmatically [message #831701] |
Thu, 29 March 2012 08:17  |
Eclipse User |
|
|
|
I followed the example and managed to load the models and finally run the atl vm from the code, but there is some internal problem.
in ASMEMFModel.initClassifiers DynamicEObjectImpl is not handled properly, but the loader code initialized my model as a DynaimcEObjectImpl
this is how I loaded it:
ASMEMFModel dbModel = (ASMEMFModel) loader.loadModel("db", loader.getMOF(), new FileInputStream(parentPath + "/mo.ecore"));
Is there any way to force the loader to not handle the model as a DynaimcEobject?
Is this a bug, anyway?
I can run the transformation from eclipse with the ATL profile. With exaclty the same models and metamodels...
I hope someone is here who can answer...
[Updated on: Thu, 29 March 2012 11:57] by Moderator Report message to a moderator
|
|
|
Re: [ATL] problem running ATL programmatically [message #831740 is a reply to message #831701] |
Thu, 29 March 2012 09:21   |
Eclipse User |
|
|
|
I made a quick fix: (the fix is in bold)
private void initClassifiers(Iterator i, Map allClassifiers, String base) {
for ( ; i.hasNext();) {
EObject eo = (EObject)i.next();
if (eo instanceof EPackage) {
String name = ((EPackage)eo).getName();
if (base != null) {
name = base + "::" + name;
}
initClassifiers(((EPackage)eo).eContents().iterator(), allClassifiers, name);
} else if (eo instanceof EClassifier) {
String name = ((EClassifier)eo).getName();
// register the classifier under its simple name
register(allClassifiers, name, eo);
if (base != null) {
name = base + "::" + name;
// register the classifier under its full name
register(allClassifiers, name, eo);
}
}else if(eo instanceof DynamicEObjectImpl) {
initClassifiers(((DynamicEObjectImpl)eo).eClass().getEPackage().eContents().iterator(), allClassifiers, base)
} else {
// No meta-package or meta-class => just keep digging.
// N.B. This situation occurs in UML2 profiles, where
// EPackages containing EClasses are buried somewhere
// underneath other elements.
initClassifiers(eo.eContents().iterator(), allClassifiers, base);
}
}
}
I just don't know how can I repackage and try it, any help welcome, and also any suggestions about this fix.
[Updated on: Thu, 29 March 2012 09:21] by Moderator Report message to a moderator
|
|
|
Re: [ATL] problem running ATL programmatically [message #831763 is a reply to message #831701] |
Thu, 29 March 2012 09:56   |
Eclipse User |
|
|
|
Hi David
On 29/03/2012 04:17, david borsodi wrote:
> I followed the example and managed to load the models and finally run
> the atl vm from the code, but there is some internal problem.
> in ASMEMFModel.initClassifiers DynamicEObjectImpl is not handled
> properly, but the loader code initialized my model as a
> DynaimcEObjectImpl
>
> this is how I loaded it:
> ASMEMFModel dbModel = (ASMEMFModel) loader.loadModel("db",
> loader.getMOF(), new FileInputStream(parentPath + "/mo.ecore"));
>
> Is there any way to force the loader to not handle the model as a
> DynaimcEobject?
> Is this a bug, anyway?
No. It is a demonstration of EMF's polymorphism.
Registered packages use compiled objects.
Unregistered packages use DynamicEObject.
Try registering Ecore.
Globally as:
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
Locally as:
....getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore",
new EcoreResourceFactoryImpl());
Regards
Ed Willink
|
|
|
|
Powered by
FUDForum. Page generated in 0.07657 seconds