|
Re: OCL constrains [message #26918 is a reply to message #26618] |
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 #34555 is a reply to message #33659] |
Wed, 30 August 2006 11:13   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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>
> д
|
|
|
|
Powered by
FUDForum. Page generated in 0.04835 seconds