VIATRA is an open source model transformation framework, focusing on efficient evaluation of model queries and supports various transformation workflows. This document contains a tutorial for getting started with the query and transformation development.
The tutorial relies on the CPS Demonstrator application from https://github.com/viatra/viatra-docs/blob/master/cps/Home.adoc. The CPS Demonstrator is specified to cover a usual workflow in Model-driven Engineering, where a system is (1) first described in a source model, then (2) automated model-to-model transformations are used to derive a target model. Finally, (3) model-to-text transformation is performed to generate code from the target domain. In addition, a model generator that can automatically create source domain models can support the correctness testing and performance evaluation of the components. This tutorial uses only a subset of the transformation problem, as its main goal is to illustrate the basics of the VIATRA environment. Consult the original demonstrator for a more complex transformation example.
We expect readers to be familiar with the basics of Eclipse plug-in development, more specifically creating plug-in projects and defining basic UI extensions such as commands. Additionally, we expect a basic understanding of EMF-based modeling If required, look at the Plug-in development tutorial at http://www.vogella.com/tutorials/EclipsePlugIn/article.html or the EMF tutorial at http://www.vogella.com/tutorials/EclipseEMF/article.html for a short tutorial on these subjects.
This document starts with a quick setup guide, then describes model query development. Both batch and event-driven transformations are covered later.
The source of this tutorial is written in AsciiDoc and is available at https://github.com/viatra/viatra-docs Contributions are welcome! If you find any mistakes or outdated informations, please open an issue.
This document is intended only as a short tutorial for the usage of the Query and Transformation capabilities of VIATRA. A more detailed documentation is maintained at http://wiki.eclipse.org/VIATRA.
For model transformation development a Java API is available, allowing seamless integration of the transformations into any Java applications. However, to enhance readability, we recommend using a higher-level JVM language, as it allows defining the transformation as an internal DSL of this host language.
In this tutorial we rely on the Xtend language to host the VIATRA transformation DSL, and we rely on its extension method and type inference support to reduce unnecessary elements. However, other JVM-based languages can also be used with similar efficiency (for an example in Kotlin see https://gist.github.com/doczir/bfe95c470599c5b8e60b400b80f92ea2).