[SOLVED] Transforming an element twice (or more) [message #871059] |
Thu, 10 May 2012 13:12  |
Eclipse User |
|
|
|
Hello,
The ETL engine (and I guess all other model transformation engines) work on the principle that each element is transformed once. It can be transformed to many output elements, but each rule that has an input type of the same type of the element is only executed once for it. Is there any way that his can be changed so that the rule is executed twice (or more times?).
In my case, working with the eclipse uml metamodel, I have a class that has two elements of another class, lets say ClassA has cX and cY of type ClassB. Hence, ClassA has two owneAttributes that are typed with ClassB. If I do a transformation, lets say I have an output metamodel with a Block type and a block can have a nested Block, from Class to Block, I would like to have BlockA to have two nested blocks: BlockcY and BlockcX. However, if the rule is from Class to Block, ClassB only is transformed once. Hence,
rule Class2Block
transform c: Class
to b : Block {
...
b.block.addAll(c.ownedAttribute.collect(oa | oa.type).equivalent());
...
}
Will result in BlockA having only one nested block: BlockB.
If I change the approach and add a rule to transform an ownedAttribute to a block.
rule Class2Block
transform c: Class
to b : Block {
...
b.block.addAll(c.ownedAttribute.equivalent());
...
}
rule oA2Block
transform a : attribute
to b : Block {
...
b.port.addAll(a.type.ownedConnecter.equivalent());
}
This time BlockA will have two nested blocks: BlockcY and BlockcX. However, since the connectors are transformed from ClassB, only either BlockcY or BlockcX will have the equivalent ports (connectors are transformed once).
I have tried using the clone() method, but since cloned elements have the same xmi:id for the engine they are the same element and still only are transformed once. I have also tried using extended properties, but since ClassB can have additional nested classes and so on it comes a point where it is to complex to keep track of all the relations and equivalents and such.
After much thought it seems using eol to create the output elements would be the easier solution... but I just dislike the fact of doing model 2 model transformations with eol plus I loose the power of the equivalent(s) trace to "paste" realted elements.
[Updated on: Wed, 16 May 2012 11:09] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03168 seconds