Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run EMF Validation of an Ecore model outside of Eclipse

I found nothing how to validate an Ecore model outside of Eclipse. Does someone know how to do this?

like image 679
Dr. Simon Harrer Avatar asked Sep 08 '10 12:09

Dr. Simon Harrer


1 Answers

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.

like image 168
ChrisH Avatar answered Nov 15 '22 09:11

ChrisH