Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Access unnavigable opposites of reference and composition relations in Ecore
Access unnavigable opposites of reference and composition relations in Ecore [message #1697471] Thu, 04 June 2015 08:52 Go to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
Hi everyone,

I am working on a RCP application based on an Ecore meta-model. This application enables to edit a model according to business constraints written in OCL. I am new to the OCL subject.

The meta-model contains unidirectional relations, but the business constraints would need to access the container of a given object or the list of objects referencing a given object.

1) Is it possible ?

I have read the OCL FAQ (questions 2.3 and 2.4) and I am not sure to understand how to use these informations. The two bugs mentioned in 2.4 are marked as FIXED.

2) If it is possible, what is the correct syntax to access the parent/referencing objects ?

I created the simple Ecore meta-model represented in the attached file (Head containing Eye and referencing Heart). I tried to create a sample model, select the objects of this model and use the OCL consoles.

index.php/fa/22083/0/

3) Syntax self.oclAsType(ecore::EObject).eContainer() works as expected in the interactive OCL console but not in the interactive Xtext OCL console. Why ?

4) In both consoles, syntax self.head for a Eye or Heart object does not work. If I understand well question 2.4 of the FAQ, this is the syntax I should use. What did I miss ?

I am using OCL all-in-one SDK 5.0.4.

Thanks for your advice,

François

[Updated on: Thu, 04 June 2015 08:53]

Report message to a moderator

Re: Access unnavigable opposites of reference and composition relations in Ecore [message #1697480 is a reply to message #1697471] Thu, 04 June 2015 09:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

Comments inline.

On 04/06/2015 09:52, Francois Cabrol wrote:
> Hi everyone,
>
> I am working on a RCP application based on an Ecore meta-model. This application enables to edit a model according to business constraints.
>
> The meta-model contains unidirectional relations, but the business constraints would need to access the container of a given object or the list of objects referencing a given object.
>
> 1) Is it possible ?
Yes
>
> I have read the OCL FAQ (questions 2.3 and 2.4) and I am not sure to understand how to use these informations. The two bugs mentioned in 2.4 are marked as FIXED.
So much documentation to refresh. I've revised the FAQ.
>
> 2) If it is possible, what is the correct syntax to access the parent/referencing objects ?
>
> I created the simple Ecore meta-model represented in the attached file (Head containing Eye and referencing Heart). I tried to create a sample model, select the objects of this model and use the OCL consoles.
>
>
let anEye : Eye = ... in anEye.Head
>
>
> 3) Syntax self.oclAsType(ecore::EObject).eContainer() works as expected in the interactive OCL console but not in the interactive Xtext OCL console. Why ?
https://bugs.eclipse.org/bugs/show_bug.cgi?id=469371 raised.
>
> 4) In both consoles, syntax self.head for a Eye or Heart object does not work. If I understand well question 2.4 of the FAQ, this is the syntax I should use. What did I miss ?
>

let anEye : Eye = ... in anEye.Head

Regartds

Ed Willink
Re: Access unnavigable opposites of reference and composition relations in Ecore [message #1697784 is a reply to message #1697480] Mon, 08 June 2015 13:15 Go to previous messageGo to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
Thank you very much Ed !

But if I use the aforementioned example, and if I select an instance of Heart or Eye in one of my sample models then play with the OCL consoles, I get the following results:

Calling self.Head on a Eye object (containment reference)
In the interactive Xtext OCL console, I get the expected result (the containing Head object)
In the interactive OCL console, I get an error: Unrecognized variable: (Head)

Calling self.Head on a Heart object (non-containment reference)
In the interactive Xtext OCL console, I get an empty result
In the interactive OCL console, I get an error: Unrecognized variable: (Head)

Does it mean I can use syntax self.Head in my OCL business constraints ?

Thanks in advance,

François
Re: Access unnavigable opposites of reference and composition relations in Ecore [message #1697810 is a reply to message #1697784] Mon, 08 June 2015 14:55 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Today, in Luna, the Xtext functionality is part of the new 'examples'
quality Pivot-based OCL that prototypes solution for the OCL 2.5 submission.

On June 26, for Mars, the main 'examples' plugins are promoted to
non-'examples' and are the preferred OCL platform.

If you are interested in the future then you may go with what you see
with the Xtext console.

If you are interested in maximum portability, you should only use what
works on all relevant platforms; at least Dresden OCL and USE too.

Your choice, but as you can see that are many issues at the edge of OCL
where functionality is inadequately specified and consequently
inconsistently implemented. The sooner we get to OCL 2.5 the better.

Regards

Ed Willink


On 08/06/2015 14:15, Francois Cabrol wrote:
> Thank you very much Ed !
>
> But if I use the aforementioned example, and if I select an instance
> of Heart or Eye in one of my sample models then play with the OCL
> consoles, I get the following results:
>
> Calling self.Head on a Eye object (containment reference)
> In the interactive Xtext OCL console, I get the expected result (the
> containing Head object)
> In the interactive OCL console, I get an error: Unrecognized variable:
> (Head)
>
> Calling self.Head on a Heart object (non-containment reference)
> In the interactive Xtext OCL console, I get an empty result
> In the interactive OCL console, I get an error: Unrecognized variable:
> (Head)
>
> Does it mean I can use syntax self.Head in my OCL business constraints ?
>
> Thanks in advance,
>
> François
Previous Topic:Validating OCL programmatically
Next Topic:Applying OCL at models (vs metamodels)
Goto Forum:
  


Current Time: Tue Mar 19 10:00:22 GMT 2024

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

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

Back to the top