Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Check invariants without instantiation
Check invariants without instantiation [message #788354] Wed, 01 February 2012 17:47 Go to next message
sohrab Missing name is currently offline sohrab Missing nameFriend
Messages: 17
Registered: November 2011
Junior Member
Hi,

I use OCLinEcore editor for checking constraints. I have two ecore files A.ecore , B.ecore . I have a class in B (bClass) that extends another class in A (aClass). I write a invariant for aClass in A.ecore. Is it possible to check this invariant for bClass? I want check without instantiation.

how I can apply constraints for metamodels only?

Thanks.
Re: Check invariants without instantiation [message #788386 is a reply to message #788354] Wed, 01 February 2012 18:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your question doesn't make sense to me.

Yes. You can check inherited constraints, but it's a recent fix
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=351578) which is in Juno
M2 and will be in Indigo SR2 in a couple of weeks.

No. You cannot check without instantiation since most constraints access
some aspect of self. e.g. self.age >= 18;

If you just want to check non-object properties; e.g. 3 * 3 = 9 then you
can do this on any old object.

If you are really checking without instantiation, perhaps you are trying
to use M2 rather than M1 constraints. I'd be interested to see your use
case.

Regards

Ed Willink

On 01/02/2012 17:47, sohrab Mising name wrote:
> Hi,
>
> I use OCLinEcore editor for checking constraints. I have two ecore
> files A.ecore , B.ecore . I have a class in B (bClass) that extends
> another class in A (aClass). I write a invariant for aClass in
> A.ecore. Is it possible to check this invariant for bClass? I want
> check without instantiation.
>
> how I can apply constraints for metamodels only?
>
> Thanks.
Re: Check invariants without instantiation [message #788406 is a reply to message #788386] Wed, 01 February 2012 19:17 Go to previous messageGo to next message
sohrab Missing name is currently offline sohrab Missing nameFriend
Messages: 17
Registered: November 2011
Junior Member
Thanks Ed.

Indeed I want to check metamodels without any instantiation. I can use "self.name" in OCLinEcore consol and it results for example 'abc'. so I can ask "self.name='aaa'" in consol and it results false. But when I write this invariant in my class:
-----------------
invariant test:
self.name='aaa';
-----------------

and do right click on my class and select "Validate", it results "validation completed successfully". why?

----------------------------------------------------------------------
I use these two ecores for example:

import ecore_0 : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';
import ecore_1 : 'http://www.eclipse.org/emf/2002/Ecore#/';

package A : A = 'http:///A.ecore'
{
	class a
	{
		invariant test1: 
		self.name>size()<=4;
		attribute name : String[?];
		.....
	}
}



import ecore_0 : 'http://www.eclipse.org/emf/2002/Ecore#/';
import ecore_1 : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';
import A_0 : 'A.ecore#/';

package B : B = 'http:///B.ecore'
{
	class b extends A_0::a
	{
		....
	}
}




and want to check constraints on class B.
Re: Check invariants without instantiation [message #788420 is a reply to message #788406] Wed, 01 February 2012 19:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The Console evaluates instances, so they exist and can be checked.
OCLinEcore defines the rules to check.

Consider an analogy; you request that all members of your family have
names not exceeding four characters. This can be checked for known
members of your family, but cannot yet be checked for your
great-great-grand-daughter since, I assume, she has yet to be born and
named. It is not until she is named that a failure to comply with
request can be determined.

Regards

Ed Willink

On 01/02/2012 19:17, sohrab Mising name wrote:
> Thanks Ed.
>
> Indeed I want to check metamodels without any instantiation. I can use
> "self.name" in OCLinEcore consol and it results for example 'abc'. so
> I can ask "self.name='aaa'" in consol and it results false. But when I
> write this invariant in my class:
> -----------------
> invariant test:
> self.name='aaa';
> -----------------
>
> and do right click on my class and select "Validate", it results
> "validation completed successfully". why?
> ----------------------------------------------------------------------
> I use these two ecores for example:
>
> import ecore_0 : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';
> import ecore_1 : 'http://www.eclipse.org/emf/2002/Ecore#/';
>
> package A : A = 'http:///A.ecore'
> {
> class a
> {
> invariant test1: self.name>size()<=4;
> attribute name : String[?];
> .....
> }
> }
>
>
> import ecore_0 : 'http://www.eclipse.org/emf/2002/Ecore#/';
> import ecore_1 : '/plugin/org.eclipse.emf.ecore/model/Ecore.ecore#/';
> import A_0 : 'A.ecore#/';
>
> package B : B = 'http:///B.ecore'
> {
> class b extends A_0::a
> {
> ....
> }
> }
>
>
>
>
> and want to check constraints on class B.
Re: Check invariants without instantiation [message #788435 is a reply to message #788420] Wed, 01 February 2012 20:14 Go to previous messageGo to next message
sohrab Missing name is currently offline sohrab Missing nameFriend
Messages: 17
Registered: November 2011
Junior Member
Thanks, I'm understanding your response, But it's true for "name". I could be able to check name or type of eReferenceses for one class without instantiation.
for example I want to check this constraint for my ecore files:
self.eReferences ->select(eReferenceType.eSuperTypes->select(true)->at(1)=self.eReferences.eReferenceType.eAllSuperTypes->select(name='eCoupling')->at(1))->forAll(eReferences->at(2).eReferenceType.eReferences.eReferenceType.name->includesAll(eReferences->at(1).eReferenceType.eReferences.eReferenceType.name));

indeed meta-models are instances of meta-meta-models.
1-Can I check above constraint for my ecore files without OCLinEcore consol and any instantiation?
2-when B extends A, A is a eSuperClass for B , and I sholud refer to it's eAttributes, eReferences,... . Can I write constraint in A that checks about types of B's eReferences?
Re: Check invariants without instantiation [message #788449 is a reply to message #788435] Wed, 01 February 2012 20:42 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

OCL can be applied at any level to which you have access.

As from Juno M5 there are about 30 OCL constraints that are directly
code generated from OCL into Java (see the pivot.bodies package) and
executed on your meta-model when you invoke Validate within the
OCLinEcore editor. This implements some of the missing Well-Formedness
Rules. Hopefully all the rules in the OCL specification will be debugged
and implemented for the Juno release.

In principle, (https://bugs.eclipse.org/bugs/show_bug.cgi?id=368612#c1),
using Load Resource within the OCLinEcore editor could allow you to load
a Complete OCL document with additional constraints. e.g. the iterator
name of an exists iteration must be named 'e'. Something like (not
tool-checked)

context IteratorExp
inv ExistsIteratorNamedE: referredIteration.name = 'exists' implies
ownedIterator->first().name = 'e'

But here the OCL meta-model is used. You seem to be trying to use the
Ecore meta-model, so I'm not convinced that you are using your
meta-meta-model at all.

Regards

Ed Willink


On 01/02/2012 20:14, sohrab Mising name wrote:
> Thanks, I'm understanding your response, But it's true for "name". I
> could be able to check name or type of eReferenceses for one class
> without instantiation.
> for example I want to check this constraint for my ecore files:
> self.eReferences
> ->select(eReferenceType.eSuperTypes->select(true)->at(1)=self.eReferences.eReferenceType.eAllSuperTypes->select(name='eCoupling')->at(1))->forAll(eReferences->at(2).eReferenceType.eReferences.eReferenceType.name->includesAll(eReferences->at(1).eReferenceType.eReferences.eReferenceType.name));
>
> indeed meta-models are instances of meta-meta-models.
> 1-Can I check above constraint for my ecore files without OCLinEcore
> consol and any instantiation?
> 2-when B extends A, A is a eSuperClass for B , and I sholud refer to
> it's eAttributes, eReferences,... . Can I write constraint in A that
> checks about types of B's eReferences?
Previous Topic:Is it possible to retrieve the type name?
Next Topic:[Announce] Eclipse OCL Tools 4.0.0 (Juno) M5 is available
Goto Forum:
  


Current Time: Thu Mar 28 21:15:37 GMT 2024

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

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

Back to the top