Example: Use model transactions in a workflow

<project default="main">
  <!-- ANT Taskdefs for ant-contrib -->
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>  
  <target name="loadModels">
    <epsilon.emf.register file="tree.ecore"/>    
    <epsilon.emf.loadModel name="M" modelfile="tree.model" 
        metamodeluri="Tree" read="false" store="true"/>
  <target name="Transformation1">
      <model ref="M"/>
      var t : new Tree;
      t.label = 't1';
  <target name="Transformation2">
      <model ref="M"/>
      var t : new Tree;
      t.label = 't2';

  <target name="Validation1">
      <model ref="M"/>
      context Tree {
        constraint C1 {
          check : true
  <target name="Validation2">
      <model ref="M"/>
      context Tree {
        constraint C2 {
          check : true -- Switch to false to make validation fail
  <target name="Evaluation">
      <model ref="M"/>
  <target name="main" depends="loadModels">
    <runtarget target="Transformation1"/>
    <runtarget target="Validation1"/>    
        <!--Start a transaction on M so that we can roll it back later on.-->
        <epsilon.startTransaction name="Transaction1" models="M"/>
        <runtarget target="Transformation2"/>
        <runtarget target="Validation2"/>
        <!-- No errors in the validation. Commit the transaction.-->
        <epsilon.commitTransaction name="Transaction1"/>
        <!--If validation fails, roll back the transaction.-->
        <epsilon.rollbackTransaction name="Transaction1"/>
    <runtarget target="Evaluation"/>
@namespace(uri="Tree", prefix="Tree")
package Tree;

class Tree {
   val Tree[*]#parent children;
   ref Tree#children parent;
   attr String label;

Clone Epsilon's Git repository:

  • navigate to trunk/examples
  • import the org.eclipse.epsilon.examples.workflow.transactions project

What's this?

In this example we demonstrate using the ant-contrib try/catch tasks and the Epsilon model transactions tasks to conditionally rollback changes in models modified in a workflow.

What are .emf files?

.emf files are Ecore metamodels expressed using the Emfatic textual syntax.

More examples...

Epsilon Object Language
Epsilon Transformation Language
Epsilon Generation Language
Epsilon Validation Language
Epsilon Merging Language
Epsilon Flock
Combining the Epsilon Languages

Even more examples...

More examples are available in the examples folder of the Git repository.