Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Some OCL constraints are not evaluated
Some OCL constraints are not evaluated [message #60562] Sun, 08 October 2006 02:34 Go to next message
Cristina Missing name is currently offline Cristina Missing nameFriend
Messages: 21
Registered: July 2009
Junior Member
Hi everybody,

I have problems with some of the OCL Audit Rules added to my gmfmap file.

I am trying to asure that all the XNodes in my model have different names.
In my meta-model I have an abstract class Node, and two different subclasses
of Node called XNode (wich adds the attribute "name" to those inherited from
Node), and YNode (wich doesn't have "name"). I can access all the Nodes of
my model but not only those belonging to the XNode class. Thus, in order to
check that all XNodes have different names, I need to use the "allInstances"
method, i.e.:

XNode.allInstances() -> forAll ( n1, n2 | n1.name <> n2.name)
XNode.allInstances() -> select ( n1, n2 | n1.name = n2.name ) ->
isEmpty()

Other OCL expressions I have tried using the container of all Nodes as the
Domain Element Target are:

self.hasNodes( ) -> select ( n | n.oclIsTypeOf (XNode) ) -> forAll (n1,
n2 | n1.name<>n2.name)

but this expression fails since the forAll operation expects n1, n2 to be
Nodes instead of XNodes, and not all Nodes have a "name" attribute (i.e. the
previous select hasn't the effect I expected).

Anyway, the first two expressions seem to work fine (the are valid and I can
generate de gmfgen from the gmfmap) but, when I build a model and validate
it, I get the following message in the "Problems tab".

"IRJA0030I The constraint ... is disabled. It will not be evaluated."

I have read a post written by other user and the recommendation was to check
if the 'org.eclipse.emf.validation.ui' plug-in was correctly installed.
I have already checked it, and it is there... so it doesn't seem to be the
problem.

The problem seems to be related to the use of "allInstances" however, I
need this operation to access only the XNodes in my model.

Any clue??

Thanks in advance for any help :-)

Cristina
Re: Some OCL constraints are not evaluated [message #60574 is a reply to message #60562] Sun, 08 October 2006 13:35 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hi,

I never tried allInstances and I doubt there is efficient way to execute it.
However, I believe that
self.hasNodes( ) -> select ( n | n.oclIsTypeOf (XNode) )
-> forAll (n1, n2 |
n1.oclIsTypeOf(XNode)
and n2.oclIsTypeOf(XNode)
and n1.oclAsType(XNode).name<>n2.oclAsType(XNode).name
)

will do the work, at least assuming that self.hasNodes() returns collection
of nodes, not the boolean that someone may expect from its name :)

Regards,
Michael

"Cristina" <Cristina.Vicente@upct.es> wrote in message
news:eg9o4e$9p0$1@utils.eclipse.org...
> Hi everybody,
>
> I have problems with some of the OCL Audit Rules added to my gmfmap file.
>
> I am trying to asure that all the XNodes in my model have different names.
> In my meta-model I have an abstract class Node, and two different
> subclasses of Node called XNode (wich adds the attribute "name" to those
> inherited from Node), and YNode (wich doesn't have "name"). I can access
> all the Nodes of my model but not only those belonging to the XNode class.
> Thus, in order to check that all XNodes have different names, I need to
> use the "allInstances" method, i.e.:
>
> XNode.allInstances() -> forAll ( n1, n2 | n1.name <> n2.name)
> XNode.allInstances() -> select ( n1, n2 | n1.name = n2.name ) ->
> isEmpty()
>
> Other OCL expressions I have tried using the container of all Nodes as the
> Domain Element Target are:
>
> self.hasNodes( ) -> select ( n | n.oclIsTypeOf (XNode) ) -> forAll (n1,
> n2 | n1.name<>n2.name)
>
> but this expression fails since the forAll operation expects n1, n2 to be
> Nodes instead of XNodes, and not all Nodes have a "name" attribute (i.e.
> the previous select hasn't the effect I expected).
>
> Anyway, the first two expressions seem to work fine (the are valid and I
> can generate de gmfgen from the gmfmap) but, when I build a model and
> validate it, I get the following message in the "Problems tab".
>
> "IRJA0030I The constraint ... is disabled. It will not be evaluated."
>
> I have read a post written by other user and the recommendation was to
> check if the 'org.eclipse.emf.validation.ui' plug-in was correctly
> installed.
> I have already checked it, and it is there... so it doesn't seem to be the
> problem.
>
> The problem seems to be related to the use of "allInstances" however, I
> need this operation to access only the XNodes in my model.
>
> Any clue??
>
> Thanks in advance for any help :-)
>
> Cristina
>
Re: Some OCL constraints are not evaluated [message #60579 is a reply to message #60574] Sun, 08 October 2006 22:06 Go to previous messageGo to next message
Cristina Missing name is currently offline Cristina Missing nameFriend
Messages: 21
Registered: July 2009
Junior Member
Thank you very much, Michael !!
I am a beginner using OCL and didn't know the "oclAsType" (casting) function
;-).
It works perfectly even with a simplified version of your rule:
self.hasNodes( ) -> select ( n | n.oclIsTypeOf (XNode) )
-> forAll (n | n <> self implies n.oclAsType(XNode).name <>
self.name)
)

I always find useful answers to my questions in this newsgroup. You are a
great team ;-)
Thanks again !!Cheers,
Cristina


"Michael Golubev" <michael.golubev@borland.com> escribi
Re: Some OCL constraints are not evaluated [message #60588 is a reply to message #60562] Mon, 09 October 2006 11:35 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
Hi Cristina,

You probably use GMF 1.0. This release has dependency on EMF OCL build
1.0.0RC6, which
had https://bugs.eclipse.org/bugs/show_bug.cgi?id=146378, fixed in 1.0.1.

In general, EMFT OCL supports 'allInstances()' operation on EClasses. The
default implementation
returns all instances contained in the root container of the evalutation
context object.

Yet another hint, try using qualified name for XNode eClass.

/Radek


"Cristina" <Cristina.Vicente@upct.es> wrote in message
news:eg9o4e$9p0$1@utils.eclipse.org...
> Hi everybody,
>
> I have problems with some of the OCL Audit Rules added to my gmfmap file.
>
> I am trying to asure that all the XNodes in my model have different names.
> In my meta-model I have an abstract class Node, and two different
> subclasses of Node called XNode (wich adds the attribute "name" to those
> inherited from Node), and YNode (wich doesn't have "name"). I can access
> all the Nodes of my model but not only those belonging to the XNode class.
> Thus, in order to check that all XNodes have different names, I need to
> use the "allInstances" method, i.e.:
>
> XNode.allInstances() -> forAll ( n1, n2 | n1.name <> n2.name)
> XNode.allInstances() -> select ( n1, n2 | n1.name = n2.name ) ->
> isEmpty()
>
> Other OCL expressions I have tried using the container of all Nodes as the
> Domain Element Target are:
>
> self.hasNodes( ) -> select ( n | n.oclIsTypeOf (XNode) ) -> forAll (n1,
> n2 | n1.name<>n2.name)
>
> but this expression fails since the forAll operation expects n1, n2 to be
> Nodes instead of XNodes, and not all Nodes have a "name" attribute (i.e.
> the previous select hasn't the effect I expected).
>
> Anyway, the first two expressions seem to work fine (the are valid and I
> can generate de gmfgen from the gmfmap) but, when I build a model and
> validate it, I get the following message in the "Problems tab".
>
> "IRJA0030I The constraint ... is disabled. It will not be evaluated."
>
> I have read a post written by other user and the recommendation was to
> check if the 'org.eclipse.emf.validation.ui' plug-in was correctly
> installed.
> I have already checked it, and it is there... so it doesn't seem to be the
> problem.
>
> The problem seems to be related to the use of "allInstances" however, I
> need this operation to access only the XNodes in my model.
>
> Any clue??
>
> Thanks in advance for any help :-)
>
> Cristina
>
Previous Topic:Removing Appearance Property Tab
Next Topic:target project name
Goto Forum:
  


Current Time: Wed Jul 17 14:53:01 GMT 2024

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

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

Back to the top