Create Model Element/Object on Validation [message #1731394] |
Wed, 04 May 2016 22:59 |
Parsa Pourali Messages: 210 Registered: February 2014 |
Senior Member |
|
|
Hi,
I need to make sure that the model always has one instance of an Object in the model. Thus, I decided to add the following code in the validation xtend class to see if the object is not there, then create one!
So, in the following code, if wm does not have an instance of constraints , it should create one !
@Check
def checkConstraintsElementExist(WorldModel wm) {
if (wm.constraints == null) {
wm.constraints = FormlFactory::eINSTANCE.createConstraint
warning('World Model Must have at least one Constraint Element(even if empty)',
FormlPackage.Literals.WORLD_MODEL__CONSTRAINTS);
}
}
I tried to debug it, when the validator reaches to the line : wm.constraints = FormlFactory::eINSTANCE.createConstraint , it adds to wm , however it doesnot apply to the original model/resource. And if I run it next time it is still null !
Sorry, I'm not expert in XTend ! Is it the way it should be or I'm doing sth wrong ?
Thanks,
Bests,
Parsa
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03168 seconds