Skip to main content



      Home
Home » Modeling » OCL » How can I use oclContainer() in OCL Query for Ecore
How can I use oclContainer() in OCL Query for Ecore [message #1638744] Fri, 27 February 2015 04:16 Go to next message
Eclipse UserFriend
Hi everybody,

I'm trying to use oclContainer() in an OCL Query to get the eContainer of an EObject. Nevertheless, this operation is not recognized.

I'm following the code provided by OCL documentation:

OCLExpression<EClassifier> oclQuery = null;
OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
OCLHelper<EClassifier, ?, ?, Constraint> helper = ocl.createOCLHelper();
helper.setInstanceContext(context);
oclQuery = helper.createQuery(query);
Query queryEval = ocl.createQuery(oclQuery);
Object queryResult = (Object) queryEval.evaluate(context);


Thanks for your help!

[Updated on: Fri, 27 February 2015 04:17] by Moderator

Re: How can I use oclContainer() in OCL Query for Ecore [message #1667846 is a reply to message #1638744] Thu, 12 March 2015 04:04 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

Has anybody had the same need?

Thanks
Re: How can I use oclContainer() in OCL Query for Ecore [message #1667961 is a reply to message #1667846] Thu, 12 March 2015 05:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi

My previous reply, accidentally off list is below.

oclContainer() / eContainer() is useful whenever the metamodel omits a
named relation to the container. It is needed if the parent is rachable
by other relationships too.

Regards

Ed Willink

Hi

You only provide a partial clues, but I can see from the template
arguments that you must be using the Ecore-based OCL.

oclContainer() and oclContents() are candidates for inclusion in OCL 2.5
and are available in the PIvot-based OCL prototype.

They are not available in Ecore-based OCL, but eContainer() is provided
your object is an EObject; you may need oclAsType().

Regards

Ed Willink


On 12/03/2015 08:04, Carlos Gomez wrote:
> Hello,
>
> Has anybody had the same need?
>
> Thanks
Re: How can I use oclContainer() in OCL Query for Ecore [message #1678621 is a reply to message #1667961] Mon, 16 March 2015 05:12 Go to previous messageGo to next message
Eclipse UserFriend
Thank you Ed for your answer,

Yes, I know what you mean. In fact, I cannot modify the meta-model to add the parent relationship. That is the reason why I ask for oclContainer().

Thanks again
Re: How can I use oclContainer() in OCL Query for Ecore [message #1684440 is a reply to message #1678621] Wed, 18 March 2015 08:26 Go to previous message
Eclipse UserFriend
I found a temporal solution and it's to use eContainer() operation. Thus, if you want to get the parent of your object, you can use:
children.oclAsType(ecore::EObject).eContainer()


I hope this help Wink
Previous Topic:supplierDependency broken in Luna SR2
Next Topic:Parser ignores @pre
Goto Forum:
  


Current Time: Thu Jul 10 08:12:57 EDT 2025

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

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

Back to the top