var i := 0; for (leaf in Tree.all.select(t|t.children.isEmpty())) { var child : new Tree; i := i+1; child.label := 'Added' + i; leaf.children.add(child); } Model.store(Model.modelFile + 'copy.model');
@namespace(uri="Tree", prefix="Tree") package Tree; class Tree { val Tree[*]#parent children; ref Tree#children parent; attr String label; }
There are two ways to get the code of this example:
Once you have checked out/imported the code, to run the example you need to go through the following steps:
In this example we use the Epsilon Object Language (EOL) to programmatically modify a model that conforms to the Tree.emf metamodel and store the modified version as a new model.
.emf files are Ecore metamodels expressed using the Emfatic textual syntax.
More examples are available in the examples folder of the SVN repository.