Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » aql:eAllContents(packageName::eClassName)
aql:eAllContents(packageName::eClassName) [message #1744079] Thu, 22 September 2016 08:58 Go to next message
Emil Jenotte is currently offline Emil JenotteFriend
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 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 705
Registered: July 2009
Senior Member
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 #1744169 is a reply to message #1744083] Fri, 23 September 2016 06:48 Go to previous messageGo to next message
Emil Jenotte is currently offline Emil JenotteFriend
Messages: 25
Registered: September 2016
Junior Member
Hello Pierre-Charles,

thank you for you reply.
I actually have tried exactly what you suggested right from the beginning:
aql:self.eResource().getContents().eAllContents(mypackagename::EClassNameToLookFor)

That s exactly what does not work in my .odesign file.
I can work around this by

aql:self.eResource().getContents().eContents().eClassNameToLookForReference

So I just get all the parents of my ClassToLookFor and then call all their references from parent to the ClassToLookFor. But I thought the first version would be better, as a reference might change with a higher chance, when developing my model, than that Class/Package names change. It was a thought of easy expandability.

But I still find it weird, that the expression eAllContents(packageName::eClassName) does not work. The simple eAllContents() works.

Cheers
Emil
Re: aql:eAllContents(packageName::eClassName) [message #1744179 is a reply to message #1744169] Fri, 23 September 2016 08:08 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 705
Registered: July 2009
Senior Member
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 #1744183 is a reply to message #1744179] Fri, 23 September 2016 08:39 Go to previous messageGo to next message
Emil Jenotte is currently offline Emil JenotteFriend
Messages: 25
Registered: September 2016
Junior Member
Hello Pierre-Charles,

thank you!
That was what I was missing. Now it works perfectly! Thank you!

Cheers
Emil
Re: aql:eAllContents(packageName::eClassName) [message #1745175 is a reply to message #1744183] Thu, 06 October 2016 02:20 Go to previous messageGo to next message
Emil Jenotte is currently offline Emil JenotteFriend
Messages: 25
Registered: September 2016
Junior Member
Hello Pierre-Charles

I updated my meta model and did some changes in Sirius - and now my query does not work anymore.

My expression is:
aql:self.eClass().eResource().getContents().eAllContents(myPackageName::MyEEnumTypeName).eContents()

I am trying to use it in my Properties Views for getting the candidates for a drop down menu under Candidates Expression. I registered my metamodel in the VSM - at the Diagram under the tab Metamodels and also under the Properties Views Description under Metamodels. When trying to check it with the Sirius Interpreter on my created Instances, it does not work either and I get the following warning: could not find the 'eAllContents(EClassifier=EPackage, EClassifier=EEnum)'service. - But in the little tutorial/introduction [1] from Melanie Bats it is done the same (without the .eContents() - but that does not work for me either).

E.g., if i queriy eAllContents(ecore::EEnum), it works in terms of me getting all the enums of my metamodel.

Where am I wrong? Or what did I not consider?

Cheers
Emil

[1] http://melb.enix.org/sirius/let-me-sirius-that-for-you-properties-view/
Re: aql:eAllContents(packageName::eClassName) [message #1745185 is a reply to message #1745175] Thu, 06 October 2016 07:50 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 705
Registered: July 2009
Senior Member
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
Re: aql:eAllContents(packageName::eClassName) [message #1745202 is a reply to message #1745185] Thu, 06 October 2016 12:39 Go to previous message
Emil Jenotte is currently offline Emil JenotteFriend
Messages: 25
Registered: September 2016
Junior Member
Hello Pierre-Charles,

thank you for your fast reply.
So, am I right, that the only option to get my MyEEnumType, is to insert in my Cadidates Expression something like:

aql:self.eClass().eResource().getContents().eAllContents(ecore::EEnum)->select(s|s.name.equals('MyEEnumTypeName')).eContents()

So I have to go over the name and can not call directly my desired MyEEnumType?
I mean, the above stated query works.

Cheers
Emil
Previous Topic:The problem with the commands Copy / Paste
Next Topic:Reconnect Edge with ReconnectSourceNodeCommand
Goto Forum:
  


Current Time: Sat Sep 21 01:25:19 GMT 2024

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

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

Back to the top