• Aucun résultat trouvé

mm t mmt ∪ mmtp

6.6 Transformation Composition in Action

Previous sections defined both metamodel and transformation compositions.

Although in what concerns metamodels we think it is clear how the approach applies, regarding transformation we believe that some more detail will help to clarify the approach presented. Taking this into account, this section is dedicated to show how transformations are composed.

For the purpose of better understanding of transformations’ composition we consider two scenarios:

1. The case in which the transformation domain element in f pdefined by ψ is in the edge of the metamodel. This means that the element has no linked elements from it. It is an element with no connected nodes from it;

2. The case in which the element is not anedge element of the metamodel.

For the first case, the transformation composition is performed as shown in Figg. 6.11, 6.12 and 6.13.

The three figures present three different views which illustrate, step by step, what happens while composing the transformation rules.

For what concerns these descriptions we consider that:

• T rf p→mmtis the set ofntransformation rules defined forf pmetamodel:

T rf p→mmt ={T rf p→mmt1 , T r2f p→mmt, ..., T rf p→mmtn };

• analogously, T rep is the set of transformation rules for ep metamodel:

T rep→mmt={T r1ep→mmt, T r2ep→mmt, ..., T rnep→mmt};

• T rDSM Lmm0→mmt stands for the complete definition of the transfor-mation after composition. In the diagrams representing each one of the views, only blocks corresponding to the rules of T rep→mmt and T rf p→mmt are represented. This was done explicitly for simplicity rea-sons although the full transformationT rDSM Lmm0→mmtmight contain other rules;

For the case of a composed DSML in which the f p element in the ϕ function is an edge element like in Fig. 6.11 the ψ composition function is defined as:

ψ ={hT r2f p→mmt, T rep→mmti}

Meaning the transformation defined for the element in thef pmetamodel to which corresponds the transformation T r2f p→mmt is to be replaced by the transformation defined for ep

6.6. Transformation Composition in Action 95 View 1 from Fig. 6.11 shows the state of the transformation rules before

anything happens;

... ...

T r1f pmmt T rf p→mmt

T r2f pmmt

T rnf p→mmt T repnmmt T rep1 mmt T rep2 mmt T rep→mmt

ψ = {!T r2f pmmt, T repmmt"}

Figure 6.11. Transformation Composition for Edge Elements - View 1 View 2 in Fig. 6.12 presents the step in which the left side of theψfunction is

erased from the full transformation view. This a necessary intermediary step to allow replacement of ep corresponding transformation in the next step;

View 3 as depicted from Fig. 6.13 shows how transformation rules are packed together by the end of the execution of the composition. This is the last step in the composition chain that places the transformation rules defined for ep in the empty spot left from the previous step.

Since the transformations are, as defined previously, a set of transforma-tion rules, the order in which the rules are applied is not important. More-over, rules that are applied by using a graph based matching technique will always be applied by following the matched patterns and not the order which they were specified.

Transformation composition defined over elements from non-edge ele-ments are more complex. The main reason for the increase of complexity is because, typically, we don’t want to replace the totality of the element’s transformation for a new one. By complete replacing its transformation, we’ll lose transformation information we don’t want to: we might have transfor-mation rules for the linked elements that depend on the execution of that element transformation.

... ...

T rf p→mmt1 T rf pmmt

T rf p→mmtn T rep→mmtn T rep→mmt1 T rep→mmt2 T repmmt

Figure 6.12. Transformation Composition for Edge Elements - View 2

T r1f pmmt

...

T rnf pmmt

...

T rnep→mmt T r1epmmt T r2epmmt

}

T rf pmmt|T rep2 mmt

T repmmt

}

T rf p→mmt ←−−ϕ,ψ T rep→mmt

T rDSM Lmm!mmt

Figure 6.13. Transformation Composition for Edge Elements - View 3

6.6. Transformation Composition in Action 97 The main goal behind this strategy is to be able to compose transfor-mation blocks without the need to replace transfortransfor-mation rules in the f p side, but rather to do it in the ep side. Figg. 6.14, 6.15 and 6.16 provide a schematic perspective on the three views that build the composition process:

View 1 presented in Fig. 6.14 shows the state of the transformation rules after composition execution. In the left-hand we have the set of rules corresponding to T rf p→mmt. The rule T rf p→mmt1 is what we define as T F the rule. This is the rule we are parameterizing but we don’t want to replace its transformation definition. This rule is T rf p→mmt|T F a restriction ofT rf p→mmt toT F. On the right side we defineT rep→mmt

Figure 6.14. Transformation Composition for non-Edge Elements - View 1 View 2 depicted from Fig. 6.15 presents the step in which the right side of

theψ function is removed from the full transformation view. T rep→mmt

is now only the part T rep→mmt −T E as T E is unwanted in the final version of the transformation;

View 3 in Fig. 6.16 shows how transformation rules are packed together by the end of the execution of the composition.

The composition definition for these cases is

ψ ={hT rnf p→mmt,(T rep→mmt−T E)∪(T rf p→mmt|T F)i}

where T rnf p→mmt is the rule we want to parameterize but not to replace in the source DSML transformation. T E the rule in the effective parameter transformation set that is to be removed so thatT rnf p→mmtcan be maintained.

... ...

T r1f pmmt T rf p→mmt

T r2f p→mmt

T rnf pmmt T rep→mmtn T rep2mmt T rep→mmt

{

T rf p→mmt|T F

T rep→mmtT E

}

Figure 6.15. Transformation Composition for non-Edge Elements - View 2

...

...

T r1f p→mmt T r2f pmmt

T rnf pmmt

T repnmmt T rep→mmt2

{

T rf pmmt|T F

T repmmtT E

{

T rf pmmt

←−−ϕ,ψ T repmmt

T rDSM Lmm!mmt

}

T rf pmmt

Figure 6.16. Transformation Composition for non-Edge Elements - View 3

6.6. Transformation Composition in Action 99

6.6.1 Railway System DSML Transformation Compo-sition

For illustrating the composition of transformations lets consider the definition of the Rail Way System DSML base on the Moving Entities generic DSML defined previously. First let’s start by showing what is an Edge and a non-Edge element in metamodel. In Fig. 6.17 the EClass MovingEntityis what we consider an Edge element of the metamodel. TheEClass JunctionPoint has linked elements such as EndPoint1 and EndPoint2 thus it is what we define as a non-Edge element.

non-Edge Element Edge Element

Figure 6.17. Example of Edge and non-Edge Metamodel Elements

The metamodel parameterization definition of this DSML was specified using the ϕ function

ϕ={hM ovingEntity, T rainEntityi,hJ unctionP oint, RailwayStationi, hownedEntities, ownedT rainEntitiesi,

hownedJ unctionP oints, ownedRailwayStationsi}

In this specification the elements that correspond to rules in the transforma-tion definitransforma-tion are the hM ovingEntity, T rainEntityi and

hJ unctionP oint, RailwayStationi. The first one is an edge element. It means that transformation composition is performed by replacing the trans-formation defined in the f p side by the one ep side. Schematically in Fig.

6.18 this means that the rule that corresponds to the ruleMovingEntities will be replaced by the rules defined in T rT rainEntity.

rule ruleMovingEntities { from

me : MovingEntity!MovingEntity to

cl : COOPNMetaModel!COOPNClass(...) }

rule ruleTrainEntity { from

tr : TrainEntity!TrainEntity to

cl : COOPNMetaModel!COOPNClass(...) }

Figure 6.18. Example of Transformation Composition for an Edge Element

In terms of transformation composition for non-edge elements like the JunctionPoint being parameterized by RailwayStation, the composition works slightly diferent. We cannot just eliminate the transformation rule from the f p side because it (an usually does) might contain references to other transformation rules. By replacing it, we would lose all the transfor-mation defined from it. Taking this into account, the composition in non-edge elements keeps the transformation rule defined for the element in f p, ignores the rule from the ep side that corresponds to the element in ep defined by ϕ, and adds to the f p transformation all other rules in the ep side. This procedure is illustrated in Fig. 6.19

The generic approach for composing transformations is as presented in this section. A complete description and definition of transformation com-positions is presented in Chap. 8 where the case studies are described.