Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [Solved][ATL] problem running ATL programmatically
icon7.gif  [Solved][ATL] problem running ATL programmatically [message #831701] Thu, 29 March 2012 08:17 Go to next message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
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]

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 Go to previous messageGo to next message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
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]

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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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
icon14.gif  Re: [ATL] problem running ATL programmatically [message #831825 is a reply to message #831763] Thu, 29 March 2012 11:57 Go to previous message
david borsodi is currently offline david borsodiFriend
Messages: 19
Registered: July 2009
Junior Member
Thanks for the response Ed!
It did the trick. I also noticed a mistake of mine causing problems.

david

[Updated on: Thu, 29 March 2012 11:57]

Report message to a moderator

Previous Topic:[Solved][ATL] string concat operation OclUndefined ???
Next Topic:Invoke QVT In JAVA
Goto Forum:
  


Current Time: Tue Apr 23 07:53:13 GMT 2024

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

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

Back to the top