Difference between revisions of "OCL/OCLinEcore"

From Eclipsepedia

< OCL
Jump to: navigation, search
m (New page: ===Classifier invariants=== ===Property initial and derived values=== ===Operation bodies, preconditions and postconditions===)
 
Line 1: Line 1:
 +
==Ecore Representation==
 +
 +
The OCL in Ecore annotations can be maintained directly using the Sample Ecore Editor. An example is shown below.
 +
 +
[[Image:MDT_OCL_Example_Ecore_Annotations.png|Example OCL in Ecore Annotations]]
 +
 +
The relevant annotations (a purple dumbbell with a paperclip) may be added by selecting New Child->EAnnotation and then New Child->Details Entry.
 +
 +
===EPackage configuration===
 +
 +
The embedded OCL becomes active when the appropriate delegate functionality is specified. In practice all three functionalities should be specified. This specification provides EMF with the required configuration information to access the extended functionality provided by these delegates.
 +
 +
====Setting Delegate====
 +
 +
The setting delegate functionality enables OCL expressions to define initial or derived value of an EStructuralFeature. Thus when eGet(CompanyPackage.Literals.COMPANY__SIZE) or Company.getSize() is invoked the OCL expression is evaluated to provide the value. In an OCL context, the corresponding eSet or setSize is not applicable.
 +
 +
The setting delegate is specified by an EPackage EAnnotation with:<br/>
 +
Source = "http://www.eclipse.org/emf/2002/Ecore"<br/>
 +
Key = "settingDelegates"<br/>
 +
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"<br/>
 +
 +
The delegate value matches an org.eclipse.emf.ecore.setting_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.
 +
 +
====Invocation Delegate====
 +
 +
The invocation delegate functionality enables OCL expressions to define the body of an EOperation. Thus when eInvoke(CompanyPackage.Literals.EMPLOYEE__REPORTS_TO) or Employee.reportsTo() is invoked the OCL expression is evaluated to provide the value.
 +
 +
The invocation delegate is specified by an EPackage EAnnotation with:<br/>
 +
Source = "http://www.eclipse.org/emf/2002/Ecore"<br/>
 +
Key = "invocation Delegates"<br/>
 +
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"<br/>
 +
 +
The delegate value matches an org.eclipse.emf.ecore.invocation_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.
 +
 +
====Validation Delegate====
 +
 +
The validation delegate functionality enables OCL expressions to define one or more invariants of an EClassifier. Thus when the EValidator is activated to validate the classifier, the OCL expressions are evaluated.
 +
 +
The validation delegate is specified by an EPackage EAnnotation with:<br/>
 +
Source = "http://www.eclipse.org/emf/2002/Ecore"<br/>
 +
Key = "validation Delegates"<br/>
 +
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"<br/>
 +
 +
The delegate value matches an org.eclipse.emf.ecore.validation_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.
 +
 
===Classifier invariants===
 
===Classifier invariants===
  

Revision as of 11:50, 27 February 2010

Contents

Ecore Representation

The OCL in Ecore annotations can be maintained directly using the Sample Ecore Editor. An example is shown below.

Example OCL in Ecore Annotations

The relevant annotations (a purple dumbbell with a paperclip) may be added by selecting New Child->EAnnotation and then New Child->Details Entry.

EPackage configuration

The embedded OCL becomes active when the appropriate delegate functionality is specified. In practice all three functionalities should be specified. This specification provides EMF with the required configuration information to access the extended functionality provided by these delegates.

Setting Delegate

The setting delegate functionality enables OCL expressions to define initial or derived value of an EStructuralFeature. Thus when eGet(CompanyPackage.Literals.COMPANY__SIZE) or Company.getSize() is invoked the OCL expression is evaluated to provide the value. In an OCL context, the corresponding eSet or setSize is not applicable.

The setting delegate is specified by an EPackage EAnnotation with:
Source = "http://www.eclipse.org/emf/2002/Ecore"
Key = "settingDelegates"
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"

The delegate value matches an org.eclipse.emf.ecore.setting_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.

Invocation Delegate

The invocation delegate functionality enables OCL expressions to define the body of an EOperation. Thus when eInvoke(CompanyPackage.Literals.EMPLOYEE__REPORTS_TO) or Employee.reportsTo() is invoked the OCL expression is evaluated to provide the value.

The invocation delegate is specified by an EPackage EAnnotation with:
Source = "http://www.eclipse.org/emf/2002/Ecore"
Key = "invocation Delegates"
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"

The delegate value matches an org.eclipse.emf.ecore.invocation_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.

Validation Delegate

The validation delegate functionality enables OCL expressions to define one or more invariants of an EClassifier. Thus when the EValidator is activated to validate the classifier, the OCL expressions are evaluated.

The validation delegate is specified by an EPackage EAnnotation with:
Source = "http://www.eclipse.org/emf/2002/Ecore"
Key = "validation Delegates"
Value = "http://www.eclipse.org/emf/2002/Ecore/OCL"

The delegate value matches an org.eclipse.emf.ecore.validation_delegate extension point usage in the org.eclipse.ocl.ecore plug-in that provides the delegate functionality. Multiple comma-separated delegates may be specified.

Classifier invariants

Property initial and derived values

Operation bodies, preconditions and postconditions