Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Problem in navigating references
Problem in navigating references [message #1753306] Fri, 03 February 2017 16:00 Go to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
The figure below is part of my meta-model. If I should not change the meta-model,
https://www.eclipse.org/forums/index.php?t=getfile&id=28333&
1. How can I reach "D" from "B"?
2. How can I reach "targets" from "source"?
3. How can I navigate from "C" to "A"?
  • Attachment: Untitled.jpg
    (Size: 10.38KB, Downloaded 581 times)


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Fri, 03 February 2017 16:05]

Report message to a moderator

Re: Problem in navigating references [message #1753315 is a reply to message #1753306] Fri, 03 February 2017 17:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

1: aB.A[source].body
2: aB.A[source].target
3: aC.oclAsType(A)

.A is an implicit opposite, which in your case is ambiguous. Not many tools support the [source] disambiguation.

Your metamodel looks very smelly with two A containments of B. I hope their multiplicity is [0..1]. Since there is then alternate containment,you may need to use the non-null .A[source] or .A[target]. Or .oclContainer().oclAsType(A).

Regards

Ed Willink
Re: Problem in navigating references [message #1753317 is a reply to message #1753315] Fri, 03 February 2017 18:20 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Many thanks for your kind help.
Ed Willink wrote on Fri, 03 February 2017 17:47

.A is an implicit opposite, which in your case is ambiguous. Not many tools support the [source] disambiguation.

That means if I use it in my ATL transformation code, it doesn't work correctly?
What should I do?
Ed Willink wrote on Fri, 03 February 2017 17:47

Your metamodel looks very smelly with two A containments of B. I hope their multiplicity is [0..1]. Since there is then alternate containment,you may need to use the non-null .A[source] or .A[target]. Or .oclContainer().oclAsType(A).

The multiplicity of source is "1..1" and target is "1..*"
Does expressions need any change?

This is the part of a language meta-model that I change the class name for simplicity. In fact, "A" is "TransformationRule" and "B" is "FormalParameterExpression" (in-pattern and out-pattern of transformation).


Member of MDSE Research Group
http://mdse.ui.ac.ir
Re: Problem in navigating references [message #1753322 is a reply to message #1753317] Fri, 03 February 2017 20:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

In ATL you can probably do .eContainer().oclAsType(A). Otherwise report a bug.

I am questioning the multiplicities at the container end.

Regards

Ed Willink
Re: Problem in navigating references [message #1753324 is a reply to message #1753322] Fri, 03 February 2017 20:38 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Thank you very much.
Ed Willink wrote on Fri, 03 February 2017 20:05

In ATL you can probably do .eContainer().oclAsType(A). Otherwise report a bug.

That means, in ATL, my answers are:

1. B.eContainer().oclAsType(A).body
2. B.eContainer().oclAsType(A).target

?
Ed Willink wrote on Fri, 03 February 2017 20:05

I am questioning the multiplicities at the container end.

Yes, In action that multiplicity is 1 But not specify in the meta-model.


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Fri, 03 February 2017 20:42]

Report message to a moderator

Re: Problem in navigating references [message #1753329 is a reply to message #1753324] Fri, 03 February 2017 22:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

No. It cannot be [1..1]. If it was there would be a double container which is illegal in Ecore (and UML).

Regards

Ed Willink
Re: Problem in navigating references [message #1753351 is a reply to message #1753329] Sat, 04 February 2017 10:42 Go to previous messageGo to next message
Banafsheh Azizi is currently offline Banafsheh AziziFriend
Messages: 328
Registered: July 2016
Senior Member
Yes, I think I made a mistake about its multiplicity.

I have another question about this figure, if I have a class "E" which is inherited from "A", and I want to navigate from "C" to "E",

1. I should write aC.oclAsType(E) or aC.oclAsType(A).oclAsType(E)?
2. In ATL I should write "C" or "aC"?


Member of MDSE Research Group
http://mdse.ui.ac.ir

[Updated on: Sat, 04 February 2017 10:44]

Report message to a moderator

Re: Problem in navigating references [message #1753352 is a reply to message #1753351] Sat, 04 February 2017 11:27 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
1 oclAsType() is just like a cast in Java, cast to what you want.
2 Without an example I cannot comment on whether you write C or aC. I informally use C as the type, aC as an instance,

Regards

Ed Willink
Previous Topic:collect equivalent for one element
Next Topic:Query to return Classes that use a given Enumeration
Goto Forum:
  


Current Time: Fri Apr 19 02:52:06 GMT 2024

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

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

Back to the top