Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to check Ecore type of element using AQL?
How to check Ecore type of element using AQL? [message #1841250] Fri, 07 May 2021 20:26 Go to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 83
Registered: March 2020
Member
Hello,

I have a class in my metamodel that has a relation based edge to multiple different types of classes. I am trying to specify one creation tool for it by using an if statement that with check the type of the target element in order to decide what type of feature to use to set the target value of the relation based edge. There doesn't seem to be a command that is available in AQL that will return the Ecore type as opposed to the OCL type and I was wondering if it is something that I will have to make custom or if I am missing some sort of obvious command here? Attached is a picture of my metamodel. The Constraint class is the one that has to different relation based edges in Data and Reference that I am trying to set.
index.php/fa/40475/0/
Re: How to check Ecore type of element using AQL? [message #1841255 is a reply to message #1841250] Sat, 08 May 2021 08:20 Go to previous messageGo to next message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 26
Registered: March 2018
Junior Member
Hi, I am not sure I understood 100% what you want to do, but how about:

If you want to check that the type is exactly "yourClass"
aql:target.oclIsTypeOf(yourNamespace::yourClass)


If you want to check that the target coerces to "yourClass" (i.e. it may be a subclass):
aql:target.oclIsKindOf(yourNamespace::yourClass)
Re: How to check Ecore type of element using AQL? [message #1841271 is a reply to message #1841255] Mon, 10 May 2021 15:00 Go to previous messageGo to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 83
Registered: March 2020
Member
No Message Body

[Updated on: Mon, 10 May 2021 15:07]

Report message to a moderator

Re: How to check Ecore type of element using AQL? [message #1841274 is a reply to message #1841271] Mon, 10 May 2021 15:31 Go to previous message
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 26
Registered: March 2018
Junior Member
Thomas Chiang wrote on Mon, 10 May 2021 15:00

A follow up question to this now is how do I check a boolean attribute of said class. If it was self I could just type feature:check but since I am trying to check the target node for the feature I am assuming that it would be something along the lines of aql:target.feature.check but there isn't an option for that. How do I access the attributes of a target node in an if statement like that?

Assumed that you have "yourVariable" which is an instance of a class with a [0,1 ] Reference called "target", which leads to a class with a EBoolean attribute called "yourBooleanProperty":

aql:yourVariable.target.yourBooleanProperty



if by "there isn't an option" you mean that the autocomplete does not fill it in, you can use:
yourVariable.oclAsType(namespace::yourClassWithTarget).target.yourBooleanProperty

(and you can use oclAsType also after target, if needed).
Previous Topic:Dialog box on Save All on Eclipse 2021-03
Next Topic:Container drop and container creation
Goto Forum:
  


Current Time: Sun Sep 25 21:44:23 GMT 2022

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

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

Back to the top