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 := self.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

"Hello world" in Eclipse QVTo

Although QVT isn’t a brand new specification (its first version is from April 2008), it is very difficult to find basic information about it and about how to use it. Since I’ve been working with QVT (Relations and Operational Mapping languages) in the last few months, I’ll post some things about it – maybe it will be useful to some QVT users…

To start, I’ll present a brief tutorial of how to execute a simple transformation in Eclipse QVTo with a custom metamodel. Nowadays we have 2 options to execute a transformation in this scenario:

  1. Install a plug-in metamodel in Eclipse and create the transformation.
  2. Use the QVTo environment in an inner Eclipse instance.

Normally we should use the option 1, as a stable metamodel is a pre-requirement for a transformation project. In some projects you may correct the metamodel during the transformation development, but it is just a matter of regenerating a plug-in. The option 2 is more suitable for tests or unstable metamodels (whatever this means).

Continue reading

The first post

For a long time I’ve been thinking in updating my website. But this update is not a mere change in the design, as you may see. First, the site is now almost entirely in English – a few pages will remain in Portuguese, mainly the ones related to the classes I teach. Second, now I am using a Content Management System (CMS), more specifically WordPress. Therefore, now I am able to receive comments from people visiting my website, and I can also post some things in a blog. But why should I blog? Blogs are so 2000’s… Wouldn’t be better to micro-blog using Twitter?

Well… No! First of all, I still don’t see a useful reason to use Twitter. Sorry Twitter fans. Second, I won’t post here details about my life (thank God!). I will try to post some technical stuff – initially some insights about QVT (Query/View/Transformation) and Eclipse’s Graphical Modeling Framework. Therefore, 140 characters wouldn’t be enough for that. As every beginner blogger, I hope it may be useful for somebody. If not, it at least will be a harmless hobby.

Finally, someone may ask why I am using WordPress instead of other CMS. As a Computer Engineer, I’ve tested some other CMSs, considering that my host only accepts PHP or .Net (I would love to be able to use Java for a fair price…). I tried another two popular CMSs, DotNetNuke and Joomla!, but I found them to be more complex than I needed. I just wanted to be able to blog, receive comments, and integrate the CMS to my existing solution to manage the content of my courses. WordPress semed to have a simpler user interface, a bigger community for plug-ins, and an easier extension mechanism. So, I chose WordPress. I spent a few months working slowly to create this website – mostly at weekends. It was fun to play a little with CSS, PHP, WebServices (as my software to manage courses is written in C#), and jQuery. And here we are!