Building and applying UML profiles with Obeo UMLDesigner

UMLDesigner (see http://marketplace.obeonetwork.com/module/uml) is the “new kid of the block” in the Uml designers family. Based on Eclipse tooling, the solution is backed by Obeo a french enterprise behind the Eclipse Modeling initiative. It is definetely the solution to consider if your want a lightweight designer integrated into your development stack.

Earlier versions of this product – while doing the basic job well – were a little trickier to use regarding the definition of Uml 2 profiles and their application to models. The later 1.2 release solves this problems elegantly and make the definition of profiles a breeze …

The purpose of this blog post is to show you the Uml profile and application process through a little sample project.

Configuration

For this demo, I’m using an Eclipse Indigo (3.7.2). Precisely, the one shipped within excellent SpringSource distribution : SpringSource Tool Suite (STS) – release 2.9.2.

To this base installation, I have added UMLDesigner using Eclipse Marketplace – Marketplace can be added to STS simply by installing the extension from the Dashboard extensions thumb. The UMLDesigner used is the 1.2 release.

An additional plugin seems to be required for an easier usage of designer (at least, it was in previous version but I did not try to do without is this last setup). It is UML2 Extender SDK. Version 3.2.1.v201109082252 was added to original STS setup using the update site of Indigo (Indigo – http://download.eclipse.org/releases/indigo) already configured into STS.

Building a profile

First, let’s start by creating a sample Eclipse project. Use a General > Project and let’s call it testUML.

Within this project, we are now going to create a model file that will host our profile information. we do this by using the Viewpoint > Modeler > UML Model wizard like below capture.

Just call the file testProfile.uml for exemple. Be careful, that when the wizard ask you the root element of your model – as shown below – you select the Profile option.

When finishing the wizard, you’ll see your file created as well as a bunch of other things. When expanding the resources tree into the Project Explorer view (important for the rest of this post), you should have the following result :

What is important now is to have a representation suitable for manipulating Uml 2 profile concepts. This is achieved by creating a new representation under the profile node of your new file. Right-click your profile element and choose New Representation > new Profile Diagram. Call your representation MyProfile diagram and see a new diagram editor appear like in the capture below.

(by the way, I have renamed the profile element within my model to MyProfile). You now have to used this editor to specify your profile specific definition. In this sample project, we are just gonna add a new stereotype to this profile. Our profile will be named Taggable, it will help specify tagging/labeling capabilities to a domain entity. As such, it will be available for Class elements only.

First, let’s create a stereotype with th corresponding tool within the palette on the right. Rename it to Taggable. Then, import the Metaclass extension corresponding to the Uml Class we’re targetting with our stereotype. The wizard shows you a quite impressive list of available extensions, scroll down to find out the Class element. For now, you should have the diagramm with this status :

You now have to specify that this stereotype is available for Class instance. For that, you have to use the Extension tool from the palette and link together the Taggable stereotype (first) with the Class metaclass (then). You’ll see a link appear like below.

Last step to make your profile available to other models is to build id. You do that by using the Define profile tool from the palette and clicking anywhere into the diagramme. This has the effect to package your profile by adding the necessary Uml annotations for being used by others. The addition is visible through the project explorer and shown below.

Applying profile to a model

The interesting part is now to use the profile defined into previous section. For that, you’ll have now to create a new empty model. Use the first method as in the first section but be careful this time to seelct Model as the root element of your model. Just call your file testModel.uml for exemple.

Like in the previous section, we’ll now have to define a new representation suitable for manipulating our model. We can choose a NewModel Package Hierarchy in the options available with a right-click on model node (sub-menu of New Represention). You can now use these representation to create a Package (with the corresponding tool from the palette) within your model. In my sample, package is named com.github.lbroudoux.uml.domain (see below).

From this diagramm, navigate down to the newly created package by right-clicking and choosing Navigate > New detail : Class Diagramm. Call it domain Class Diagramm. Once again, an empty editor appears. You could then add a class (see palette) called Tweet and add it few properties.

The goal now is to add the Taggable stereotype to our Tweet class. In order to do that, you need new tools that are not visible by default. Make them visible by checking the Layers button on the editor. By checking the Profiles layer, you should see new tools appear like below.

The trick here is to use the Apply profile tool from the palette (pick it and click anywhere on the diagramm) and choose the corresponding profile in the dialog box that should appear. After this selection, you should also see the model tree enhanced with a profile application label.

The last operation is now to apply a stereotype to our Tweet class. Just use the Apply stereotype tool by picking it and then selecting the target class. Here again, a dialog box should appear asking you the stereotype(s) you’d like to apply to the class. Just select Taggable that belongs to the profile you have previously applied to this package like in the screenshot below.

Conclusion

You just have created your first Uml model with a custom Uml profile in 5 minutes. Easy no ? Your diagramm now looks like the picture below and you should see that your model tree into the project explorer has been enhanced as well. Stereotype application made your model more readable but also ready to be exploit by other tools like code generators. Maybe – if I found time for this – this post will be followed by another one dedicated to that topic … Anyway, hope this last one helps or made you consider UMLDesigner as an interesting alternative. Let me know !

Advertisements

3 thoughts on “Building and applying UML profiles with Obeo UMLDesigner

  1. Very awesome!!! You have no idea how much time I wasted over the past week tryng to do this very fundamental UML2 modeling task with the Eclipse Modeling release’s _built-in_ tools. It’s crazy how long its been since EMF added a UML2 model and editor to its standard suite which has implementation details for profile support, yet their out-of-box editor doesn’t seem to offer a ways to do the setup work to construct a useable profile object…

  2. Great post! I need to warn that this proccess has change a bit on Obeo UML Designer 3.0.0. In this version the “Profile Diagram” is hidden in a new Viewpoint. To enable it select “Viewpoints Selection” right clicking the UML Project and the selecting the “UML Profile Design” checkbox.

    I’m now trying to add some property for my class stereotype and then set it on my model.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s