Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » OCL constrains
OCL constrains [message #26618] Wed, 23 August 2006 04:52 Go to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

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()


  • Attachment: model.JPG
    (Size: 45.26KB, Downloaded 103 times)
Re: OCL constrains [message #26918 is a reply to message #26618] Wed, 23 August 2006 07:42 Go to previous messageGo to next message
Eclipse UserFriend
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 #29038 is a reply to message #26918] Thu, 24 August 2006 11: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 #29115 is a reply to message #26918] Thu, 24 August 2006 12: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 #29489 is a reply to message #29115] Thu, 24 August 2006 20:01 Go to previous messageGo to next message
Eclipse UserFriend
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 #30760 is a reply to message #29489] Fri, 25 August 2006 12: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 120 times)
  • Attachment: audit Rules.JPG
    (Size: 26.84KB, Downloaded 100 times)
  • Attachment: tmp.JPG
    (Size: 13.09KB, Downloaded 107 times)
Re: OCL constrains [message #32117 is a reply to message #30760] Mon, 28 August 2006 19:53 Go to previous messageGo to next message
Eclipse UserFriend
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 #32152 is a reply to message #32117] Mon, 28 August 2006 20:17 Go to previous messageGo to next message
Eclipse UserFriend
Please use a GMF maintenance build as I recall there was a bug fix related
to link constraints for
link mappings like in your use-case.
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=148818)

/Radek

"Radek Dvorak" <radek.dvorak@borland.com> wrote in message
news:ecvvkv$6tt$1@utils.eclipse.org...
> 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 #33659 is a reply to message #32152] Wed, 30 August 2006 02:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Thank you for your answers, which encourage me not to give up:)
yes, I update gmf with the maintenance build:
1.0 Stream Maintenance Build
M20060824 Thu, 24 Aug 2006 -- 16:00 (-0400)

but it still gives such error:
Diagnosis of Constraint oppositeEnd <> null implies not
self.subDiagram.flows->exists(f| f.activity = self and f.data = oppositeEnd)
Invalid expression body 'oppositeEnd <> null implies not
self.subDiagram.flows->exists(f| f.activity = self and f.data =
oppositeEnd)'. Cause: Invalid expression body 'oppositeEnd <> null implies
not self.subDiagram.flows->exists(f| f.activity = self and f.data =
oppositeEnd)'.
Cause: ERROR in (variableExpCS): (Unrecognized variable: (subDiagram))

I tried the expression works fine in audit: "self.flows->forAll(r1, r2 |
r1.activity = r2.data implies r2.activity <> r1.data)" ,but in sourceEnd
constraint, it report error with Unrecognized variable: flows.

could you please give me advices about how to solve it?
"Radek Dvorak" <radek.dvorak@borland.com> д
  • Attachment: oclerror.JPG
    (Size: 47.96KB, Downloaded 133 times)
Re: OCL constrains [message #34555 is a reply to message #33659] Wed, 30 August 2006 11:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I assumed in the constraint I have posted that the source end context is
Activity node and
made a mistake taking the 'subDiagram' as a reference to its ProcessDiagram
container.
It was late, after 2:00AM so I saw the diamond which did not exist;-), sorry
for that.
Of course, the 'container' reference should be used instead of 'subDiagram'
which was unrecognized.

As for the contexts in general, It depends how you construct your link
mapping.
More precisely, what you specify as the LinkMapping::sourceMetaFeature which
becomes
the source end context.
Ananlogously, LinkMapping::linksMetaFeature forms the target end context.
The source or target roles are switched automatically in the editor if the
connection is
dragged in the opposite direction so you can stay focused on the link
mapping.

Regards,
/Radek

"dzh" <dzhpingbo@sohu.com> wrote in message
news:ed3cqc$nm1$1@utils.eclipse.org...
> Thank you for your answers, which encourage me not to give up:)
> yes, I update gmf with the maintenance build:
> 1.0 Stream Maintenance Build
> M20060824 Thu, 24 Aug 2006 -- 16:00 (-0400)
>
> but it still gives such error:
> Diagnosis of Constraint oppositeEnd <> null implies not
> self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)
> Invalid expression body 'oppositeEnd <> null implies not
> self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)'. Cause: Invalid expression body 'oppositeEnd <> null implies
> not self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)'.
> Cause: ERROR in (variableExpCS): (Unrecognized variable: (subDiagram))
>
> I tried the expression works fine in audit: "self.flows->forAll(r1, r2 |
> r1.activity = r2.data implies r2.activity <> r1.data)" ,but in sourceEnd
> constraint, it report error with Unrecognized variable: flows.
>
> could you please give me advices about how to solve it?
> "Radek Dvorak" <radek.dvorak@borland.com>
> д
Re: OCL constrains [message #34691 is a reply to message #33659] Wed, 30 August 2006 11:34 Go to previous messageGo to next message
Eclipse UserFriend
To be complete, I can see in your UML model that Flow::activity link source
reference is of Node type,
so a cast to Activity is needed here to access the 'container' reference.

oppositeEnd <> null implies not
self.oclAsType(Activity).container.flows->exists(f| f.activity = self and
f.data = oppositeEnd)

If there is still a mismatch in what is the source or target context here
(as I don't know your complete mapping),
I think you should be able to correct it yourself now.
Let me know if you have made it work ;-)

/Radek


"dzh" <dzhpingbo@sohu.com> wrote in message
news:ed3cqc$nm1$1@utils.eclipse.org...
> Thank you for your answers, which encourage me not to give up:)
> yes, I update gmf with the maintenance build:
> 1.0 Stream Maintenance Build
> M20060824 Thu, 24 Aug 2006 -- 16:00 (-0400)
>
> but it still gives such error:
> Diagnosis of Constraint oppositeEnd <> null implies not
> self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)
> Invalid expression body 'oppositeEnd <> null implies not
> self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)'. Cause: Invalid expression body 'oppositeEnd <> null implies
> not self.subDiagram.flows->exists(f| f.activity = self and f.data =
> oppositeEnd)'.
> Cause: ERROR in (variableExpCS): (Unrecognized variable: (subDiagram))
>
> I tried the expression works fine in audit: "self.flows->forAll(r1, r2 |
> r1.activity = r2.data implies r2.activity <> r1.data)" ,but in sourceEnd
> constraint, it report error with Unrecognized variable: flows.
>
> could you please give me advices about how to solve it?
> "Radek Dvorak" <radek.dvorak@borland.com>
> д
Re: OCL constrains [message #34971 is a reply to message #34691] Wed, 30 August 2006 22:05 Go to previous message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Thank you very much, It works perfectly:)
Very appreciate for all your answers for these days:)

"Radek Dvorak" <radek.dvorak@borland.com> д
Previous Topic:delete a node including all links start or end at this node
Next Topic:Implementing additional operations before a delete and deleting references.
Goto Forum:
  


Current Time: Fri May 02 05:18:14 EDT 2025

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

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

Back to the top