Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Accessing referring elements?
Accessing referring elements? [message #1853187] Wed, 22 June 2022 09:16 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi all,

Is it possible to access an ecore element's referring elements? For example, I have a reference relation like this A -> (reference relation) B-> (reference relation) C. Starting from element C, how can I travel through to element A?

Thank you.

Best regards.
Re: Accessing referring elements? [message #1853316 is a reply to message #1853187] Mon, 27 June 2022 17:29 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

You can only do this directly if the reference relationship in question is a containment relation: in that case, you can use refImmediateComposite() to navigate back to the containing element.

If your reference is not a containment reference, you can still use the object indexing pattern, for example:
--- Store all inverse values for MM!B::reference
helper def : bByReference : Map(MM!C, MM!B) =
   MM!B.allInstances()->mappedBySingle(b | b.reference);

--- Define a helper attribute on MM!C for the inverse of MM!B::reference
helper context MM!C def : inverseReference : MM!B =
  thisModule.bByReference.get(self);


Cheers,
Dennis
Re: Accessing referring elements? [message #1853461 is a reply to message #1853316] Sun, 03 July 2022 08:52 Go to previous message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Hi Dennis,

Thank you for your help. I saved this one into my examples. Could you please help me with this problem https://www.eclipse.org/forums/index.php/m/1853462/#msg_1853462

Best regards.

[Updated on: Sun, 03 July 2022 09:03]

Report message to a moderator

Previous Topic:Is this an ATL bug?
Next Topic:Collecting all instances and calculating the values
Goto Forum:
  


Current Time: Sat Nov 11 08:17:04 GMT 2023

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

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

Back to the top