Skip to main content



      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 02:53 Go to next message
Eclipse UserFriend
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 04:39 Go to previous messageGo to next message
Eclipse UserFriend
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 04:53 Go to previous messageGo to next message
Eclipse UserFriend
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 06:25 Go to previous message
Eclipse UserFriend
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()
Previous Topic:AQL problem in "includes"/"excludes" functions?
Next Topic:How to disable palette
Goto Forum:
  


Current Time: Fri Jun 20 19:40:45 EDT 2025

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

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

Back to the top