2
votes

I want to add ocl to my .ecore metamodel with java code. But i cant find any example or tutorial.

So i want to ask is tihs possible or where can i find sample codes?

2

2 Answers

1
votes

Did you check OCLinEcore? It allows embed OCL in your ecore model and edit it like a text which may be edited with the aid of syntax and semantic validation and completion suggestions.

This is exerpt from the link:

OCL can be embedded in Ecore using annotations. Maintenance of these annotations is performed automatically by the OCLinEcore editor ... The embedded OCL becomes active when the appropriate delegate functionality is specified.

There are three type of delegate functionality:

  1. Setting Delegate
  2. Invocation Delegate
  3. Validation Delegate

Also there are invariants constraints.

0
votes

I see two alternatives:

  1. Use EVL (Epsilon Validation Language), it is included in EMF (Eclipse Modeling Framework). In that way, you just right click .ecore model and create a new EVL Validation (under Epsilon options). EVL syntax is well documented on Epsilon book https://www.eclipse.org/epsilon/doc/book/.

  2. Use OCL directly. For this purpose yo need to install OCL component on EMF. So, if you are using Eclipse, Help > Install Modeling Components > Find: OCL. Check the obtained result. Now this tutorial could help you http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FCompleteOCLTutorial.html.

I wish this could help.