Skip to main content



      Home
Home » Modeling » OCL » Problem in navigating references
Problem in navigating references [message #1753306] Fri, 03 February 2017 11:00 Go to next message
Eclipse UserFriend
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 642 times)

[Updated on: Fri, 03 February 2017 11:05] by Moderator

Re: Problem in navigating references [message #1753315 is a reply to message #1753306] Fri, 03 February 2017 12:47 Go to previous messageGo to next message
Eclipse UserFriend
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 13:20 Go to previous messageGo to next message
Eclipse UserFriend
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).
Re: Problem in navigating references [message #1753322 is a reply to message #1753317] Fri, 03 February 2017 15:05 Go to previous messageGo to next message
Eclipse UserFriend
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 15:38 Go to previous messageGo to next message
Eclipse UserFriend
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.

[Updated on: Fri, 03 February 2017 15:42] by Moderator

Re: Problem in navigating references [message #1753329 is a reply to message #1753324] Fri, 03 February 2017 17:22 Go to previous messageGo to next message
Eclipse UserFriend
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 05:42 Go to previous messageGo to next message
Eclipse UserFriend
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"?

[Updated on: Sat, 04 February 2017 05:44] by Moderator

Re: Problem in navigating references [message #1753352 is a reply to message #1753351] Sat, 04 February 2017 06:27 Go to previous message
Eclipse UserFriend
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: Sat Apr 19 21:31:31 EDT 2025

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

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

Back to the top