Execute operation in java code [message #1781029] |
Wed, 31 January 2018 11:29  |
Eclipse User |
|
|
|
Hi,
The following code gets the transformation rules and the guard for each rule.My question is : if the guard is an operation can i execute it ?? and i f yes what java code i need to execute an operation in standalone manner??
package etljavatool;
import org.eclipse.epsilon.eol.dom.Parameter;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.epsilon.eol.dom.ExecutableBlock;
import org.eclipse.epsilon.eol.execute.operations.*;
import org.eclipse.epsilon.etl.EtlModule;
import org.eclipse.epsilon.etl.dom.TransformationRule;
import org.eclipse.epsilon.etl.execute.*;
import org.eclipse.epsilon.etl.execute.context.*;
import org.eclipse.epsilon.etl.execute.operations.*;
import org.eclipse.epsilon.etl.parse.*;
import org.eclipse.epsilon.etl.strategy.*;
import org.eclipse.epsilon.eol.IEolModule;
import org.eclipse.epsilon.eol.models.IModel;
public class EtlTool{
public static void main(String[] args) throws Exception {
EtlModule module = new EtlModule();
module.parse(new File("C:/Epsilon/eclipse-epsilon-1.3-win32-x86_64/workspace/EtlJavaTool/src/TraceabilityFeb3.etl"));
if (!module.getParseProblems().isEmpty()) return;
module.getTransformationRules(); // Returns a list of transformation rules
for (TransformationRule tr : module.getTransformationRules()) {
//TransformationRule rule = module.getTransformationRules().get(5);
List<Parameter> t = tr.getTargetParameters() ;
Parameter s = tr.getSourceParameter() ;
s.getTypeName();
t.get(0);
System.out.println("Target type "+ t.get(0).getTypeName());
System.out.println("Source type "+ s.getTypeName());
ExecutableBlock<Boolean> ex =tr.getGuard();
if (ex != null)
{//ex.getBody();
System.out.println("guard "+ex.getBody() );
}
}
}
}
Thanks,
Taghreed
|
|
|
|
|
|
|
|
|
|
|
Re: Execute operation in java code [message #1781982 is a reply to message #1781564] |
Thu, 15 February 2018 07:48  |
Eclipse User |
|
|
|
Hi Taghreed,
That is a very interesting project! I am sure we could collaborate more directly if you want (I am currently working on incremental execution of Epsilon languages myself), perhaps as an external assessor to your PhD (lets take this offline - can you drop me an email[1]?)
I think the problem with our approach is that to execute the guard you need to assign the rule parameters model object elements:
...
// This method would be responsible for finding the element that changed, if it was used for this rule (note that this could be a list of elements)
Object sVal = etlModelComapre.getSourceElementThatChangedFor(tr);
guardSatisfied = ex.execute(module.getContext(),
Variable.createReadOnlyVariable(s.getName(), sVal), // We put the changed Object in the context
Variable.createReadOnlyVariable("self", sVal));
You also need to consider that the guard expression might use other object references, those should also be added to the context. If the guard uses an "all" call, then the model that is being queried should also be in the context.
Cheers,
[1] https://www.cs.york.ac.uk/people/hhoyos
|
|
|
Powered by
FUDForum. Page generated in 0.26264 seconds