Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL expression intersection
OCL expression intersection [message #892315] Wed, 27 June 2012 17:12 Go to next message
Erik Gollot is currently offline Erik Gollot
Messages: 5
Registered: May 2012
Junior Member
Hello,

I would to know if its possible to easilly (of course) determine if an OCL expression OExp1 is "included in" another OCL expression OExp2 in the same context.
For example, my first expression is "self.age < 18" then I've another expression which is "self.category = CategoryKind.CAT1 && self.age < 34". So is it possible to determine that my first expression is "included in", "compatible with" my second expression ?

Thanks

[Updated on: Wed, 27 June 2012 17:13]

Report message to a moderator

Re: OCL expression intersection [message #892320 is a reply to message #892315] Wed, 27 June 2012 17:36 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4097
Registered: July 2009
Senior Member
Hi

Using the Pivot binding of OCL that you can find as examples functionality:

oclType() is fully reflective so provided you can navigate from the self
Classifier to rthe expression, e.g to an invariant or operation body,

self.ownedRule->select(name='interestingInvariant')->any(true).specification.oclAsType(ExpressionInOCL).bodyExpression

gives the AST of the invariant named 'interestingInvariant'.

Once you have two ASTs you can then just detect whether one 'covers' the
other.

This could be achieved by defining a 'covers' operation for relevant
nodes in the OCL AST.

You can implement 'covers' to be exact match or greater than match.

No exactly easy, but in principle what you would do in Java.

Regards

Ed Willink





On 27/06/2012 18:12, Erik Gollot wrote:
> Hello,
>
> I would to know if its possible to easilly (of course) determine if an
> OCL expression OExp1 is "included in" another OCL expression OExp2 in
> the same context.
> For example, my first expression is "self.age < 18" then I've another
> expression which is "self.category = CategoryKind.CAT1 && self.age <
> 34". So is it possible to determine that my first expression is
> "included in", "compatible with" my second expression ?
>
> Thanks
>
Previous Topic:Saving a file with OCLinEcore undefines EOpposite in a referenced model
Next Topic:[Announce] Eclipse OCL 4.0.0 (Juno) is now available
Goto Forum:
  


Current Time: Fri Oct 24 23:56:37 GMT 2014

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

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