Unique Id Constraint does not validate [message #1744332] |
Sun, 25 September 2016 23:35 |
Eclipse User |
|
|
|
Hello everyone,
I have the following example ECore metamodel with some OCL constraints:
...
/*
* OCL Constraint: UniqueIdentifiableInstance
* Every EClass that implements Identifiable interface has an identifier attribute. The value of this attribute must be unique for each instance.
*
*/
abstract class Identifiable { interface }
{
attribute identifier : String[1];
attribute name : String[?];
attribute description : String[?];
invariant UniqueIdentifiableInstance: self.oclType().allInstances()->forAll(id1, id2 |id1 <> id2 implies id1.identifier <> id2.identifier);
}
class SomeOtherEClass extends ParentClass,Identifiable;
...
Interestingly, I have used exactly the same Identifiable EClass in some other metamodel with the same OCL constraint, it is working correctly with that metamodel. But, this constraint does not work with the given example metamodel. By the way, this metamodel includes other EClasses with other OCL constraints that are correctly working.
Note: In Eclipse, I write the OCL constraints by right-clicking on the ECore file and choosing the OCLinECore editor. After creating a model of the metamodel, I right-click on the root element of the model and click "Validate" option (Live Validation is also on.).
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03822 seconds