Skip to main content


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 10:53 Go to next message
Eclipse UserFriend
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 13:47 Go to previous message
Eclipse UserFriend
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: Fri Apr 19 19:54:28 GMT 2024

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

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

Back to the top