Book a Demo

Author Topic: OCL constraints on operations  (Read 2435 times)

olafk

  • EA User
  • **
  • Posts: 29
  • Karma: +0/-0
    • View Profile
OCL constraints on operations
« on: February 15, 2006, 11:16:40 pm »
Hi all.

I am somewhat bamboozled by the entire OCL support offered by EA...

1. In all of the examples that I could find, it seems that its intended use is for model validation --- but I would've liked to express my own constraints through OCL. That is, express constraints on my own, real-life object instance populating the model.

2. Now, not being all too familiar with OCL, my first feeble attempts ended up looking like this:
Code: [Select]
body: self.allInstances()->select( i | i.number > number )
(in an operation, as a pre-condition; where number is both a class attribute as well as the name of the operation's input parameter; largely non-sensical and immaterial w.r.t. my question)

This generated "Invalid OCL" errors. Hmm... simple one would've thought. However, experimentation showed that

Code: [Select]
body: self.allInstances()->select( i.number > number )
worked just fine. What is happening here? Am I looking at the EA variant of OCL or is my understanding of OCL syntax incorrect?

3. Seeing that the syntax might be dubious, how about exporting such constraints to XMI? For instance, we are feeding EA models into AndroMDA - which translates constraints on operations into appropriate db queries. Can I attach a constraint to an operation without it being either a pre- or post-condition?

Comments, experiences anybody?

cheers,
-olaf