Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Navigating over eContainer()
Navigating over eContainer() [message #486862] Sun, 20 September 2009 06:04 Go to next message
Derek Palma is currently offline Derek Palma
Messages: 141
Registered: July 2009
Senior Member
Hi,

I have Ecore models with EClass A having a reference to EClass B, a
composition where A 'owns' B. The reference is configured with
setContainment(true). There is no opposite relation because I don't have
it/want it/need it. Is there a way to navigate from an instance of B back to
an instance of A with OCL? As far as I can see, it seems B.eContainer()
would have to be used by OCL to achieve this. Is there a syntax for this?

Thanks in advance.
Derek
Re: Navigating over eContainer() [message #486877 is a reply to message #486862] Sun, 20 September 2009 11:58 Go to previous messageGo to next message
Eclipse User
Originally posted by: dvorak.radek.gmail.com

Hi Derek,

You can set the "implicit root class" parser option to EObject and then
ecore reflective operations
like eClass(), eCotainer() should be available.

The Stdlib of QVT comes with Element::container().

Regards,
/Radek



On Sun, 20 Sep 2009 12:04:04 +0200, Derek Palma <derek.palma@gmail.com>
wrote:

> Hi,
>
> I have Ecore models with EClass A having a reference to EClass B, a
> composition where A 'owns' B. The reference is configured with
> setContainment(true). There is no opposite relation because I don't have
> it/want it/need it. Is there a way to navigate from an instance of B
> back to an instance of A with OCL? As far as I can see, it seems
> B.eContainer() would have to be used by OCL to achieve this. Is there a
> syntax for this?
>
> Thanks in advance.
> Derek
Re: Navigating over eContainer() [message #486921 is a reply to message #486877] Sun, 20 September 2009 23:40 Go to previous messageGo to next message
Derek Palma is currently offline Derek Palma
Messages: 141
Registered: July 2009
Senior Member
Thanks Radek!!!

I searched the java doc and found the option in ParsingOptions.
Unfortunately, I just don't get how to specify the parameters due to some
lack of understanding of Java generics I guess.

Here is what I have. I tried EObject in the 3rd parameter but it does not
like it. Oddly I found no code in my environment setting this option which I
could refer to. Please tell me the magical syntax. :)

Derek

Environment<EPackage, EClassifier, EOperation, EStructuralFeature,
EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction,
Constraint, EClass, EObject>

rootEnv = EcoreEnvironmentFactory.INSTANCE.createEnvironment();

ParsingOptions.setOption(rootEnv, ParsingOptions.implicitRootClass(rootEnv),
<What goes here????>);





"radek dvorak" <dvorak.radek@gmail.com> wrote in message
news:op.u0khhsom12y5f2@kliste.local...
> Hi Derek,
>
> You can set the "implicit root class" parser option to EObject and then
> ecore reflective operations
> like eClass(), eCotainer() should be available.
>
> The Stdlib of QVT comes with Element::container().
>
> Regards,
> /Radek
>
>
>
> On Sun, 20 Sep 2009 12:04:04 +0200, Derek Palma <derek.palma@gmail.com>
> wrote:
>
>> Hi,
>>
>> I have Ecore models with EClass A having a reference to EClass B, a
>> composition where A 'owns' B. The reference is configured with
>> setContainment(true). There is no opposite relation because I don't have
>> it/want it/need it. Is there a way to navigate from an instance of B
>> back to an instance of A with OCL? As far as I can see, it seems
>> B.eContainer() would have to be used by OCL to achieve this. Is there a
>> syntax for this?
>>
>> Thanks in advance.
>> Derek
Re: Navigating over eContainer() [message #486927 is a reply to message #486921] Mon, 21 September 2009 01:30 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi Derek

The org.eclipse.ocl.ecore.tests.ParsingOptionsTest JUnit test does

ParsingOptions.setOption(ocl.getEnvironment(),
ParsingOptions.implicitRootClass(ocl.getEnvironment()),
EcorePackage.Literals.EOBJECT);

This should not be necessary. The OCL 2.0 specification is hardly clear
but your meta-model types conform to OclAny and Classifier so any
operation of Classifier, such as container() should work. Hopefully
fixed in the next release.

Regards

Ed Willink

Derek Palma wrote:
> Thanks Radek!!!
>
> I searched the java doc and found the option in ParsingOptions.
> Unfortunately, I just don't get how to specify the parameters due to
> some lack of understanding of Java generics I guess.
>
> Here is what I have. I tried EObject in the 3rd parameter but it does
> not like it. Oddly I found no code in my environment setting this option
> which I could refer to. Please tell me the magical syntax. :)
>
> Derek
>
> Environment<EPackage, EClassifier, EOperation, EStructuralFeature,
> EEnumLiteral, EParameter, EObject, CallOperationAction,
> SendSignalAction, Constraint, EClass, EObject>
>
> rootEnv = EcoreEnvironmentFactory.INSTANCE.createEnvironment();
>
> ParsingOptions.setOption(rootEnv,
> ParsingOptions.implicitRootClass(rootEnv), <What goes here????>);
>
>
>
>
>
> "radek dvorak" <dvorak.radek@gmail.com> wrote in message
> news:op.u0khhsom12y5f2@kliste.local...
>> Hi Derek,
>>
>> You can set the "implicit root class" parser option to EObject and
>> then ecore reflective operations
>> like eClass(), eCotainer() should be available.
>>
>> The Stdlib of QVT comes with Element::container().
>>
>> Regards,
>> /Radek
>>
>>
>>
>> On Sun, 20 Sep 2009 12:04:04 +0200, Derek Palma
>> <derek.palma@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have Ecore models with EClass A having a reference to EClass B, a
>>> composition where A 'owns' B. The reference is configured with
>>> setContainment(true). There is no opposite relation because I don't
>>> have it/want it/need it. Is there a way to navigate from an instance
>>> of B back to an instance of A with OCL? As far as I can see, it seems
>>> B.eContainer() would have to be used by OCL to achieve this. Is there
>>> a syntax for this?
>>>
>>> Thanks in advance.
>>> Derek
>
Previous Topic:How to check the types of containment?
Next Topic:Referencing models with names that conflict with OCL syntax
Goto Forum:
  


Current Time: Tue Jul 22 13:38:38 EDT 2014

Powered by FUDForum. Page generated in 0.02517 seconds