Book a Demo

Author Topic: Perform on-the-fly validation checks via OCL  (Read 3221 times)

jakob

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Perform on-the-fly validation checks via OCL
« on: April 21, 2011, 12:23:49 am »
Hi!

I'm implementing an Add-In for a custom domain specific language. With the help of the DSL's meta-model my Add-In should "observe" the editor while creating the model. When the editor tries to do something which is not in line with the metal model (e.g. linking two elements with an association not defined in the meta-model, or setting wrong cardinality) the Add-In should display an warning/error message and reject the editor's action.

In the EA documentation I read about the Model Validation but it seems that this Model Validation is only performed when the user invokes it manually. Additionally I was not able to figure out how I could reject some actions done by an editor. It seems the Model Validation only returns a list of errors.

I was thinking about using the Pre-New Events in my Add-In to perform these validation checks on my own to be able to reject certain actions. I don't want the validation rules to be hard coded into my Add-in instead I want to execute and check OCL statements which are derived from the meta-model.

And here is the final question ;): How can I perform these on-the-fly validation checks in my Add-In by executing certain OCL on the current model? Maybe there is something like OCLQuery(string OCL) which is similar to the SQLQuery (string SQL)
method of the Repository object? Or is there a possibility to invoke the EA built-in Model Validation via my Add-In?

Thanks a lot!
Jakob
« Last Edit: April 21, 2011, 12:24:12 am by jakob »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Perform on-the-fly validation checks via OCL
« Reply #1 on: April 21, 2011, 05:35:57 pm »
Jacob,

I think you'll have to write your own OCL interpreter.
I'm not sure about the ways to invoke the model validator, but I don't think these functions are exposed by the API. (if they are they should be Repository or Project Interface)

Geert

jakob

  • EA User
  • **
  • Posts: 39
  • Karma: +0/-0
    • View Profile
Re: Perform on-the-fly validation checks via OCL
« Reply #2 on: April 22, 2011, 06:19:04 am »
Hmm, ok. Are you aware of any existing OCL interpreter which could be used for this purpose?