Bug 451340 - Annotation-based Validation Framework
Summary: Annotation-based Validation Framework
Status: CLOSED WONTFIX
Alias: None
Product: Sphinx
Classification: Automotive
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Amine Lajmi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-13 08:59 EST by Amine Lajmi CLA
Modified: 2024-05-07 00:52 EDT (History)
2 users (show)

See Also:


Attachments
The annotation-based validation framework plugins and feature (292.70 KB, application/x-zip-compressed)
2014-11-13 08:59 EST, Amine Lajmi CLA
no flags Details
An example of annotation-based validator (16.29 KB, application/x-zip-compressed)
2014-11-13 09:00 EST, Amine Lajmi CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Amine Lajmi CLA 2014-11-13 08:59:06 EST
Created attachment 248632 [details]
The annotation-based validation framework plugins and feature

== Problem statement ==

The standard EMF validation seems tightly coupled to the language metmodel and difficult to extend without modifying the .ecore file. Users want to have a more flexible/declarative mechanism. 

The idea could be to learn from Xtext and implement a validation mechanism that uses annotations to identify check methods and provide a framework that gets invoked for validation and error/info/warning methods similar to Xtext.
In addition/difference to plain Xtext, it would be nice if we could register more than one validator for a given meta-model (or even on a project basis), so that we can add project/product line specific validators.

The validation should integrate with the IDE (e.g. setting error log/problem markers when editing or saving) as well with an API (e.g. being able to access errors on a given resource programmatically after/before a transformation/workflow step).

== Proposed solution ==

A check-based validation framework is attached. The framework follows the same principle of the existing check-based framework of Xtext, as it uses @Chek annotated methods for validating model objects. The framework externalizes constraint categories as well as error/warning/info constants such as severity, message, comments, etc. into an external model (check catalog).

In order to guarantee backward compatibility with existing validators, and handle the contribution of other types of validators, a DispatchingValidator is also introduced. This validator is a composition of all the validators assigned to a given package, it should be the entry point for validation. It simply delegates validation to all the existing validators and its returned validation status is the logical “and” of the returned validation status of all the delegations. During this process diagnostics are chained following the delegation order, and the resulting diagnostic is the aggregation of all the delegates’ diagnostics.

To be able to handle the management of validators, a CheckValidationRegistry singleton is introduced. This registry wraps the standard EValidator.Registry singleton of EMF and provides utility methods to handle registration and add/remove delegates.
Comment 1 Amine Lajmi CLA 2014-11-13 09:00:58 EST
Created attachment 248633 [details]
An example of annotation-based validator
Comment 2 Balazs Grill CLA 2024-05-07 00:52:29 EDT
Closed stale issue before migration