Skip to main content



      Home
Home » Modeling » OCL » Invariants in abstract EClasses
Invariants in abstract EClasses [message #1339495] Wed, 07 May 2014 14:09 Go to next message
Eclipse UserFriend
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 14:51 Go to previous messageGo to next message
Eclipse UserFriend
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 17:43 Go to previous messageGo to next message
Eclipse UserFriend
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 07:47 Go to previous messageGo to next message
Eclipse UserFriend
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 08:19 Go to previous message
Eclipse UserFriend
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: Wed Jul 16 16:54:01 EDT 2025

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

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

Back to the top