Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Invariants in abstract EClasses
Invariants in abstract EClasses [message #1339495] Wed, 07 May 2014 18:09 Go to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Hi,

I've recently started adding OCL contraints to one of our models through OclInEcore as described in:

http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Ftutorials%2Foclinecore%2FoclInEcoreTutorial.html
https://wiki.eclipse.org/OCL/OCLinEcore#EOperation_bodies.2C_preconditions_and_postconditions

I'm wondering if invariants on abstract EClasses are inherited by non-abstract subclasses. I found that the following invariant:

invariant mustHaveOneTypeA: children->select(oclIsKindOf(TypeA))->size() < 2;


is checked only if defined in non-abstract subclasses. If defined on the abstract superclass, its not checked. I tested this through the dinamic instance creation and the reflective ecore editor:

- if the invariant is defined in the superclass, the reflective ecore editor does not show any validation error.
- if the invariant is defined in the subclass im actually instantiating, the reflective ecore editor correctly show a validation error.

Any thoughts?

Best Regards,
Víctor Roldán Betancort.
Re: Invariants in abstract EClasses [message #1339571 is a reply to message #1339495] Wed, 07 May 2014 18:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sounds like a bug.

What versions are you using?

Regards

Ed


On 07/05/2014 19:09, Victor Roldan Betancort wrote:
> Hi,
>
> I've recently started adding OCL contraints to one of our models
> through OclInEcore as described in:
>
> http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Ftutorials%2Foclinecore%2FoclInEcoreTutorial.html
>
> https://wiki.eclipse.org/OCL/OCLinEcore#EOperation_bodies.2C_preconditions_and_postconditions
>
>
> I'm wondering if invariants on abstract EClasses are inherited by
> non-abstract subclasses. I found that the following invariant:
>
> invariant mustHaveOneTypeA:
> children->select(oclIsKindOf(TypeA))->size() < 2;
>
> is checked only if defined in non-abstract subclasses. If defined on
> the abstract superclass, its not checked. I tested this through the
> dinamic instance creation and the reflective ecore editor:
>
> - if the invariant is defined in the superclass, the reflective ecore
> editor does not show any validation error.
> - if the invariant is defined in the subclass im actually
> instantiating, the reflective ecore editor correctly show a validation
> error.
>
> Any thoughts?
>
> Best Regards,
> Víctor Roldán Betancort.
Re: Invariants in abstract EClasses [message #1339858 is a reply to message #1339571] Wed, 07 May 2014 21:43 Go to previous messageGo to next message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Hi there Ed,

I hoped I was doing something wrong. I guess the workaround is to copy the invariant in every subclass. I'm using the Kepler SR2 as development workbench to test these constraints.

I've read something about defining these constraints in a separate file. Is this actually possible?

Cheers,
Víctor Roldán Betancort.
Re: Invariants in abstract EClasses [message #1341250 is a reply to message #1339858] Thu, 08 May 2014 11:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Using:

package NewOCLinEcoreFile : pfx =
'platform:/resource/Activity/NewOCLinEcoreFile.oclinecore'
{
abstract class Abstract
{
invariant AbstractAlwaysFalse: false;
}
class Derived extends Abstract
{
invariant DerivedAlwaysFalse: false;
}
}

and an instance of Derived

on Juno SR2 and Luna M7, both LPG and Pivot evaluators report both
AbstractAlwaysFalse and DerivedAlwaysFalse failures.

So there must be something else that's confusing you.

Regards

Ed Willink


On 07/05/2014 22:43, Victor Roldan Betancort wrote:
> Hi there Ed,
>
> I hoped I was doing something wrong. I guess the workaround is to copy
> the invariant in every subclass. I'm using the Kepler SR2 as
> development workbench to test these constraints.
> I've read something about defining these constraints in a separate
> file. Is this actually possible?
>
> Cheers,
> Víctor Roldán Betancort.
Re: Invariants in abstract EClasses [message #1341301 is a reply to message #1341250] Thu, 08 May 2014 12:19 Go to previous message
Victor Roldan Betancort is currently offline Victor Roldan BetancortFriend
Messages: 524
Registered: July 2009
Senior Member
Hi Ed,

thats odd, I checked through the OCL console and those constraints seem to work fine (the ocl expression returns what I expect). However, validation does not take place when setting the invariant in the abstract class.
Thanks for your insight, I'll keep investigating Smile

Best Regards,
Víctor Roldán Betancort.
Previous Topic:Using OCL as a setter for derived features in EMF?
Next Topic:PrettyPrinter ignors comments
Goto Forum:
  


Current Time: Tue Mar 19 04:34:45 GMT 2024

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

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

Back to the top