Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » how to write constraints in OCL
how to write constraints in OCL [message #194100] Mon, 23 June 2008 12:22 Go to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi,
I wonder how to express in OCL if I want to write this constriants in
GMF: the polyline connection number to which a figure can have is no
larger than one of the figure's attributes.how to express this in OCL?
For example,now there is a EClass Gather which is connected by a
polyline connection (represented by Eclass Channel).The number of Channels
that pointing at Gather is no larger than InputNum which is one attribute
of Gather.How to express this constraint for Channel in OCL?



Thanks so much
Re: how to write constraints in OCL [message #194168 is a reply to message #194100] Mon, 23 June 2008 17:21 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ye,

> Channels that pointing at Gather is no larger than InputNum which is one
> attribute of Gather.How to express this constraint for Channel in OCL?
AFAIU, Channel should be represented as link on your diagram. In this case
you have so specify target end link constraint like:
self.incommingChanels->size() < self.InputNum

Note: you have to keep refereces from Gather instances back to Channels (incommingChanels
in OCL expression). This is easy to implement (thanks to EMF) using eOpposite
property of Channel->Gather reference.

-----------------
Alex Shatalin
Re: how to write constraints in OCL [message #194216 is a reply to message #194168] Tue, 24 June 2008 08:27 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi Alex,

I add the ocl expression to link(Channel) constraints- target end
constraint.
but when I create generator model from mapping model,it report 'invalid
expressio n body'self.incomingChannels->size()<=self.InputNum'.The latter
self means Channel,right?Can it access to InputNum belong to Gather in
this way?
Maybe I should explain the situation in more details.Now there are two
bidirectional references between Channel and Object(abstract class which
have subclasses Gather and Scatter).inputs(belong to
Channel)<----->outgoingChannels(belong to
Objects);outputs<---->incomingChannels.InputNum and OutputNum are two
attributes defined in Gather and Scatter respectively.
In addition, I want to ask how to express two constraints in one target
end constraint text editor.For instance,to express
self.incomingChannels->size()<=self.InputNum
self.outgoingChannels->size()<=self.OutputNum
Is '&&' or other operator needed between the two expressions?


I hope I explained clearly,thank you for your reply!

Ye Liu
Re: how to write constraints in OCL [message #194256 is a reply to message #194216] Tue, 24 June 2008 10:23 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ye,

> 'invalid expressio n body'self.incomingChannels->size()<=self.InputNum'.The
Any othe details in this messages?

> self means Channel,right?Can it access to InputNum belong to Gather in
variable "self" in target end link constraint should be recognized as link
target == Gather.

> In addition, I want to ask how to express two constraints in one
> target end constraint text editor.For instance,to express
I think you have to use source/target link end constraints for it..

> Is '&&' or other operator needed between the two expressions?
In OCL you have to use 'and' instead of '&&'.

-----------------
Alex Shatalin
Re: how to write constraints in OCL [message #194600 is a reply to message #194256] Wed, 25 June 2008 12:05 Go to previous messageGo to next message
yeliu is currently offline yeliuFriend
Messages: 145
Registered: July 2009
Senior Member
Hi Alex,
The exact error report is :
invalid expression body'self.incomingChannels<self.outputs->inputRate'
Cause:Error in(variableExpCS):(Unrecognized variable:(inputRate))

As I told ,the constraint is added to Link Mapping(Channel).if here by
self you mean Gather ,then how to access to Gather in target end
constraint of Channel?

By the way ,in Source end constraint of Channel,there is already 'self<>
oppositeEnd'.And can you tell me the meaning of source /target in the term
source/target End constraint?


Thanks a lot!

Ye Liu
Re: how to write constraints in OCL [message #194680 is a reply to message #194600] Thu, 26 June 2008 11:07 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ye,

> invalid expression body'self.incomingChannels<self.outputs->inputRate'
> Cause:Error in(variableExpCS):(Unrecognized variable:(inputRate))
This means, inputRate was not found.

> As I told ,the constraint is added to Link Mapping(Channel).if here by
> self you mean Gather ,then how to access to Gather in target end
> constraint of Channel?
Each link mapping can handle tree kids of constraints:
- Constraint
- Link Constraints/Source End Constraint
- Link Constraints/Target End Constraint

In scope of Constraint "self" env. variable will keep reference to link domain
element (if defined)
In scope of Source/Target End Constraints "self" used to point to source/target
element of future link in accordance.

So, if you are specifying target end constraint then "self" == target Gather
instance.

> 'self<> oppositeEnd'.And can you tell me the meaning of source /target
> in the term source/target End constraint?
source/target end constraint will be evaluated before link creation for future
link source/target domain element. If both constraints are satisfied then
link can be created if not - link creation will be prohibited.
BTW you can use "and" in OCL like: (self <> oppositeEnd) and (self.outgoingChannels<self.outputs')

-----------------
Alex Shatalin
Re: how to write constraints in OCL [message #194746 is a reply to message #194600] Thu, 26 June 2008 23:47 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-LXIYASpbj7/MdN7z6Oyu
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Ye,

The -> operator is only used with collection operations such as "size"
and iterators such as "forAll." To access properties of model elements,
you must use the dot ( . ) operator:

self.outputs.inputRate

HTH,

Christian


On Wed, 2008-06-25 at 12:05 +0000, Ye Liu wrote:

> Hi Alex,
> The exact error report is :
> invalid expression body'self.incomingChannels<self.outputs->inputRate'
> Cause:Error in(variableExpCS):(Unrecognized variable:(inputRate))
>
> As I told ,the constraint is added to Link Mapping(Channel).if here by
> self you mean Gather ,then how to access to Gather in target end
> constraint of Channel?
>
> By the way ,in Source end constraint of Channel,there is already 'self<>
> oppositeEnd'.And can you tell me the meaning of source /target in the term
> source/target End constraint?
>
>
> Thanks a lot!
>
> Ye Liu
>
>
>

--=-LXIYASpbj7/MdN7z6Oyu
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Ye,<BR>
<BR>
The -&gt; operator is only used with collection operations such as &quot;size&quot; and iterators such as &quot;forAll.&quot;&nbsp; To access properties of model elements, you must use the dot ( . ) operator:<BR>
<BR>
&nbsp; self.outputs.inputRate<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Wed, 2008-06-25 at 12:05 +0000, Ye Liu wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Hi Alex,</FONT>
<FONT COLOR="#000000"> The exact error report is :</FONT>
<FONT COLOR="#000000">invalid expression body'self.incomingChannels&lt;self.outputs-&gt;input Rate' </FONT>
<FONT COLOR="#000000">Cause:Error in(variableExpCS):(Unrecognized variable:(inputRate))</FONT>

<FONT COLOR="#000000">As I told ,the constraint is added to Link Mapping(Channel).if here by </FONT>
<FONT COLOR="#000000">self you mean Gather ,then how to access to Gather in target end </FONT>
<FONT COLOR="#000000">constraint of Channel?</FONT>

<FONT COLOR="#000000">By the way ,in Source end constraint of Channel,there is already 'self&lt;&gt; </FONT>
<FONT COLOR="#000000">oppositeEnd'.And can you tell me the meaning of source /target in the term </FONT>
<FONT COLOR="#000000">source/target End constraint?</FONT>


<FONT COLOR="#000000">Thanks a lot!</FONT>

<FONT COLOR="#000000">Ye Liu</FONT>



</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-LXIYASpbj7/MdN7z6Oyu--
Previous Topic:Question about compartment
Next Topic:Compartment boundry
Goto Forum:
  


Current Time: Thu Mar 28 08:44:45 GMT 2024

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

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

Back to the top