Create new objects in transformation [message #1735947] |
Thu, 23 June 2016 21:58 |
Gunnar Sörens Messages: 1 Registered: June 2016 |
Junior Member |
|
|
Hi!
I'm fairly new to Epsilon so I face a (probably simple) problem.
To demonstrate this, assume the following meta-model:
There are three classes A, B and C, where many Bs may be contained by A and C holds some additional information.
Now some instances of B could be derived by a "base instance" of B and additional information from instances of C.
I want to reduce the work and only require one instance of B to be modeled and the other ones to be auto-generated with the information of C.
So before I start with my actual transformation, I want to use a small transformation to auto-generate the missing instances of B.
As an example, consider the following:
pre {
var all_bs = MyModel.getAllOfKind("B");
for (b in all_bs) {
var b2 = new B;
//use some information from C to assemble b2
}
}
However, this creates the new B object at the topmost level of the resulting model; i.e., the new instances of B are at the same level as A and no longer contained by the original instance of A.
How could i insert the new instances at the same level as the original instance of B?
Should I use pre-blocks to do this work, or could actual rules be used? (Consider that I want a dynamic number of instances to be created)
Or should I take a completely different approach?
I hope you understand my question.
Looking forward to answers,
Gunnar
|
|
|
|
Powered by
FUDForum. Page generated in 0.03069 seconds