Inheritance in QVTo

An interesting feature in QVT Operational Mapping language (QVTo) is mapping reuse. Differently from QVT Relations (QVTr), the QVTo language has some concepts that allow reusing mappings easily, and, more importantly, in an organized way. One of these concepts is mapping inheritance.

When I first saw this concept, I expected (or hoped) it would allow specializing an existing mapping similar to what happens in a object-oriented language – maybe because I am an OO programmer/designer. To my frustration, it does not… Moreover, I think it has a strange semantics that is more similar to an “include”. Yet, a truly “inheritance” can be an interesting and useful concept to allow mapping reuse in QVTo.

Before discussing what I think would be a more interesting semantics, let me explain how it works in QVTo. Continue reading

Using black box implementations in Eclipse QVTo

In QVT, it is possible to execute external code in a transformation. According to the standard, it has some benefits (QVT, 2009, p.10):

  • It allows complex algorithms to be coded in any programming language with a MOF binding (or that can be executed from a language with a MOF binding).
  • It allows the use of domain specific libraries to calculate model property values. For example, mathematical, engineering, bioscience and many other domains have large libraries that encode domain-specific algorithms which will difficult, if not impossible to express using OCL.
  • It allows implementations of some parts of a transformation to be opaque.

The external code is called a “black box implementation”.

Using this concept, in Eclipse QVTo it is possible to execute an external Java code. In this post I will describe how you can easily create a black box implementation to execute a math sine operation. Continue reading

PhD Thesis

Here it is, finally, my PhD thesis in Computer Engineering. It is in Portuguese and its original title is “Transformação de um Modelo de Empresa em um Modelo de Casos de Uso seguindo os Conceitos de Engenharia Dirigida por Modelos” – which can be translated to “Transforming an Enterprise Model into a Use Case Model using Model-Driven Engineering Concepts”. Continue reading

Essential Use Case Meta-model

There are several meta-models and templates for use case textual description. These representations have different goals and viewpoints, thus proposing different concepts, or different relationship between concepts, or even different semantics for a concept.

Because some MDE works need to use a basic use case meta-model as part of the transformation, in this paper in WER 2011; I proposed an essential use case meta-model. This meta-model was based on a survey on existing meta-models and templates (the analysis of these concepts is available in this post).

Due to space limitations, the paper only presents part of the meta-model abstract syntax and semantics (textually). In this post I will make available the full abstract syntax and concrete syntax using XML (for the semantics, please refer to the original paper).

The meta-model’s abstract syntax is presented next, using a MOF class diagram. The Ecore file is available here. The original meta-model was adapted to include three meta-classes: UseCaseModel, Agent and Subject. Agent and Subject were included to represent who executes a Step – if a Subject (the System) or an Actor – an Agent is simply a generalization of Subject and Actor.

Essential Use Case Meta-model Continue reading

Common Elements in a Use Case

I’ve published a paper in WER 2011 that analyzes the most common elements of a use case textual representation and proposes a meta-model considering them. Due to lack of space, it wasn’t possible to include the original tables used in the analysis. During the workshop I’ve promised that I would make it available somewhere… and I’m finally fulfilling this promise. Here it is the first table, analyzing the main concepts proposed by some templates and meta-models.

Continue reading

Transformation localization in QVTo

Last week I’ve decided to translate my QVTo transformation to Portuguese. I’m preparing an experiment that uses this transformation, and my subjects are Brazilian students. So it wouldn’t be appropriate to have English texts in the obtained transformation. It would be a silly independent variable to consider…

So, how can I make my transformation outputs a Portuguese text? A simple solution would be to copy my existent code and just translate it. Easy… But an horrible solution. If I ever change my transformation code, due to this solution I would have to change in 2 places instead of just one. It’s the common “copy-paste in maintenance” problem.

So, how can I create an elegant localization solution? Using the Dictionary type defined in the QVTo Standard Library (defined in the QVT standard), I decided to use the following solution:

  • Create 2 dictionaries: one for English text and one for Portuguese text.
  • Create a “configuration property” so the user can select the language without touching the transformation code.
  • Create a query that returns the message asked, considering the selected dictionary.
  • Create a library for this localization query, separating it to my original code.

Continue reading

Debugging queries in Medini QVT

Medini QVT was one of the first QVT tools to be available to the community – if not the first. To my knowledge, it is still the only functional QVT Relations tool. It was developed by IKV++ Technologies, and it has a remarkable compatibility with QVT and OCL standards, being a great tool to work with QVT Relations. Moreover, it can be used inside an application and has an integrated development environment with a debug feature. However, the debugging has a problem: it does not work for queries. The tool simply ignores them…

Depending on the complexity of your solution, queries can have a very important part of your logic. So, how can we debug them? Moreover, how can we test them? Because sometimes you need a query to call another query, sometimes it is very difficult to understand what exactly have happened in a transformation. Here I will present how to use OCL Tools for this end, but it is also possible to use the QVTo plug-in if you want (you will need to learn QVT Operational).

Continue reading

Returning a Set in QVTo Mappings

In some situations, it is necessary to return a set of elements in a mapping. If this size of the set is predefined, it is possible to use a tuple. If the size is undefined, it is necessary to use a Collection. But how to use them? A first solution would be to write something like:

mapping A::A2B() :  Set(B) {
	result += object B {
		id :=;
		b := "something";

However, this solution does not work… We get in the result what I will call here a lose element, i.e. an unused object that is put in the root of the hierarchy. In general, a lose element occurs when an element is created, but is not correctly associated to a container object. The problem here is that a Set is an immutable Collection! A immutable Collection is a group of elements that cannot be changed after it has been created. Therefore, each time a Set is modified, a new Set is created. All Collection types defined in OCL are immutable, i.e., Set, OrderedSet, Bag, and Sequence are immutable.

Continue reading