I found nothing how to validate an Ecore model outside of Eclipse. Does someone know how to do this?
Asked
Active
Viewed 1,588 times
6
1 Answers
4
Here is the skeleton of some code I've used to validate an EMF model outside of Eclipse:
EValidator.Registry.INSTANCE.put(YourPackage.eINSTANCE, new YourValidator());
BasicDiagnostic diagnostics = new BasicDiagnostic();
boolean valid = true;
for (EObject eo : yourResource.getContents()) {
Map<Object, Object> context = new HashMap<Object, Object>();
valid &= Diagnostician.INSTANCE.validate(eo, diagnostics, context);
}
There is more customization you can do, but I hope that helps get you started.
-
thanks for the answer. this validates the constraints defined. however, the constraint that an ID is unique throughout the document is not validated. do you have any leads on this? – Dr. Simon Harrer Sep 08 '10 at 15:40
-
I don't know all the ins and outs of EMF validation, so take this as a guess. Perhaps you can put that constraint check into YourValidator. – ChrisH Sep 08 '10 at 18:20