Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Getting to the "root" element by AQL query
Getting to the "root" element by AQL query [message #1823331] Wed, 25 March 2020 06:53 Go to next message
Avi Shaked is currently offline Avi ShakedFriend
Messages: 116
Registered: October 2019
Senior Member
Hi,

I wish to get to the root element in my model. I know I can apply ancestors()->last(), but this does not work on the root element itself (I want to keep the query generic, so that in case the selected element is the root element then it will also be selected).

Any advice?
Re: Getting to the "root" element by AQL query [message #1823335 is a reply to message #1823331] Wed, 25 March 2020 08:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6874
Registered: July 2009
Senior Member
Hi

How about ancestors()->prepend(self)->last() or of course something involving an if test for isEmpty(), or a closure() of eContainer().

Regards

Ed Willink
Re: Getting to the "root" element by AQL query [message #1823336 is a reply to message #1823335] Wed, 25 March 2020 08:53 Go to previous messageGo to next message
Avi Shaked is currently offline Avi ShakedFriend
Messages: 116
Registered: October 2019
Senior Member
Thanks Ed!

I actually did something similar, but I thought there might be a simpler syntax.

I also tried using self.eResource().getContents(), which seemed to work, but when I used it for changing context it did not.

Regards,
Avi
Re: Getting to the "root" element by AQL query [message #1823344 is a reply to message #1823336] Wed, 25 March 2020 10:25 Go to previous message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 544
Registered: July 2009
Senior Member
An EMF resource can have multiple root elements, so getContents() retruns a list, which would not work with "Change Context". If in your case you know there is a single root element you can getContents()->first()

Pierre-Charles David - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:AQL problem in "includes"/"excludes" functions?
Next Topic:How to disable palette
Goto Forum:
  


Current Time: Sat Oct 24 09:30:45 GMT 2020

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

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

Back to the top