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!