Home » Modeling » GMF (Graphical Modeling Framework) » Need Help with Link Constraints
Need Help with Link Constraints [message #168224] |
Tue, 15 January 2008 12:44 |
Eclipse User |
|
|
|
Originally posted by: Sid.v.v
Hello,
i hope someone can help me, im pretty unexperienced with GMF.
In my Project ive 2 different Types(lets say A and B)of Nodes. Links are
only allowed from NodeType A to Type B.
Thats working. But how can i achieve that multiple connection between the
same nodes are not allowed. (no multiple Connections with the same source
and the same target nodes)
Thanks for your help.
|
|
|
Re: Need Help with Link Constraints [message #168256 is a reply to message #168224] |
Tue, 15 January 2008 15:43 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
Sid wrote:
> Hello,
>
> i hope someone can help me, im pretty unexperienced with GMF.
> In my Project ive 2 different Types(lets say A and B)of Nodes. Links are
> only allowed from NodeType A to Type B. Thats working. But how can i
> achieve that multiple connection between the same nodes are not allowed.
> (no multiple Connections with the same source and the same target nodes)
> Thanks for your help.
>
Do you mean a 0,1 relation ? (not multiple). That can be done in the
ecore model (Upper bound: 1)
HTH,
Tomas Zijdemans
|
|
| |
Re: Need Help with Link Constraints [message #168287 is a reply to message #168272] |
Tue, 15 January 2008 16:38 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Boris, Sid,
Hope you don't mind me taking an opportunity to provide OCL tips :-)
This can also be expressed as
oppositeEnd.bs.excludes(self)
Cheers,
Christian
Boris Blajer wrote:
> Hi Sid,
>
> If A references B using an EReference 'bs', you should add a creation
> constraint with a target end constraint like this (I'm not 100% sure it
> will work right away, but can be used as an initial approximation):
> oppositeEnd.bs->select(e| e=self)->isEmpty()
>
>
> Best regards,
> Boris
>
> Sid wrote:
>> Hello,
>>
>> i hope someone can help me, im pretty unexperienced with GMF.
>> In my Project ive 2 different Types(lets say A and B)of Nodes. Links are
>> only allowed from NodeType A to Type B. Thats working. But how can i
>> achieve that multiple connection between the same nodes are not allowed.
>> (no multiple Connections with the same source and the same target nodes)
>> Thanks for your help.
>>
|
|
|
Re: Need Help with Link Constraints [message #168294 is a reply to message #168287] |
Tue, 15 January 2008 17:09 |
Boris Blajer Messages: 217 Registered: July 2009 |
Senior Member |
|
|
Hi Christian,
Thanks for the elegant alias :). One question, though:
Is it .excludes() or ->excludes()?
Best regards,
Boris
Christian W. Damus wrote:
> Hi, Boris, Sid,
>
> Hope you don't mind me taking an opportunity to provide OCL tips :-)
>
> This can also be expressed as
>
> oppositeEnd.bs.excludes(self)
>
> Cheers,
>
> Christian
>
>
> Boris Blajer wrote:
>
>> Hi Sid,
>>
>> If A references B using an EReference 'bs', you should add a creation
>> constraint with a target end constraint like this (I'm not 100% sure it
>> will work right away, but can be used as an initial approximation):
>> oppositeEnd.bs->select(e| e=self)->isEmpty()
>>
>>
>> Best regards,
>> Boris
>>
>> Sid wrote:
>>> Hello,
>>>
>>> i hope someone can help me, im pretty unexperienced with GMF.
>>> In my Project ive 2 different Types(lets say A and B)of Nodes. Links are
>>> only allowed from NodeType A to Type B. Thats working. But how can i
>>> achieve that multiple connection between the same nodes are not allowed.
>>> (no multiple Connections with the same source and the same target nodes)
>>> Thanks for your help.
>>>
>
|
|
|
Re: Need Help with Link Constraints [message #168309 is a reply to message #168294] |
Tue, 15 January 2008 17:17 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Ack!
Sorry, that should be
oppositeEnd.bs->excludes(self)
Good catch, Boris.
This distinguishes the OCL from the following:
oppositeEnd.bs.excludes(self)
which is actually a short-hand for
oppositeEnd.bs->collect(b | b.excludes(self))
which result would be some kind of Collection(Boolean) if the type of "b"
defined a compatible "excludes" operation returning a Boolean.
All collection operations, including the iterators, use "->"
Thanks,
Christian
Boris Blajer wrote:
> Hi Christian,
>
> Thanks for the elegant alias :). One question, though:
>
> Is it .excludes() or ->excludes()?
>
> Best regards,
> Boris
>
> Christian W. Damus wrote:
>> Hi, Boris, Sid,
>>
>> Hope you don't mind me taking an opportunity to provide OCL tips :-)
>>
>> This can also be expressed as
>>
>> oppositeEnd.bs.excludes(self)
>>
>> Cheers,
>>
>> Christian
-----8<-----
|
|
|
Re: Need Help with Link Constraints [message #168322 is a reply to message #168309] |
Tue, 15 January 2008 18:56 |
Eclipse User |
|
|
|
Originally posted by: Sid.v.v
Hello Thomas, Boris and Christian
thanks for your help. to make things a bit clearer here a little example:
-2 Nodes of Type A named 'xx' and 'tt'
-2 Nodes of Type B named 'yy' and 'uu'
the connections between them:
ConnectionNumber SourceNodeName(A) TargetNodeName(B)
Comment
1 xx yy
ok
2 xx uu
ok
3 tt yy
ok
4 xx yy
not ok *1
*1(because Connection Number 1 already connected this 2 Nodes)
i would like to share my ecore model, maybe you could give me some helpful
hints how to model this better. but i dont know how to put files up here.
Greetings Sid
|
|
|
Re: Need Help with Link Constraints [message #168330 is a reply to message #168322] |
Tue, 15 January 2008 19:09 |
Boris Blajer Messages: 217 Registered: July 2009 |
Senior Member |
|
|
Hi Sid,
The ocl above was meant exactly for this situation.
First, you need a target end constraint because it is checked when the
connection creation is being completed. In this context, oppositeEnd
variable resolves as the source of the connection. Likewise,
oppositeEnd.bs is a collection of all Bs pointed at by this connection
source. ->excludes(self) means that self (the target of the connection)
is not among the above collection. This, I believe it should work,
unless I am wrong with what 'self' and 'oppositeEnd' resolve to.
Best regards,
Boris
Sid wrote:
> Hello Thomas, Boris and Christian
>
> thanks for your help. to make things a bit clearer here a little example:
> -2 Nodes of Type A named 'xx' and 'tt'
> -2 Nodes of Type B named 'yy' and 'uu'
>
> the connections between them:
>
> ConnectionNumber SourceNodeName(A) TargetNodeName(B)
> Comment
> 1 xx
> yy ok
> 2 xx
> uu ok
> 3 tt
> yy ok
> 4 xx yy
> not ok *1
>
> *1(because Connection Number 1 already connected this 2 Nodes)
>
> i would like to share my ecore model, maybe you could give me some
> helpful hints how to model this better. but i dont know how to put files
> up here.
>
> Greetings Sid
>
|
|
| |
Re: Need Help with Link Constraints [message #168461 is a reply to message #168430] |
Wed, 16 January 2008 14:07 |
Boris Blajer Messages: 217 Registered: July 2009 |
Senior Member |
|
|
Hi Sid,
If I got it, the link class is Connection1, its source is Transition,
and its target is Place. If this is correct, the ocl should look
approximately like this:
oppositeEnd.consistofTC1->select(e| e.cP1=self)->isEmpty()
Christian will probably correct me if there's a more concise equivalent.
Best regards,
Boris
Sid wrote:
> Hello Boris,
>
> thanks for your Reply, ive tried to got it working, but i failed. i
> think the probleme is that i dont use a direct EReference between the Nodes
> Please have a look at my Ecore, ive uploaded a image at:
> http://link.imgshare.us/1fgEnK
>
> Thanks for your help!
>
> with kind regards,
> Sid
>
|
|
|
Re: Need Help with Link Constraints [message #168489 is a reply to message #168461] |
Wed, 16 January 2008 14:33 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Boris, Sid,
Since I was explicitly invited to respond... :-)
You could do:
not oppositeEnd.consistofTC1->exists(CP1=self)
Simply because it's nice to use the word "exists" in constraints checking
for existence of relationships. However, it is no more concise, really.
Note that we must use "CP1" because OCL uses the Ecore names, not the
generated Java names.
cW
Boris Blajer wrote:
> Hi Sid,
>
> If I got it, the link class is Connection1, its source is Transition,
> and its target is Place. If this is correct, the ocl should look
> approximately like this:
>
> oppositeEnd.consistofTC1->select(e| e.cP1=self)->isEmpty()
>
> Christian will probably correct me if there's a more concise equivalent.
>
> Best regards,
> Boris
>
> Sid wrote:
>> Hello Boris,
>>
>> thanks for your Reply, ive tried to got it working, but i failed. i
>> think the probleme is that i dont use a direct EReference between the
>> Nodes Please have a look at my Ecore, ive uploaded a image at:
>> http://link.imgshare.us/1fgEnK
>>
>> Thanks for your help!
>>
>> with kind regards,
>> Sid
>>
|
|
| |
Goto Forum:
Current Time: Thu Sep 26 20:35:40 GMT 2024
Powered by FUDForum. Page generated in 0.04324 seconds
|