Antonio Garcia-Dominguez
March 3, 2022
EolModuleEtlModuleEglTemplateFactoryModuleAdapterClass)We will focus on this subset of Epsilon:


NoModel and press Enterpom.xml)-SNAPSHOT), to avoid a warning message when using EGL<dependencyManagement> to ensure we use modern Eclipse core JARs:
<dependency>
<groupId>org.eclipse.epsilon</groupId>
<artifactId>org.eclipse.epsilon.eol.engine</artifactId>
<version>${epsilon.version}</version>
</dependency>epsilon.version property ensures the Epsilon JARs match each otherNoModel.javaEolModule.parse() while passing the reference to the script location: in this case, we package the script with our application, but it could be an external file.execute() to obtain the result (in case the last statement is a return)public static void main, and watch the terminal
Picked up part: it’s Gitpod-specific<dependency>
<groupId>org.eclipse.epsilon</groupId>
<artifactId>org.eclipse.epsilon.emc.emf</artifactId>
<version>${epsilon.version}</version>
</dependency>EmfModel<dependency>
<groupId>org.eclipse.epsilon</groupId>
<artifactId>org.eclipse.epsilon.flexmi</artifactId>
<version>${epsilon.version}</version>
</dependency><dependency>
<groupId>org.eclipse.emfatic</groupId>
<artifactId>org.eclipse.emfatic.core</artifactId>
<version>1.0.0</version>
</dependency>final var emap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap();
emap.put("flexmi", new FlexmiResourceFactory());
emap.put("emf", new EmfaticResourceFactory());.flexmi and .emf file extensions (on top of the default .xmi one)true iff model is an input to the current tasktrue iff model is an output of the current taskm.load()EolModule variable go out of scope is not enough to free its resources (as in C++)dispose() the model repository once a model is done running:
setStoredOnDisposal(true)Running ReadOnlyModel will produce the same output as in the Playground:

returnReadOnlyModel called WriteModel that:
03-add_task.eol insteadmodels/project.flexmi.xmi

.execute() call, importing execute.context.VariableWriteModel: you should see a new task with the specified durationTree2Graph.javaEmfModelEmfModel// Allows using Source!Tree to refer to the type
source.setName("Source");
// We only read from this model
source.setReadOnLoad(true);
source.setStoredOnDisposal(false);
// Allows using Target!Graph
target.setName("Target");
// We only write to this model
target.setReadOnLoad(false);
target.setStoredOnDisposal(true);Tree2Graph, and open models/graph.xmietl.execute() inside the try:Run Tree2Graph and you will get a list like this:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@576f63f6 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3403e2ac (name: Tree) (instanceClassName: null) (abstract: false, interface: false)) produced [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@13e547a9 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@40844aab (name: Graph) (instanceClassName: null) (abstract: false, interface: false))]
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@2dca0d64 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3403e2ac (name: Tree) (instanceClassName: null) (abstract: false, interface: false)) produced [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@3fb6cf60 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@447a020 (name: Node) (instanceClassName: null) (abstract: false, interface: false))]
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@5ef6ae06 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3403e2ac (name: Tree) (instanceClassName: null) (abstract: false, interface: false)) produced [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@37ddb69a (eClass: org.eclipse.emf.ecore.impl.EClassImpl@447a020 (name: Node) (instanceClassName: null) (abstract: false, interface: false))]
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@55dfebeb (eClass: org.eclipse.emf.ecore.impl.EClassImpl@3403e2ac (name: Tree) (instanceClassName: null) (abstract: false, interface: false)) produced [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@349c1daf (eClass: org.eclipse.emf.ecore.impl.EClassImpl@447a020 (name: Node) (instanceClassName: null) (abstract: false, interface: false))]
Not particularly nice to look at…
Change the code to this:
for (Transformation tx : etl.getContext().getTransformationTrace().getTransformations()) {
EObject eob = (EObject) tx.getSource();
EStructuralFeature sfLabel = eob.eClass().getEStructuralFeature("label");
String label = (String) eob.eGet(sfLabel);
for (Object txTarget : tx.getTargets()) {
EObject eobTarget = (EObject) txTarget;
EStructuralFeature sfName = eobTarget.eClass().getEStructuralFeature("name");
String name = (String) eobTarget.eGet(sfName);
System.out.println("Tree " + label + " produced Node " + name);
}
}EObject typeTree t1 produced Node t1
Tree t2 produced Node t2
Tree t3 produced Node t3
Tree t4 produced Node t4
Project2Chart.javaEmfModeloutput.html fileEglTemplateFactoryModuleAdapter is an adapter over EGL’s internal APIs that can be used in the same way as the ExlModule classes of the other Epsilon languagesoutput.html file in the root folder


Antonio Garcia-Dominguez
a.garcia-dominguez AT aston.ac.uk