A difference model can be executed to "reconstruct" a final model starting from the initial one. Unfortunately, this is intrinsically difficult and it requires a high-order
transformation. In particular, according to the lower side of Figure 5, the model transformation (MMD_MM2MM) can be applied to a model M1 in order to obtain a target
M2 with respect to the differences specified in a model MD. Such a model conforms to the metamodel MMD automatically obtained from MM as previously discussed.
Figure 5: Difference Animation
The MMD_MM2MM transformation implements the rules to apply on a source model M1 the additions, deletions and changes specified in the model MD. More precisely,
considering the dashed part in Figure 1, for each metaclass MC in the metamodel MM, the transformation MMD_MM2MM contains the following rules:
-
AddedMC2MC: it manages the elements in the difference model MD that conform to the AddedMC metaclass. For each element, the rule creates in M2 a new instance
of MC setting the corresponding structural features according to the specification of the AddedMC element;
-
ChangedMC2MC: it updates already existing elements in the initial model of type MC according to the modifications specified in MD through ChangedMC instances;
-
UnchangedMC2MC: it copies the unmodified instances of the metaclass MC which have to be the same both in M1 and M2. The source pattern of this rule has a
guard matching only the MC elements which have not been changed nor deleted.
Concerning the management of DeletedMC instances, no rules are provided, since the guard in the source pattern of the UnchangedMC2MCrule guarantees that elements which have
been specified as deleted in the difference model are not matched during the transformation phase (hence, not copied in the target model M2).
An ATL implementation of this high-order transformation has been defined and it consists of three main rules (see Figure 6) that are AddedClass (lines 4-25), UnchangedClass
(lines 27-49), and ChangedClass (lines 51-70). They are dedicated to the generation of the three kinds of rules needed for the management of each metaclass specified in the
source difference model. Depending on the structural features of the matched metaclass, a number of helpers are created. Since such generations are quite complex and it is
difficult to specify them in a declarative way, ATL called rules and action blocks are used. For instance, the lines 21-24 in Figure 6 implements an action blocks where the
called rule CreateAddedHelper is invoked in order to generate the target helpers needed for the management of additions specified in a given model difference (see the lower
side of Figure 5)
Figure 6: Fragment of the MMD2ATL high-order transformation
This work is a first attempt to support model versioning and evolution in a MDE setting. Further work will address the problem of conflict detection and resolution. When
software is developed in a distributed environment, parallel modifications can give place to conflicts which are usually detected by means of traditional lexical approaches
which lack of abstraction and can give place to false positive and negative issues.
|