University of Sheffield

Reusable Model Design Language

Build metamodels, models and model transformations
ReMoDeL icon

ReMoDeL User Guide

Project Setup

Every ReMoDeL project is created as a new Java project in your favourite Java IDE. Every project must include the ReMoDeL kernel on its build path. The expected folders under the project root folder should look like this:

The src/home package contains the shell programs for the compiler, and is the same for every ReMoDeL project. You should copy and paste this package as-is to each of your new projects.

We assume from here on that you have installed the example project RM_Trees following the instructions on the Download Page.

Viewing and Editing

To view any of this project's metamodel, model or transformation file in your IDE's text editor, simply open the file as a text file. Examples include:

You may need to associate the different file extensions with your IDE's text editor. Use the Open With option on first access. To edit any file, simply make the desired changes in your text editor and save the file. But don't modify these examples yet!

Refreshing your IDE

At various points, the ReMoDeL tools will create new files in your project. These may not initially be visible in your IDE, because it uses its own metadata to work out what to display. To get around this, you should learn how to Refresh your project, in your IDE. For example:

In Eclipse, right click on the project RM_Trees to bring up a menu. Select the Refresh option about halfway down. You may also use the F5 function key to refresh a selected project.

After this, you should be able to see the previously invisible file(s). Another useful trick is to Clean your project periodically, which forces all generated Java sources to be recompiled, if the compiled files have got out of step in your IDE.

Shell Programs

In the src/home package you should find:

These shell programs run the ReMoDeL tools and they both expect command-line arguments, giving the relative path to the ReMoDeL input files. Your Java IDE will have a way of specifying command-line inputs, for example:

In Eclipse, select Run > Run Configurations and choose a name for this configuration. On the Main tab fill out the project name RM_Trees, and the main class, e.g. home.Validate. On the Arguments tab fill the Program arguments box with the relative pathname to a ReMoDeL file, e.g. meta/Graph.met. Click Apply to save, and Close to close.

Validating a Metamodel

In the meta folder you should find some metamodels to check:

Run the Validate program to check any of these. Specify the desired pathname as a command-line argument, e.g. meta/Graph.met. If you already have a configuration for this, you can usually find it as one of the drop-down options of your Run button. Run this.

Any syntax errors are reported on standard output. Otherwise, the metamodel is read into memory, and as proof of this, is rewritten out to file called meta/out.met (refresh to see this). This is a temporary file, which you can view and then delete. You should also see a success message on standard output.

Compiling a Metamodel

Run the Compile program to compile a metamodel. This will generate a new Java package under the src folder. To do this, set up a new run configuration with the main program: home.Compile, and specify the desired pathname, e.g. meta/Graph.met. Run this.

If no errors are found, you should see a success message on standard output, and a Java package meta.graph will have been added in your src folder (refresh to see this).

Open the src folder to see the new Java package meta.graph sitting alongside the home package. You can open this package, to see how the metamodel has been converted into a set of Java classes.

ReMoDeL Metamodel of an OutTree

ReMoDeL Metamodel of an OutTree

Validating a Model

Models are text serialisations of memory models, which are constructed from the Java classes you just compiled. To read a model, you must always have compiled its metamodel first! Otherwise, you will see the no metamodel class error message.

In the model folder you should find some models to check:

Run the Validate program to check the model syntax. Create a new run configuration for this, supplying a path to the model file, e.g. model/graph1.mod. Run this.

Any syntax errors are reported on standard output. Otherwise, the model is read into memory, and as proof of this, is rewritten out to file called model/out.mod (refresh to see this). This is a temporary file, which you can view and then delete. You should also see a success message on standard output.

Note that models are data, they cannot be compiled as code. But they are read, created, and written by model transformations.

Validating a Transformation

In the rule folder you should find six transformations, whose names aptly describe what kind of transformation they each perform:

They can transform any kind of tree-like model into another, and back again! You may open and view these files to figure out how they work. You can validate any of these by running the Validate program, specifying the desired path, e.g. rule/InTreeToGraph.tra. Run this.

Any syntax errors are reported on standard output. Otherwise, the transformation is read into memory, and as proof of this, is rewritten out to file called rule/out.tra (refresh to see this). This is a temporary file, to be deleted after reading.

Compiling a Transformation

Run the Compile program to compile a transformation. This will generate a new Java package under the src folder. To do this, set up a new run configuration with the main program: home.Compile, and specify the desired pathname, e.g. rule/InTreeToGraph.tra.

If no errors are found, you should see a success message on standard output, and a Java package rule.trees will have been added in your src folder (refresh to see this). You can open the package, to see that a Java class rule.trees.InTreeToGraph.java has been created.

Furthermore, Java packages will have been added for each of the metamodels used in this transformation. So, you should also see the Java packages: meta.graph and meta.intree. Compiling a transformation always recompiles any dependent metamodels, in case these were modified.

Executing a Transformation

The generated Java class rule.trees.InTreeToGraph.java can be run like any Java main program. It expects a command-line argument giving the relative path to the input source model. To execute this transformation, create a new run configuration with the main program: rule.trees.InTreeToGraph and specifying the path: model/intree1.mod as the input. Run this.

If no errors are found, you should see a success message on standard output, and a temporary output model file model/out.mod will have been added to the model folder. You can open this file, and it should have exactly the same structure as the file model/graph1.mod, which proves that you have just transformed an in-tree to a graph.

Transformation classes can also be used as just one step in a chain of model transformations. In this case, their apply() method is invoked from a Java program that manages the transformation chain. To do this, you will need to understand the Java representation of models and transformations. Look Inside to continue learning.