Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Re: OCL constrains
Re: OCL constrains [message #46413] Wed, 23 August 2006 11:42 Go to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 #46611 is a reply to message #46413] Thu, 24 August 2006 15:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Thank you:)
"Radek Dvorak" <radek.dvorak@borland.com> д
Re: OCL constrains [message #46634 is a reply to message #46413] Thu, 24 August 2006 16:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

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 #46882 is a reply to message #46634] Fri, 25 August 2006 00:01 Go to previous messageGo to next message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 #47000 is a reply to message #46882] Fri, 25 August 2006 16:49 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

"Radek Dvorak" <radek.dvorak@borland.com> д
  • Attachment: model.JPG
    (Size: 45.26KB, Downloaded 153 times)
  • Attachment: audit Rules.JPG
    (Size: 26.84KB, Downloaded 111 times)
  • Attachment: tmp.JPG
    (Size: 13.09KB, Downloaded 129 times)
Re: OCL constrains [message #47252 is a reply to message #47000] Mon, 28 August 2006 23:53 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 #586228 is a reply to message #46413] Thu, 24 August 2006 15:20 Go to previous message
dzh is currently offline dzhFriend
Messages: 10
Registered: July 2009
Junior Member
Thank you:)
"Radek Dvorak" <radek.dvorak@borland.com> д
Re: OCL constrains [message #586249 is a reply to message #46413] Thu, 24 August 2006 16:46 Go to previous message
dzh is currently offline dzhFriend
Messages: 10
Registered: July 2009
Junior Member
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] Fri, 25 August 2006 00:01 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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 #586445 is a reply to message #46882] Fri, 25 August 2006 16:49 Go to previous message
dzh is currently offline dzhFriend
Messages: 10
Registered: July 2009
Junior Member
"Radek Dvorak" <radek.dvorak@borland.com> д
  • Attachment: model.JPG
    (Size: 45.26KB, Downloaded 110 times)
  • Attachment: audit Rules.JPG
    (Size: 26.84KB, Downloaded 104 times)
  • Attachment: tmp.JPG
    (Size: 13.09KB, Downloaded 97 times)
Re: OCL constrains [message #586596 is a reply to message #47000] Mon, 28 August 2006 23:53 Go to previous message
Radomil Dvorak is currently offline Radomil DvorakFriend
Messages: 249
Registered: July 2009
Senior Member
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>
> д
Previous Topic:'Live' validation in EMF vs EMFT
Next Topic:Live mode constraint not working correctly
Goto Forum:
  


Current Time: Thu Apr 25 09:28:42 GMT 2024

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

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

Back to the top