# Writing a new transforamtion

In the sequel, we describe briefly, how now transformations can be defined. Transformations have a model part that declares the transformations (and thus enable its use within the context of a transformation chain) and the operational definition at the code level.

## Define a transformation at the model level

Transformations are typically described in a model that is hosted and registered by a plugin providing also the associated imeplementation of the transformation.

A transformation is simply declared by creating an empty class with a suitable name and applying the "M2MTransformation" stereotype from the transformation profile.

Care should be taken by choosing a suitable package structure, as the qualified name of the transformation will be shown to link the declaration of the transformation with its implementation (see below).

## Linking a model transformation with its implementation

An implementation of a model-to-model transformation can implement one of the following interfaces (all in oepd.transformation.core.m2minterfaces), depending on the nature of the transformation:

- IM2MTrafoCDP: transformation is invoked by passing a deployment plan (or the root package). Use this open, when the transformation requires instance informations

- IM2MTrafoElem: will be automatically invoked for each element of a model that gets transformed. Use this (in combination with a suitable filtering), if no context information for the element to transform is required.

## Add a new transformation chain

A transformation is simply declared by creating an empty class with a suitable name and applying the "M2MTrafoChain" stereotype from the transformation profile.

The set of transformations to use is specified by declaring attributes typed with existing M2M transformations. The order of the attributes defines the order in which the transformations are invoked.