Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » help me with a constraint please :)
help me with a constraint please :) [message #50427] Thu, 07 February 2008 05:53 Go to next message
Eclipse User
Originally posted by: ingelin.isfeldt.gmail.com

Newbie to OCL and here is mye question:

In my model, a Puzzle contains Field. Row, Column and Box extends Field.
Row contains Cell and Row, Column and Box refers to cells.

Now, from my Puzzle I need to check that any row and column has exactly
one cell in common.

Any ideas for this?

Hope someone can help me out :)

Thanks!
Re: help me with a constraint please :) [message #50511 is a reply to message #50427] Fri, 08 February 2008 08:47 Go to previous message
Eclipse User
Originally posted by: cdamus.ca.ibm.com

Hi, ingelin,

An answer will depend on what, precisely, your model looks like.

Is the association between Column and Cell bidirectional? If so, assuming
conventional association-end names, the following might work:

context Row
inv unique_cells: self.cell->isUnique(c : Cell | c.column)

This would work also in the case that your model is a UML model, and not an
Ecore model, because OCL in UML can navigate non-navigable and even unnamed
association ends.

Otherwise, if a Cell does not know its column, you might try:

context Row
inv unique_cells: self.cell->isUnique(c : Cell |
Column.allInstances()->any(col | col.cell->includes(c)))

but this wastes time looking at all Columns, not just those in the same
puzzle.

As I say, this really depends on the specific structure of your model.

HTH,

Christian


ingelin wrote:

> Newbie to OCL and here is mye question:
>
> In my model, a Puzzle contains Field. Row, Column and Box extends Field.
> Row contains Cell and Row, Column and Box refers to cells.
>
> Now, from my Puzzle I need to check that any row and column has exactly
> one cell in common.
>
> Any ideas for this?
>
> Hope someone can help me out :)
>
> Thanks!
Previous Topic:OCL and uml::InstanceSpecification
Next Topic:EMF many-valued features, set or sequence?
Goto Forum:
  


Current Time: Thu Aug 28 09:27:06 EDT 2014

Powered by FUDForum. Page generated in 0.02641 seconds