[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.mdt.uml2.ocl] How to validate uniqueness of class names within an entire package subtree


Works like hell ... OCL is so sweet :-) (I used "includes(self.base_Package)" instead of "includes(self)", to be more portable.)


I was not consciously aware yet of the context propagation used several times here, nor of the possibility to start an expression with a metaclass name. This opens some new perspectives for me. Thanks for this example!

One more question: I did not find allNamespaces() in the OCL 2.0 spec. Is this an extension in the OCL of Eclipse ?

Andy

Christian W. Damus wrote:
Hi, Andy,

Try this constraint in the context of the package that is the common root:

    Class.allInstances()->select(
        allNamespaces()->includes(self))->isUnique(name)

HTH,

Christian


Andreas Maier wrote:

In CIM, the names of all classes (and association classes)in the CIM
schema must be unique. The classes in the CIM schema are located in a
package subtree of mostly depth 3, starting from a common root. There
are about 1600+ classes and association classes. There are no other
classes in that package subtree.

I want to write an OCL constraint that validates that all those class
names are in fact unique as described above.

Any ideas how to do that ?

Andy