Community
Participate
Working Groups
If validators property reportSuccesses is set to false and no constraint returns failure status (e.g. model is OK with no errors), validation returns NO_CONSTRAINTS_EVALUATED error instead of ALL_CONSTRAINTS_PASSED error. Code snippet: IBatchValidator validator = (IBatchValidator)ModelValidationService.getInstance().newValidator(EvaluationMode.BATCH); validator.setReportSuccesses(false); //all constraints are satisfied IStatus status = validator.validate( objects, monitor ); System.out.println(status); System output: Status OK: org.eclipse.emf.validation code=10 No constraints were evaluated. null Workaround: Wrap returned status into own IStatus class: class AroundValidationFrameworkBugStatus implements IStatus { private final IStatus status; public AroundValidationFrameworkBugStatus(IStatus status) { super(); this.status = status; } public IStatus[] getChildren() { return status.getChildren(); } //I could hard code constant or do this ... @SuppressWarnings("restriction") public int getCode() { int code = status.getCode(); if (code==org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.NO_CONSTRAINTS_EVALUATED) return org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED; return code; } public Throwable getException() { return status.getException(); } //I could hard code constant or do this ... @SuppressWarnings("restriction") public String getMessage() { if (org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED==getCode()) { return org.eclipse.emf.validation.internal.EMFModelValidationStatusCodes.ALL_CONSTRAINTS_PASSED_MSG; } return status.getMessage(); } public String getPlugin() { return status.getPlugin(); } public int getSeverity() { return status.getSeverity(); } public boolean isMultiStatus() { return status.isMultiStatus(); } public boolean isOK() { return status.isOK(); } public boolean matches(int severityMask) { return status.matches(severityMask); } }
Eclipse EMF Validation is moving away from this bugs.eclipse.org issue tracker to https://github.com/eclipse/emf-validation. If this issue is relevant to you and still present in the latest release: * Create a new issue at https://github.com/eclipse/emf-validation/issues/. * Use as title in GitHub the title of this Bugzilla ticket (may include the bug number or not, at your own convenience) * In the GitHub description, start with a link to this bugzilla ticket * Optionally add new content to the description if it can helps towards resolution * Update bugzilla ticket * Add to "See also" property (up right column) the link to the newly created GitHub issue * Add a comment "Migrated to <link-to-newly-created-GitHub-issue>" * Set status as CLOSED MOVED All issues that remain open will be automatically closed next week or so. Then the Bugzilla component for EMF Validation will be archived and made read-only.