Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Need Help with Link Constraints
Need Help with Link Constraints [message #168224] Tue, 15 January 2008 12:44 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #168272 is a reply to message #168224] Tue, 15 January 2008 16:16 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
Messages: 217
Registered: July 2009
Senior Member
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 #168287 is a reply to message #168272] Tue, 15 January 2008 16:38 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
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 #168430 is a reply to message #168330] Wed, 16 January 2008 13:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Sid.v.v

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 #168461 is a reply to message #168430] Wed, 16 January 2008 14:07 Go to previous messageGo to next message
Boris Blajer is currently offline Boris BlajerFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
>>
Re: Need Help with Link Constraints [message #168552 is a reply to message #168489] Thu, 17 January 2008 08:15 Go to previous message
Eclipse UserFriend
Originally posted by: Sid.v.v

Hello Boris and Christian,

thank you both a lot. It is working now exactly as it should be :-) really
nice!

@Christian: your post at
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg10187.html
was helpful to, at first i had problems with the required ocl.ecore bundle.

I have a few more questions about gmf and ocl but i thinks its better to
start them in a new message.

Thank you, with kinds regards
Sid
Previous Topic:how do dynamic popup menus
Next Topic:xpt templates, where are the java imports defined?
Goto Forum:
  


Current Time: Thu Sep 26 20:35:40 GMT 2024

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

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

Back to the top