The List Metamodel Refactoring example

Summary

In this example, we present some basic concepts of ATL through a simple use case. Our working context is the creation of a bridge between
two different versions of a List metamodel (A and B). This bridge consists on an ATL transformation from the version A to the version B.

In this example, we discover how:
to use automatic traceability support in ATL, to create an ordered set, to use operation on string type.

Introduction

This example deals with the refactoring of a simple metamodel. We want to bridge two different versions of a metamodel thanks to a model transformation.

The Metamodels

Metamodel A

The metamodel A is composed of two elements which represent a simple list of named elements.

Metamodel B

The metamodel B is a evolution of metamodel A. It defines the same concepts except RootB lost its name.

Refactoring Transformation

Transformation principles

In this transformation, we want to transform an element RootA into a RootB and to transform an element ElementA into a ElementB.
Some additional constraints should be respected:

The elements order in the list should be kept.

An ElementB should be created from the name of a RootA. This element is added at the first list position.

The name of each ElementB should start with 'B_'

To sum up, the created list will contain one more element than the initial list. This additional element is created from the name of the list root. It will be placed at the
first position of the list.

Transformation step by step

First, we create the skeleton of the rule "Root". A RootB element is created from a RootA element.

rule Root {
from
s : A!RootA
to
t : B!RootB (
)
}

We create now the rule called "Element". This rule transforms an ElementA into an ElementB. For the name of each ElementB, the name of the matching
ElementA is reused and 'B_' is added to respect our constraint defined in the transformation requirements.