[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [henshin-dev] Programmatically executing out-place transformations
|
Hi Vlad,
If your existing solution works, I would leave it as it is. If you still need the helper method you can use the version that takes an Assignment as input and simply use null or an empty assignment.
Cheers,
Christian
On Oct 14, 2014 4:50 PM, "Vlad Acretoaie" <
rvac@xxxxxx> wrote:
Hi Christian,
Thank you for your answer. I ended up using the following solution, which seems to work without creating any unwanted duplicate elements in the target model:
EGraph graph = new EGraphImpl(source);
UnitApplication application = new UnitApplicationImpl(engine, graph, unit, null);
application.execute(null);
Resource target = resourceSet.createResource(targetURI.getPath());
target.getContents().clear();
target.getContents().addAll(source.getContents());
target.save(null);
I am avoiding the InterpreterUtil helper method because I would like to use an ApplicationMonitor, and the helper method which supports an ApplicationMonitor
requires an Assignment as a parameter (instead of a Unit). I think (hope) that these two invocation methods are equivalent.
Cheers,
Vlad
Hi Vlad,
in the InterpreterUtil class there is a method called applyToResource (see links below). It collects all new root objects and adds them to the resource. It does not remove the input model though (unless you do this in your transformation).
You could copy the content of your transformed input resource to the resource of the output file and save it. In this step you could also do some filtering. So it would be something like this:
InterpreterUtil.applyToResource(unit, engine, input);
output.addAll(input.getContents()); <-- filter here if needed
2014-10-14 15:29 GMT+02:00 Vlad Acretoaie <rvac@xxxxxx>:
Hi,
I would like to invoke a Henshin transformation programmatically and save the target model in a different file than the source model (i.e. I would like my transformation to be out-place).
So far I was able to do this as follows, using the “ePackage” output parameter of my transformation:
UnitApplication application = new UnitApplicationImpl(engine, graph, unit, null);
application.execute(null);
EPackage result = (EPackage) application.getResultParameterValue("ePackage");
resourceSet.saveEObject(result, "target.ecore");
So my question is: Is there a way of executing an out-place transformation without depending on the existence of an appropriate output parameter of the transformation? I would like
to simply save the entire target model, regardless if the transformation has any parameters or not. I suspect this is possible, since the Henshin Eclipse plug-in is able to do it when executing transformations using the GUI.
Cheers,
Vlad
|
Vlad Acretoaie
|
PhD student
|
DTU Compute
|
|
Technical University of Denmark
|
|
Department of Applied Mathematics and Computer Science
|
Matematiktorvet
|
Building 303B, Room 055
|
DK - 2800 Kgs. Lyngby
|
Denmark
|
Direct
+45 45253645
|
rvac@xxxxxx
|
www.compute.dtu.dk/~rvac
|
|
_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev
_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/henshin-dev