|UML2 constraints -- problem with spec, repository model required [message #568556]
||Mon, 06 November 2006 13:03
| Michael Golubev
Registered: July 2009
(crossposted to eclipse.modeling.mdt, eclipse.tools.uml2)
I am trying to implement constraints support for the MDT Class diagram, and
I have some troubles.
Any help is highly appreciated, especially from experts from MDT OCL
To understand the issue please take a look at the OMG UML2 specification
06-04-02, Figure 7.7 "Constraints diagram of the Kernel package". Note 2
associations +context/+ownedRule (with composite aggregation at the
"context" end) and +constrainedElement navigable from constraint to element.
Note that NONE of them IS DERIVED.
Also please take a look at the "Semantics" part of the paragraph 7.3.10 that
"For example, in OCL 'self' is used to refer to the __context__ element".
The problem is that given any repository model, we can change 3 different
things: context/owned rule containment, value specification's "body" and
It looks like only 2 of these 3 things may be changed independently --
either (context + body) that effectively makes "constrainedElement" to be
derived. Or (context + constrainedElement) that derives "body", or finally
(body + constrainedElement) that derives context.
To have an example, consider very simple UML model instance that contains
class Person with integer attribute age. We want to constraint age to be
positive ("AIP" -- stands for "age is positive").
There are a lot of possible repository models for this case.
E.g, we can arrange it as follows:
1. Model instance owns the Class "Person". Class owns Property "age".
Property owns Constraint "AIP", Constraint in turn owns ValueSpecification
like "self > 0". Note that once we set containment context to be a property,
we HAVE TO use "self" to denote the context element (property), so we can
not write AIP body as, say "self.age > 0". Note that once we set context and
body, we can not say that constrainedElement is some independent "Actor" --
the pair of context/body effectively derives the contextElement.
We had a chance to arrange model using other way:
2. Model owns the Class "Person". Class owns the Property age. The same
class (in contrast to the Property in the first arrangement) owns Constraint
"AIP". Assume that at first we set the constrainedElement association to
reference the property and now we are wondering what may be the constraint
body. Given the prerequisite that "self" ultimately has to express the class
(due to "Semantics" part of the 7.3.10 spec), we have no chances to define
body other than "self.age > 0" -- any other left part of the body will not
give us the correct preset value for constrainedElement.
It is not the "theoretical" question.
The graphical representation of the repository model should be:
- the Constraint rectangle,
- Class rectangle
- Property label
- and some link between Constraint rectangle and _something_.
When looking for this "_something_", we can rely either on the
context/ownedRule association or on the constrainedElement association. I am
rising this issue mainly to choose one of them to visualize.
Powered by FUDForum
. Page generated in 0.01771 seconds