At itemis, I’ve recently been working on a challenging prototype: the migration of Rational Rose UML models and diagrams to Topcased UML editor (www.topcased.org
While open source (UML) solutions are becoming more and more trendy and mature, in particular in embedded systems area, technologies have still to prove their ability to adapt to existing legacy solutions. This is particularly true when trying to convince people to switch to open source!
Topcased is an IDE for critical systems; it includes a UML2 editor, based on Eclipse UML2 as underlying model and use UML Diagram Interchange concepts to store diagrams model.
On Rose side, the last IBM Rational product RSM allows to import Rose files and to export the model (without diagrams!) into UML2 format, more or less compatible with Topcased.
In this context the question was: is it possible to make a model transformation from Rose diagrams to Topcased diagrams? How much would it be, comparing to re-design every diagram by hand?
The realized prototype is based on openArchitectureWare technologies.
It takes as input:
- the Rose ".mdl" file
- the UML2 model file (.uml) obtained from RSM
The outcomes are:
- the UML2 model file (.uml) slightly modified to comply with Topcased constraints
- the Topcased diagram model file (.umldi)
The scope of the prototype has been reduced to the migration of Use Case, Class and Sequence diagrams.
The Rose file is parsed thanks to an open source library CrazyBeans (crazybeans.sourceforge.net
) which provides an object tree representation of the Rose model.
Model transformations are done with Xtend, using three meta-models: the oAW JavaBean meta-model allowing to easily navigating through an object graph, the UML2 meta-model and the Ecore meta-model for Diagram Interchange.
The picture below shows an architecture overview:
The workflow is as followed:
1. Rational Rose model parsing thanks to CrazyBeans, being integrated as an oAW workflow component.
2. First Xtend transformation to create a “bridge” model between Rose elements and UML2 elements; the purpose of this intermediate model is to ease the navigation while creating the diagrams model.
For example, an object LifelineBridge is created for each lifeline of sequence diagram encountered in the Rose model, linking an InterObjView (Rose concept of lifeline), the UML2 Lifeline and the behaviors that will be attached on this lifeline. When creating diagrams model, each Lifeline will then offer easy access to the rose data, containing graphical information (location, size …) and to UML2 element we need to relate to.
This is illustrated in the picture below:
3. Second Xtend transformation to create diagrams model by navigating through the previously created “bridge” model. Issues of sizes, locations and scaling are managed in this transformation. For this, we use a nice Xtend feature which is to be able to call Java methods directly from Xtend expression language. This allows to write complex formulas and algorithms in Java, better suited for this task, and also to re-use layouts operation already developed in Topcased.
To give an overview of what it looks like, here are some lines of Xtend expressions:
The first operation create the root element "Diagrams" that contained all the diagram elements. For example, when doing diagrams.addAll(bridge.classDiagrams.typeSelect(model::bridge::ClassDiagramBridge).createClassDiagram(model)), we iterate on each ClassDiagramBridge, created during the first transformation, and call createClassDiagram to create the Diagram element, which will be in turn put as a contained object of the Diagrams root element.
This operation creates the Diagram element for the ClassDiagram, creating all the graph nodes/edges for each class and associations that have to be shown on the class diagram.
4. Save UML and UMLDI resources, using Topcased specific resource implementations (writers).
Here are some screenshots giving an overview of the outcomes:
A class diagram in Rational Rose:
The same in Topcased:
A sequence diagram in Rational Rose:
The same in Topcased:
In conclusion, the prototype has been a success. Results were judged quite impressive considering the few days spent to do it. Topcased meta-models and APIs were open and comprehensive enough to be able to exploit them from "outside".
From a technology point of view, Xtend was a good choice for this use case. Indeed the power of expression language allows easy model navigation and creation, and the resulting prototype actually represents few lines of "code". Moreover for the tricky computing parts, it was possible to keep them in Java and even re-use existing APIs.