Rpy Interoperability Developer

This documentation talks about the import of models created with the software IBM Rational Rhapsody into Papyrus. IBM Rational Rhapsody is developed by the IBM company. In this documentation, we reference this software as Rhapsody.

Which Rhapsody version models are supported?

The migration tool has been developed with IBM Rhapsody 8.0.3. Nevertheless, it should work with previous and next versions.

Where are located the Papyrus Intereoperability Rpy plugins?

All Papyrus Rpy user plugins are stored in the Papyrus git org.eclipse.papyrus-interoperability.git, into the subfolder rpy.

Papyrus Interoperability Rpy Metamodel

These 3 plugins provide the papyrus umlrpy metamodel based on Ecore. They describe the internal Rhapsody metamodel. The models created with this metamodel used the file extension *.umlrpy. The QVTo transformations are applied on these files to create the Papyrus UML models.

How has been created this metamodel?

Rhapsody and Papyrus are representing differently similar concepts. The Rhapsody to Papyrus import process is implemented as a set of mapping rules between those two representations. In order to express the mapping rules, a description of Rhapsody representation of UML and graphical concepts has been implemented with a so-called “ecore metamodel�?. This metamodel has been built thanks to an analysis of two complementary public informations:

However, an automated update process is provided as a “developer feature�? : when a user provides a new Rhapsody model containing concepts which had not been encountered in the analyzed examples, the metamodel update with those new concepts can be automated. This features is made to accelerate the implementation of a new mapping rule to an equivalent Papyrus concept. To update the metamodel, you can use the plugin org.eclipse.papyrus.interoperability.rpy.toolsmiths.api.discovery

Papyrus Interoperability Rpy plugins

In addition, there are the plugins org.eclipse.papyrus.uml.m2m.qvto.common and org.eclipse.papyrus.uml.m2m.qvto.common.blackboxes located on the git org.eclipse.papyrus.git in the folder plugins/uml/m2m. These plugins group common code used by Rpy, RSA and Sysml14 interoperability tools.

JUnit tests are provided too. They use EMF-Compare to check that the imported models continues to be equals to the expected one.

How does the migration process work?

The migration process is done in 3 steps:

  1. the *rpy file is parsed by the XText parser (plugin org.eclipse.papyrus.interoperability.rhapsody.parser) and converted into a first simple model using a first EMF metamodel, RpySyntax, provided by this plugin, then
  2. this first model is converted into a set of *.umlrpy by the class org.eclipse.papyrus.interoperability.rpy.importer.UMLRpyImporter. There is a *.umlrpy file for the initial selected *rpy file, and one other for each subpackage of the imported Rhaposdy model. At the end of this process, we transform these files into the Papyrus UML model.
  3. In the Rhapsody model, there are references to objects provided by Rhapsody Libraries (types, stereotypes, ...) . As we can't reuse them directly (for legal reason), we create "proxy object" during the creation of the *.umlrpy file with an EAnnotation referencing the name of the Rhapsody file providing it. This information is used later in the process by the QVto transformation.

QVTo Informations

The QVTo files are stored in the plugin org.eclipse.papyrus.interoperability.rpy.

Cast

Casting collection doing Type seems change arbitrary the order of the elements. It is a pattern to avoid.

Transformation files

How are chained the QVTo transformations?

Inheritance

It seems possible, but not yet used.

How to develop the QVTo transformation?

How to debug QVTo transformation?

It is possible to use breakpoint to debug QVTo transformation, but in this case you must use the Operatinal QVT Interpreter provided as Debug tool of Eclipse. QVTo Debugging view

QVTo Tricks

Here, we describe the main QVTo keyword to know:

mapping EObject::StoreSourceAndResult(res : EObject) : EObject {

    init { result := res }     

}

It could seem a good idea to apply them when required in the mapping method, but it is not possible, because

  1. the result of the mapping is not yet in stored in the resource, so we get a NPE (main reason),
  2. in some case stereotype properties reference UML object not yet mapped (or stereotype application of others objects),
  3. more complex to override when we want extends a transformation to manage others profiles.

That's why we make a second run to apply profiles and stereotypes on the objects

Stereotype firstStereotype=...//(coming from a parameter of the transformation) element.applyStereotype(firstStereotype); element.setValue(firstStereotype,"propName", newValue);//doesn't work

so we must do :

Stereotype firstStereotype=...//(coming from a parameter of the transformation) element.applyStereotype(firstStereotype); Stereotype secondStereotype=element.getAppliedStereotype(firstStereotype.getQualifiedName()) element.setValue(secondStereotype,"propName", newValue);//works, first and secondStereotype are equals; their resource have the same URI, but 2 instance of the same resource is loaded

Of course, in case of static profile, we can create the EClass represented the UML Stereotype in a mapping method too.

General Tricks

Java code

The plugin org.eclipse.papyrus.interoperability.common is a refactoring of the code provided for RSA migration tool. A part of the embedded code initially written for RSA migration tool is now embedded in this plugin used by Rpy migration tool, but not yet used.

The QVTo transformation is launched by the class org.eclipse.papyrus.interoperability.rpy.transformations.RpyImportTransformationLauncher. The creation of the *.umlrhapsody file is done by the class org.eclipse.papyrus.interoperability.rpy.importer.SelectedRpyFilesImporter.

Versioning

To ease future fixes for generated corrupted models, an EMF EAnnotation is added during the transformation to the root of the UML model and to all created diagrams. This EAnnotation contains:

This work is done by the QVTo library RpyToPapyrusUtils, with the helper method createEAnnotationForVersioning.

Diagram Styling

As we want to get the same style in import models than in the Rhapsody source model, we need to add EAnnoation PapyrusCSSForceValue to override the styling done by CSS stylesheet. The method to create a such EAnnotation is provided by the QVTo library RpyToPapyrusDiagamCommon, by the helper createCSSForceValue.