Family To Persons (B)

Bx Examples Repository

Title: FamilyToPersons (B)

Version: 0.1

Type: Industrial, Sketch, Now a benchmarx

Overview

This is a well-known example adapted from the ATL Zoo.
It is sometimes referred to as the ATL "hello world" transformation.

This example has now been extended to a benchmarx described in detail in [1].

Models

The diagram below depicts a pair of consistent source and target models.
The source model to the left consists of a FamilyRegister, which contains a number of Families.
In this domain, a set of Members are connected to their Family via a reference that represents their "role" in the Family. For example, Cindy is a Member and plays the role of "mother" in the Family March.

The target model contains basically the same information, but represented quite differently.
There is no concept of a Family as a container for family members.
All Persons are placed directly into a global PersonsRegister.
While it is possible to guess who belongs to the same family via a comparison of surnames, this only works if surnames are unique and this is not the case in general.
The roles in a family are represented in the target model by explicit types: Cindy March isa Mother

familyTopersons.PNG

Consistency

FamilyRegister corresponds to PersonsRegister, Members to Persons according to the role they play in their Family.
More precisely, a families model is consistent with a persons model if and only if (i) there is exactly one family register in the families model containing all families, (ii) every family member is in exactly one family, (iii) there is exactly one persons register in the persons model containing all persons, and (iiv) a bijective mapping between family members and persons can be established such that:

  1. Mothers and daughters (fathers and sons) are paired with females (males).
  2. The name of every person p is “f.name, m.name”, where m is the member (in family f ) paired with p.

Consistency Restoration

There are quite a few interesting deltas to try out: Moving Members in the source model between Families should result in appropriate renaming in the target model and vice versa.

Properties [optional section]

Variants [optional section]

The example can be extended by making the concept of a Family more realistic, e.g., allowing a Member to play different roles in multiple Families.

Constraints can be added, e.g., a Family can have either: a Father and a Mother, two Fathers, or two Mothers, etc. As the proposed consistency relation allows empty families, a constraint can be added to forbid empty families.

Finally, more relationships can be added between Members and Persons, e.g., marriage relationships, grandparents/grandchildren, in-laws, etc.

Discussion

The example requires some interesting bidirectional attribute manipulation to "extract" families from target models.
Structure (in the source model) is also mapped to types (in the target model).

References [optional section]

See the ATL Zoo

[1] Anthony Anjorin, Zinovy Diskin, Frédéric Jouault, Hsiang-Shang Ko, Erhan Leblebici, Bernhard Westfechtel: Benchmarx Reloaded: A Practical Benchmark Framework for Bidirectional Transformations, BX 2017, 2017.

Author(s)

Anthony Anjorin

Reviewer(s)

Comments

Artefacts [optional section]

A virtual machine hosted on Share is available with a workspace containing both (Ecore) metamodels, the concrete example used above, and a TGG formalizing the consistency relation as a set of rules:

A virtual machine for the related benchmarx and implementations with various bx tools is also available on Share:

Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.