aql:eAllContents(packageName::eClassName) [message #1744079] |
Thu, 22 September 2016 08:58 |
Emil Jenotte Messages: 25 Registered: September 2016 |
Junior Member |
|
|
Hello,
when I try any aql-command that involves at any place:
eAllContents(mypackagename::EClassNameToLookFor)
It works, when I try the command out in the Sirius Interpreter letting it run over my MyTry.projectname file.
But it does not work, when I insert in in the desired place in my projectname.odesign file.
Why? Is it not possible?
I just want to have a collection of all existing objects of a certain class.
Cheers
Emil
[Updated on: Thu, 22 September 2016 08:59] Report message to a moderator
|
|
|
Re: aql:eAllContents(packageName::eClassName) [message #1744083 is a reply to message #1744079] |
Thu, 22 September 2016 09:19 |
|
Hi.
eAllContents(mypackagename::EClassNameToLookFor) does not give you all existing objects of a certain class, but all objects of a certain class contained in the current element (on which the AQL expression is invoked). What probably happens is that in the case of the Sirius Interpreter, you evaluate it on the whole resource, so it finds all existing instances inside that. But each expression defined in the VSM (the .odesign) will be evaluated in the context of a specific model element (which one depends on each case; refer to the documentation), and in you case no instance of EClassNameToLookFor exists *inside* that element. If you really want all the instances existing in a given resource (or on the whole session), you must first navigate from the current element to the resource. Something like this (untested):
aql:self.eResource().getContents().eAllContents(mypackagename::EClassNameToLookFor)
See https://www.eclipse.org/acceleo/documentation/ for more details about AQL.
Note that eAllContents() can be a costly operation, so this kind of pattern should be reserved for the cases where there is really no better way to identify the elements of interest.
Regards,
Pierre-Charles
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Re: aql:eAllContents(packageName::eClassName) [message #1744179 is a reply to message #1744169] |
Fri, 23 September 2016 08:08 |
|
Have you registered your metamodels in the VSM? It's configured in the "Metamodels" tab of each representation in your .odesign. If it's not there, the AQL runtime might not have the information about which metamodels to take into account, which could explain that it does not understand "packageName::eClassName" in your expression. The interpreter runtime used in the "Interpreter" view is configured a little differently and knows about all the installed metamodels, which explains why the expression works in that context.
Regards,
Pierre-Charkes
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
Re: aql:eAllContents(packageName::eClassName) [message #1745185 is a reply to message #1745175] |
Thu, 06 October 2016 07:50 |
|
Quote:
aql:self.eClass().eResource().getContents().eAllContents(myPackageName::MyEEnumTypeName).eContents()
The ".eClass()" seems wrong. From your model element, it will return an EClass, i.e. an element from you metamodel definition itself. After that, the rest of the query is executed in the context of your Ecore metamodel, not on your model instance. So it's asking for instances of the MyEEnumTypeName type inside an EPackage. The package may define the MyEEnumTypeName type, but will never contains instances of it.
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.04316 seconds