Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Programmatically executing out-place transformations

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

 

From: henshin-dev-bounces@xxxxxxxxxxx [mailto:henshin-dev-bounces@xxxxxxxxxxx] On Behalf Of Christian Krause
Sent: Tuesday, October 14, 2014 3:51 PM
To: Henshin developers mailing list
Subject: Re: [henshin-dev] Programmatically executing out-place transformations

 

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:

 

Resource input = ...

InterpreterUtil.applyToResource(unit, engine, input);

 

Resource output = ...

output.addAll(input.getContents()); <-- filter here if needed

output.save(null);

 

Best regards,

Christian

 

 

 

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

 


Back to the top