| Re: OCL constrains [message #46413] | 
Wed, 23 August 2006 07:42   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi dzh, 
 
Remark: When posting the same question to multiple newsgroups, please use a  
single posting so that an answer on any group is an answer on all groups. 
 
At the moment you can't write an OCL expression directly as you intend. 
However, you could make use of EMF reflection and slightly reformulate it as  
'self.eClass() <> oppositeEnd.eClass() '. 
This can be used as soon as  
https://bugs.eclipse.org/bugs/show_bug.cgi?id=152003 gets implemented in  
EMFT, see 
news:ea6mkj$7nh$1@utils.eclipse.org thread on this matter. 
 
1) However, you can still check an instance for its type by  
'oclIsTypeOf(OclType)' and write the expression something like 
    'self.oclIsTypeOf(Activity) implies not  
oppositeEnd.oclIsTypeOf(Activity) and ...' 
 
2) If you can modify your meta-model, you could add a nodeType attribute and  
check it in your constraint if you wish to make 
your constraint simpler. 
 
Regards, 
/Radek 
 
 
"dzh" <dzhpingbo@sohu.com> wrote in message  
news:ech4vq$pdq$1@utils.eclipse.org... 
>I have a flow which can link with data and activity, the picture shows my 
> model. 
> 
> I want to do such constrains: 
> 1, activity can not connect with activity 
> 2,data can not connect with data 
> in other words, I don't want a node connect with another node with the  
> same 
> class type. 
> 
> what does the expression should I write in the "sourceEnd constraint" or 
> "targetEnd constraint" in link constraint in gmfmap? 
> 
> can I get the class type of sourceEnd and targetEnd in ocl expression ?  
> self.getClass() <> oppositeEnd.getClass() 
> 
>
 |  
 |  
  | 
 | 
 | 
 | 
 | 
| Re: OCL constrains [message #47252 is a reply to message #47000] | 
Mon, 28 August 2006 19:53   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi dzh, 
 
Sorry, for the late response, I somehow overlooked your latest post. 
As for your multiple connection constraint, 
AFAIU you want to disallow multiple flows connecting to the same Data and  
Activity node. 
Try the following sourceEnd: 
oppositeEnd <> null implies not self.subDiagram.flows->exists(f| f.activity  
= self and f.data = oppositeEnd) 
 
/Radek 
 
"dzh" <dzhpingbo@sohu.com> wrote in message  
news:ecn9mm$d5f$1@utils.eclipse.org... 
> 
> "Radek Dvorak" <radek.dvorak@borland.com>  
> д
 |  
 |  
  | 
 | 
| Re: OCL constrains [message #586249 is a reply to message #46413] | 
Thu, 24 August 2006 12:46   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Thank you for your answers:) 
now I can create multiple connections between node A and node B, but I want  
to limit user can only create one connection between nodes. 
I know I can check this with audit function in gmfmap, but it was used to  
show errors when I already create muliple connections between nodes, I want  
to prevent user from creating multiple connections between nodes, how can I  
implement this function? 
 
best regards, 
dzh
 |  
 |  
  | 
| Re: OCL constrains [message #586339 is a reply to message #46634] | 
Thu, 24 August 2006 20:01   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
The best way to enforce a constraint like this is directly in your metamodel  
by using multiplicity 
and unique properties for a reference. 
The connection creation should follow such restrictions. 
 
I am not sure I fully understand your use-case at this point as you are not  
much specific with respect to the metamodel. 
However, If you are able to achieve this with audits, doing so by using link  
constraints is just an analogy only 
with the following difference: 
link constraints are evaluated against nodes before a connection is  
established 
while audits are checked against the current state. 
 
/Radek 
 
 
"dzh" <dzhpingbo@sohu.com> wrote in message  
news:eckl5i$dkk$1@utils.eclipse.org... 
> Thank you for your answers:) 
> now I can create multiple connections between node A and node B, but I  
> want to limit user can only create one connection between nodes. 
> I know I can check this with audit function in gmfmap, but it was used to  
> show errors when I already create muliple connections between nodes, I  
> want to prevent user from creating multiple connections between nodes, how  
> can I implement this function? 
> 
> best regards, 
> dzh 
>
 |  
 |  
  | 
 | 
| Re: OCL constrains [message #586596 is a reply to message #47000] | 
Mon, 28 August 2006 19:53   | 
 
Eclipse User  | 
 | 
 | 
   | 
 
Hi dzh, 
 
Sorry, for the late response, I somehow overlooked your latest post. 
As for your multiple connection constraint, 
AFAIU you want to disallow multiple flows connecting to the same Data and  
Activity node. 
Try the following sourceEnd: 
oppositeEnd <> null implies not self.subDiagram.flows->exists(f| f.activity  
= self and f.data = oppositeEnd) 
 
/Radek 
 
"dzh" <dzhpingbo@sohu.com> wrote in message  
news:ecn9mm$d5f$1@utils.eclipse.org... 
> 
> "Radek Dvorak" <radek.dvorak@borland.com>  
> д
 |  
 |  
  | 
Powered by 
FUDForum. Page generated in 0.05658 seconds