Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "OCL/Pivot Model"

< OCL
m
m (Ed.willink.me.uk moved page MDT/OCL/Pivot Model to OCL/Pivot Model: Decontainerizing)
 
(6 intermediate revisions by the same user not shown)
Line 17: Line 17:
 
=== MOF-compliant modeling ===
 
=== MOF-compliant modeling ===
  
Ecore is slightly different to EMOF and consequently Eclipse UML is slightly different to OMG UML. This can be very awkward when struct MOF-compliance is necessary.
+
Ecore is slightly different to EMOF and consequently Eclipse UML is slightly different to OMG UML. This can be very awkward when strict MOF-compliance is necessary.
  
 
MOF-compliance is supported by adapting the traditional Ecore or UML meta-model with either an Eclipse-UML-Pivot-MM or an Eclipse-Ecore-Pivot-MM. Each of these adapted meta-models generalise the Pivot-Meta-Model that is as compliant as possible with the MOF and UML standards. This compliance extends to reflection and so the getMetaClass() operation will return a Pivot Meta Model instance rather an Ecore Meta Modekl Instance.
 
MOF-compliance is supported by adapting the traditional Ecore or UML meta-model with either an Eclipse-UML-Pivot-MM or an Eclipse-Ecore-Pivot-MM. Each of these adapted meta-models generalise the Pivot-Meta-Model that is as compliant as possible with the MOF and UML standards. This compliance extends to reflection and so the getMetaClass() operation will return a Pivot Meta Model instance rather an Ecore Meta Modekl Instance.
  
 
The planned implementation of the adapters will use Ecore Adapters so that any changes using, for instance the Eclipse Ecore API, will be visible via the MOF Pivot API and vice-versa.
 
The planned implementation of the adapters will use Ecore Adapters so that any changes using, for instance the Eclipse Ecore API, will be visible via the MOF Pivot API and vice-versa.
 +
 +
==== UnifiedOCL editor ====
 +
 +
The [[MDT/OCL/OCLinEcore | OCLinEcore]] editir will be enhanced to support the full capabilities of the Pivot Meta-Model and so will support concepts such as Association and subsetting properties, with first class OMG-like textual syntaxes. This will make advanced Ecore facilities such as [http://www.eclipse.org/modeling/emf/docs/overviews/FeatureMap.pdf EFeatureMap] directly accessible to modellers.
  
 
=== Dynamic UML ===
 
=== Dynamic UML ===
Line 29: Line 33:
 
There is no counterpart for UML, which requires that the UML meta-model is manually exported to Ecore in order to use Ecore code generation or dynamic instantiation. This manual export must be repeated for each change.
 
There is no counterpart for UML, which requires that the UML meta-model is manually exported to Ecore in order to use Ecore code generation or dynamic instantiation. This manual export must be repeated for each change.
  
The master/slave relationship between Pivot Meta-Models should make this transparent. When a slave Eclipse-Ecore-Pivot MM is trackling a master Eclipse-UML-Pivot-MM, tooling such as code generators may use the Eclipse Ecore API to access UML meta-models. The UML to Ecore conversion will be performed automatically by the adapters; UML to Pivot, then Pivot to Ecore or vice-versa. A change made in any meta-model dialect will be prtopagayted up via the master pivot to the master meta-model and then propagated down to keep all meta-models coherent.
+
The master/slave relationship between Pivot Meta-Models should make this transparent. When a slave Eclipse-Ecore-Pivot MM is tracking a master Eclipse-UML-Pivot-MM, tooling such as code generators may use the Eclipse Ecore API to access UML meta-models. The UML to Ecore conversion will be performed automatically by the adapters; UML to Pivot, then Pivot to Ecore or vice-versa. A change made in any meta-model dialect will be propagated up via the master pivot to the master meta-model and then propagated down to keep all meta-models coherent.
  
 
The master/slave approach will support one master and many slaves, without constraining the master to be UML or Ecore; the approach should be extensible to any meta-model dialect, provided the meta-model dialect supports every concept supported by the MOF Pivot Meta-Model. For Eclipse UML and Ecore, this mostly just requires discovinering the poorly documented EAnnotations used to persist special functionality.
 
The master/slave approach will support one master and many slaves, without constraining the master to be UML or Ecore; the approach should be extensible to any meta-model dialect, provided the meta-model dialect supports every concept supported by the MOF Pivot Meta-Model. For Eclipse UML and Ecore, this mostly just requires discovinering the poorly documented EAnnotations used to persist special functionality.
  
 +
=== OCL ===
  
 +
The primary motivation for this infrastructure is to fully support OCL for which referenceable declarations may originate from user-defined meta-models, the OCL-defined standard library or from user-supplied Complete OCL documents.
  
==== Pivot Structural Model ====
+
The OCL specification neglects to specify how library and document contributions can be referenced. The Pivot meta-model is therefore a prototype for a future OMG OCL resolution of these oversights.
 
+
The Pivot Model isolates OCL from the details of any particular UML or Ecore (or EMOF or CMOF or ...) meta-model representation. OCL expressions can therefore be defined, analyzed and evaluated for a heterogeneous mix of meta-models for which an external representation to pivot model mapping has been defined. (Initially this mapping may be realised as a one shot transformation. In the longer term, the mapping must be a live adaptation in order for the pivot model to update automatically to external changes in the meta-model.)
+
 
+
The Pivot Model is arguably a major omission from the OMG OCL specification, which provides no clues as to how the OCL AST can reference a non-meta-model operation defined by an OperationContextDecl, or how an OperationCallExp can reference a standard library operation since there is no defined URI for the OCL Standard Library.
+
 
+
A custom pivot model may need to be created for each usage since each usage may customise OclAny in distinct ways. However most usages will not customise OclAny, so a lightweight approach is needed for simple usage whose costs are proportionate to complexity.
+
 
+
The Pivot Model is a merged meta-model with a class for each user-defined classifier and for each OCL Standard Library class. A "conformsTo" relationship is established from the "superType" relationships of the user meta-models. The merge imposes the additional OCL "conformsTo" relationships so that each root classifier in the user meta-models "conformsTo" OclType which "conformsTo" OclAny. Similarly OclVoid "conformsTo" each leaf classifier in the user meta-models. Additional model elements introduced by CompleteOCL are incorporated in the pivot model so that there is no observable difference between between a user-defined feature, a CompleteOCL feature or an OCL Standard LIbrary feature.
+
 
+
The Pivot Model needs to accommodate all the class-related concepts of UML, such as AssociationClasses, subset properties
+
and profiles. However there is no need for other facilities such as Use Cases or Deployments. The meta-model of the Pivot Model is therefore perhaps a distinct merge of UML packages analoguous to the Essential MOF merge.
+
  
With full class-related facilities in the pivot model, problems such as how to navigate non-navigable opposites in EMOF are isolated as a problem for EMOF and the EMOF to pivot model mapping. Ongoing discussions standardising Tags should allow these problems to be resolved.
+
The three sources of declarations are merged to form a merged OCL-Pivot-MM instance which provides the uniform treatment of the diverse declaration sources without corrupting the sources. The OCL pivot model tracks changes to the defining models but does not propagate changes backwards. Access through the OCL API will therefore provide read-only access to the merged model.
  
The Pivot Model need never be persisted, however its construction is predictable and so the pivot model can be the provider of consistent URIs for use by the OCL AST.
+
Since the OCL pivot model tracks in only one direction, it may be appropriate to normalise certain difficulties such as unnavigable opposites in the merged model, where the merged copies can be changed without impacting the source definitions.
  
The Pivot Model has explicit generic parameters, just like Java or Ecore or UML, rather than the implicit generics that lurk behind a coherent interpretation of Set(T), Collection::product(T2), Tuple etc.
+
== The Pivot Meta-Model ==
  
With a uniform merged representation in the pivot model, it is fairly easy in principle to provide substantial reflective facilities in the pivot model. In practice, provision of reflection could undermine OCL's current support for full static type analysis. This hazard need not arise if the reflection fully generic and so avoids the problems that Java and Ecore had in maintaining compatibility when generics were introduced once reflection was already established.
+
The Pivot Meta-model should be identical to anything that a future version of the OMG OCL specification endorses as the solution to resolving diverse declaration references. The OMG OCL specification is evolving to resolve UML alignment issues and so any Pivot Meta-model proposal that is poorly aligned with UML is unlikely to be adopted.
  
==== Pivot AST Model ====
+
It would appear that the Pivot Meta-model should be as similar to UML as possible. This can probably be achieved by defining the Pivot Meta-model as a distinct merge of relevant UML Infrastructure packages.
  
The primary AST will use the Pivot Model's classes and features. It can be converted between Ecore and UML representations when necessary.
+
=== Implementation Approach ===
  
(It is unclear whether the Pivot Model will just be a third binding of the generic binding, or whether an evolution back to non-generic bindings is merited thereby giving 100% compliance with an OMG endorsed Pivot model.)
+
The Ecore meta-model is defined by Ecore.ecore and realised with the assistance of Ecore.genmodel and Ecore JET templates as Ecore*.java and Ecore*Impl.java where Ecore* denotes the many classes such as EAttribute etc that realise the model.  
  
==== Pivot Standard Library Model ====
+
The UML meta-model is similarly defined by UML.ecore and realised with the assistance of UML.genmodel and Ecore/UML JET templates as UML*.java and UML*Impl.java where UML* denotes the many classes such as Property etc that realise the model.
  
Using the Pivot Model to represent the OCL standard library allows the OCL Library to be fully model driven, allowing variant OCL standard libraries to realise alternative interpretations of the OCL specifications and extended libraries to support other languages.
+
The Pivot meta-model is defined by Pivot.ecore and realised with the assistance of Pivot.genmodel and Ecore JET templates as Pivot*.java where Pivot* denotes the many interfaces such as PivotProperty etc that realise the model. It may be that only Pivot interfaces are used.
  
The standard library model provides the declarations used by the parser, analyzer and validator and associates a Java class with each feature. Extension or modification therefore requires alternate or additional declarations and/or Java classes.
+
The mapping from Pivot to Ecore or UML is defined by Pivot2Ecore.qvtr or Pivot2UML.qvtr from which a bespoke Acceleo Java code generation provides the EcorePivot*.java or UMLPivot*.java adapters. Note that QVTr is used as a convenient declarative syntax; the QVTr is not executed, so the lack of a QVTr execution engine is not a problem. The QVTr declarative structure captures the pair-wise mapping of Pivot to Ecore names, and for the leaves, some statement such as: readOnly := inverted(changeable); identifies 'inverted' as an irregular mapping policy hard coded in the Acceleo code generator template. Acceleo therefore replaces JET, and a *.qvtr replaces a *.genmodel in the 'conventional' form of Java generation.

Latest revision as of 13:39, 15 May 2016

The Pivot Meta-Model is the key to an integrated fully OMG-compliant implementation in the MDT/OCL 4.X architecture. The usage of the Pivot Meta-Model is shown in

MDT-OCL-Pivot-architecture.png

The diagram is similar to a UML Object Diagram in which boxes denote named instances of underlined classes. However in this diagram each box denotes a named model with all its constituent model element instances of corresponding meta-model elements.

The simple is-a arrows indicate that the relevant source meta-model elements generalise related target meta-model elements.

The block arrows denote run-time information flow to maintain equivalence of one meta-model with another.

Use Cases

Traditional Ecore or UML modeling

A traditional Eclipse Ecore or Eclipse UML user makes use of their instance of an Eclipse-Ecore-MM or Eclipse-UML-MM in traditional fashion. This usage is denoted as using the Eclipse UML or Eclipse Ecore APIs and requires no co-ordination between disparate meta-models.

MOF-compliant modeling

Ecore is slightly different to EMOF and consequently Eclipse UML is slightly different to OMG UML. This can be very awkward when strict MOF-compliance is necessary.

MOF-compliance is supported by adapting the traditional Ecore or UML meta-model with either an Eclipse-UML-Pivot-MM or an Eclipse-Ecore-Pivot-MM. Each of these adapted meta-models generalise the Pivot-Meta-Model that is as compliant as possible with the MOF and UML standards. This compliance extends to reflection and so the getMetaClass() operation will return a Pivot Meta Model instance rather an Ecore Meta Modekl Instance.

The planned implementation of the adapters will use Ecore Adapters so that any changes using, for instance the Eclipse Ecore API, will be visible via the MOF Pivot API and vice-versa.

UnifiedOCL editor

The OCLinEcore editir will be enhanced to support the full capabilities of the Pivot Meta-Model and so will support concepts such as Association and subsetting properties, with first class OMG-like textual syntaxes. This will make advanced Ecore facilities such as EFeatureMap directly accessible to modellers.

Dynamic UML

Ecore supports creation of dynamic instance models by invoking Create Dynamic Instnace in the Sample Ecore Editor. This dynamic instance may then be editoed in the Sample Reflective Ecore Editor.

There is no counterpart for UML, which requires that the UML meta-model is manually exported to Ecore in order to use Ecore code generation or dynamic instantiation. This manual export must be repeated for each change.

The master/slave relationship between Pivot Meta-Models should make this transparent. When a slave Eclipse-Ecore-Pivot MM is tracking a master Eclipse-UML-Pivot-MM, tooling such as code generators may use the Eclipse Ecore API to access UML meta-models. The UML to Ecore conversion will be performed automatically by the adapters; UML to Pivot, then Pivot to Ecore or vice-versa. A change made in any meta-model dialect will be propagated up via the master pivot to the master meta-model and then propagated down to keep all meta-models coherent.

The master/slave approach will support one master and many slaves, without constraining the master to be UML or Ecore; the approach should be extensible to any meta-model dialect, provided the meta-model dialect supports every concept supported by the MOF Pivot Meta-Model. For Eclipse UML and Ecore, this mostly just requires discovinering the poorly documented EAnnotations used to persist special functionality.

OCL

The primary motivation for this infrastructure is to fully support OCL for which referenceable declarations may originate from user-defined meta-models, the OCL-defined standard library or from user-supplied Complete OCL documents.

The OCL specification neglects to specify how library and document contributions can be referenced. The Pivot meta-model is therefore a prototype for a future OMG OCL resolution of these oversights.

The three sources of declarations are merged to form a merged OCL-Pivot-MM instance which provides the uniform treatment of the diverse declaration sources without corrupting the sources. The OCL pivot model tracks changes to the defining models but does not propagate changes backwards. Access through the OCL API will therefore provide read-only access to the merged model.

Since the OCL pivot model tracks in only one direction, it may be appropriate to normalise certain difficulties such as unnavigable opposites in the merged model, where the merged copies can be changed without impacting the source definitions.

The Pivot Meta-Model

The Pivot Meta-model should be identical to anything that a future version of the OMG OCL specification endorses as the solution to resolving diverse declaration references. The OMG OCL specification is evolving to resolve UML alignment issues and so any Pivot Meta-model proposal that is poorly aligned with UML is unlikely to be adopted.

It would appear that the Pivot Meta-model should be as similar to UML as possible. This can probably be achieved by defining the Pivot Meta-model as a distinct merge of relevant UML Infrastructure packages.

Implementation Approach

The Ecore meta-model is defined by Ecore.ecore and realised with the assistance of Ecore.genmodel and Ecore JET templates as Ecore*.java and Ecore*Impl.java where Ecore* denotes the many classes such as EAttribute etc that realise the model.

The UML meta-model is similarly defined by UML.ecore and realised with the assistance of UML.genmodel and Ecore/UML JET templates as UML*.java and UML*Impl.java where UML* denotes the many classes such as Property etc that realise the model.

The Pivot meta-model is defined by Pivot.ecore and realised with the assistance of Pivot.genmodel and Ecore JET templates as Pivot*.java where Pivot* denotes the many interfaces such as PivotProperty etc that realise the model. It may be that only Pivot interfaces are used.

The mapping from Pivot to Ecore or UML is defined by Pivot2Ecore.qvtr or Pivot2UML.qvtr from which a bespoke Acceleo Java code generation provides the EcorePivot*.java or UMLPivot*.java adapters. Note that QVTr is used as a convenient declarative syntax; the QVTr is not executed, so the lack of a QVTr execution engine is not a problem. The QVTr declarative structure captures the pair-wise mapping of Pivot to Ecore names, and for the leaves, some statement such as: readOnly := inverted(changeable); identifies 'inverted' as an irregular mapping policy hard coded in the Acceleo code generator template. Acceleo therefore replaces JET, and a *.qvtr replaces a *.genmodel in the 'conventional' form of Java generation.

Back to the top