Run EMF Validation of an Ecore model outside of Eclipse
Asked Answered
C

1

6

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

Chemotherapy answered 8/9, 2010 at 12:48 Comment(0)
P
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.

Pouched answered 8/9, 2010 at 14:32 Comment(2)
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?Chemotherapy
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.Pouched

© 2022 - 2024 — McMap. All rights reserved.