Entity Merging/Structure Abstraction

This is a modularisation pattern which specialises Phased Construction.

Summary

One target model entity type is updated using data from two or more different source model entity types. Separate rules should be used to define the updates from separate sources.

Application conditions

This pattern is used when a target entity type amalgamates data from several different source entities. The target entity type will appear in the succedent of two or more rules and each rule will create or update instances of it.

Solution

Define the separate updates as distinct rules, creating the target instance in the first rule, and using some means of object lookup to locate this instance for update by subsequent rules.

In cases where a closely semantically related group of source elements are mapped to a single target element, using a multiple matching rule, separate rules are not suitable. This could be termed the Structure Abstraction pattern.

Benefits

This pattern can be used to improve the decomposition of the specification, simplifying individual rules. It should be checked that rules Ri and Rj which may update the same instance do not semantically interfere with each other: they either update entirely separate and independent sets of features of the instance, or they update shared features (which must be set-valued association ends), in a consistent and order-independent way (by both adding elements to the association ends). This enables the rules to be implemented by successive phases.

The mapping of identity attributes from source objects to target objects can be non-injective, but in such a case successive updates to the same target object from different source objects must also be non-interfering.

Applications and examples

The pattern is applicable to the same categories of transformations as Phased Construction, but it is particularly relevant to abstraction transformations or to model-merging transformations, which combine two separate models into a single model.

An alternative form of the UML to relational database transformation could take account of inheritance in the source model, and only creates relational tables for root classes in the source model inheritance hierarchy, the data of subclasses is then merged into these tables. Tables are created (for root classes only) by one rule and then updated by another, so this transformation conforms to the pattern.

Related patterns

The pattern is a special case of Phased Construction. This pattern is referred to as the global source to local target type of transformation in (Cuadrado et al, 2009). The node abstraction pattern in (Iacob et al, 2008) corresponds to a case of Structure Abstraction, as does flattening. The reverse transformation of an entity merging is an entity splitting transformation.

In order to look up already existing t : T1 objects, to update them with additional data, some mechanism such as trace-based lookup or the Object Indexing pattern must be used.

The pattern can be extended to the Model Merging architectural pattern in cases where the input model can be split into smaller models, together with a separation of the transformation into target creation and elaboration sub-transformations.

(Cuadrado et al., 2009) J. Cuadrado, J. Molina, Modularisation of model transformations through a phasing mechanism, Software Systems Modelling, Vol. 8, No. 3, pp. 325--345, 2009.

(Iacob et al, 2008) M. E. Iacob, M. W. A. Steen, L. Heerink, Reusable model transformation patterns, Enterprise Distributed Object Computing Conference Workshops, 2008, pp. 1--10, doi:10.1109/EDOCW.2008.51.