Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:16 Go to next message
Carlos Gomez is currently offline Carlos GomezFriend
Messages: 63
Registered: October 2010
Member
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 09:17]

Report message to a moderator

Re: How can I use oclContainer() in OCL Query for Ecore [message #1667846 is a reply to message #1638744] Thu, 12 March 2015 08:04 Go to previous messageGo to next message
Carlos Gomez is currently offline Carlos GomezFriend
Messages: 63
Registered: October 2010
Member
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 09:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6110
Registered: July 2009
Senior Member
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 09:12 Go to previous messageGo to next message
Carlos Gomez is currently offline Carlos GomezFriend
Messages: 63
Registered: October 2010
Member
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 12:26 Go to previous message
Carlos Gomez is currently offline Carlos GomezFriend
Messages: 63
Registered: October 2010
Member
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: Wed Nov 14 09:14:59 GMT 2018

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

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

Back to the top