Comparing and merging UML models in IBM Rational Software Architect: Part 7. Ad-hoc modeling – Fusing two models with diagrams

IBM® Rational® Software Architect Version 7.0 has a Combine Models command that allows you to combine two ad-hoc models into a single model that can be carried forward into version control. The source and target models appear in a dialog, where elements are aligned, unique elements are marked for inclusion in the final set of semantic elements, and names are adjusted as necessary.

Kim Letkeman (, Development Lead, Modeling Compare Support, IBM Rational

Author photo Kim joined IBM in 2003 with 24 years in large financial and telecommunications systems development. He is the development lead for the Rational Model-Driven Development Platform. His responsibilities include UML and EMF compare support, integrations with ClearCase, CVS, Jazz and RAM, domain modeling, patterns, transform core technology, transform authoring for both model to text and model to model transformations, and test automation.

13 March 2007

The problem

Two people begin a modeling project, and their first instinct is to model the system independently. At some point, they feel that they have sufficiently proven the concept, and they want to start the project proper. Best practice would indicate that their ad-hoc models should now be combined into a single model that can be taken forward into version control. This is a very common scenario in modeling projects.

The primary goal is to arrive at a common set of semantic elements that are shared by all diagrams within the model. However, since each modeler has diagrams that point to the local set of semantic elements, it is necessary to retarget all diagram references to the new common set of elements.

In IBM® Rational® Software Architect Version 6.x, the procedure for this is complex. You need to drag each unique semantic element into the target model (into a shared package for example), and then drag all the useful attributes from duplicate semantic elements in the source model to the equivalent element in the target model. Once you have done this for all semantic elements, you drag the diagrams in the source model into an appropriate location in the target model, and the source model is deleted.

This breaks all references in the diagrams that are still referencing the semantic elements from the source model. Model validation is run at this point, and all references to semantic elements are reconnected to the new common elements using Quick Fix.

This is a tedious and error-prone method, but it is at least possible to do it.

A better solution

In Rational Software Architect Version and later, there is a much better solution to this problem with the new Combine Models command. The source and target models appear in a dialog, where elements are aligned, unique elements are marked for inclusion in the final set of semantic elements, and names are adjusted as necessary.

Diagrams are also marked for inclusion in the target model, and the fuse facility takes care of retargeting all references to the new common semantic elements.

This is now a quick and painless procedure.

A simple example

The following example is greatly simplified, but illustrates just how easy it is to fuse independently created models without losing any diagrams or elements.

Assume two models that are similar in structure and content. The goal is to create a single model with all the unique elements from each and with all diagrams preserved and retargeted to the new shared semantic elements.

Note: the following procedure requires Rational Software Architect Version and later, as previous versions of Rational Software Architect 7 were excessively protective of model integrity and were unable to retarget any but the most trivial set of changes.

Figures 1 through 4 show details about the two models.

Figure 1. Semantic Elements and Structure of Model 1
source tree
Figure 2. Diagram of Model 1
class1, class2, and interface1
Figure 3. Semantic Elements and Structure of Model 2
target tree
Figure 4. Diagram of Model 2
interface and attributes

Combine the two models

These two models have nearly identical structure, but the names and identities of all the elements are quite different. There are diagrams in each model that need to be preserved in the final (target) model.

Looking at the two models, you decide that class class1 will align with class A, class class2 will align with class B, and interface interface1 will align with interface I.

The Combine Models command is available on the pop-up menu when two models with different identities are selected, as shown in Figure 5.

Figure 5. Combine Models command
shows pop-up menu with command

Select the target model

This command starts the Combine Models target selection dialog shown in Figure 6.

Figure 6. Choosing the source and target models
choosing fusetgt.emx as the target

This dialog selects the source and target models for the fusion. Typically, in ad-hoc modeling scenarios, the target model will be preserved and the source model will be deleted after all the useful elements and diagrams have been copied or combined.

You should only select the Attempt to combine models automatically checkbox if there are only additions in the two models, and there is no alignment required. In this article’s scenario, alignment and combination of like elements is the point of the technique, so the box is not selected.

Fuse dialog: align the models

The fuse dialog has two main panes: the source and the target model trees, as shown in Figure 7. Trees are displayed because this operation is all about model structure. Identities are irrelevant when merging by structure.

Figure 7. Visual Combine
checkmark changes from the source model

When you select the checkboxes on the left, those elements will be included in the target model. You should examine and select each element individually in order to bring it across to the target. The first step, however, is to align the common elements.

Align an element using manual mapping

Right-click the element to choose it as the source element of a manual mapping, as shown in Figure 8.

Figure 8. Select Source element
Select Source element for manual map

The target element has a similar option, as shown in Figure 9.

Figure 9. Select Target element
Select Target element for manual map

Confirmation is requested in the Create Manual Mapping dialog shown in Figure 10.

Figure 10. Confirming the Manual Mapping
do you want to create a new manual mapping

After you create a manual mapping entry, it displays in the manual mappings pane as shown in Figure 11.

Figure 11. Displaying the manual mapping

Align the rest of the elements as described earlier. As a useful byproduct of aligning the classes and the interface, Rational Software Architect automatically aligns the relationships, as shown in Figure 12.

Figure 12. Relationships are automatically aligned

Select the Source Diagram for inclusion in the target

Why is there no checkbox in Figure 13 allowing you to copy the source diagram into the target?

Figure 13. Source diagram with no option to select it
cannot select ClassDiagram1

This happens because diagram deltas have been filtered out by default. To remove the filter, clear it in the list of filters by selecting Filter out Diagram Changes, as shown in Figure 14.

Figure 14. Clear Filter out Diagram Changes from the filter list
option selectedoption cleared

Now, the checkbox is available and you can select it, as shown in Figure 15

Figure 15. Select the Source diagram
ClassDiagram1 selected

The diagram is shown unaligned with the other diagram of the same name. This is the desired result, as both diagrams will be available in the target when the fuse is completed. Since there is no structural content inside a diagram, they are intentionally left unaligned.

There are numerous filters available to remove differences of various types. This is useful so that a session may be tuned to a particular purpose. However, when performing an ad-hoc modeling session, all filtering is best left off so no differences are suppressed.

Choose the final names

For illustrative purposes, Figure 16 show’s class2’s name chosen instead of the equivalent class name (B) in the target model.

Figure 16. Choosing the name
name is currently Class2

You can override an element’s name with one that appears in neither model. To do so, right-click the element and select Override Name, as shown in Figure 17.

Figure 17. Override the name
command on pop-up menu

Now enter a new name (in this case MySpecialInterface), as shown in Figure 18. The new name displays in the source tree shown in Figure 19.

Figure 18. Entering a new name
Override Name dialog box
Figure 19. The new name displays
name is now MySpecialInterface

Finish up

All you had to do to combine these two models, with all useful element data and diagrams preserved, was the following:

  • Perform a bit of alignment using manual match
  • Check the diagram after removing the filter
  • Choose a couple of names

Clicking OK on the fuse dialog combines the two models into one. In less than a second, the system asks you if you want to reload the target model. Of course, the answer is Yes, as shown in Figure 20.

Figure 20. Reload the target model
File Changed dialog

New Target Model semantic elements and structure

Note (in Figure 21) that all of the changes were made successfully.

Figure 21. The final results of combining the models
details under fusetgt

Note that there are two class diagrams, and all of the relationships appear to have been correctly realigned to the new target elements.

The two class diagrams are similarly correct, as shown in Figure 22.

Figure 22. The class diagram details
interface, class, and attributeoverlapping diagram elements

The layout of the second diagram has been affected by the overridden name’s new size. Running automated layout (right-click and select Arrange All, as shown in Figure 23) fixes this easily. Figure 24 shows the results.

Figure 23. Selecting Arrange All
command on pop-up window
Figure 24. The rearranged diagram
final results


Rational Software Architect V7.0.0.2 and later makes combining independently-developed models a simple and very effective way of moving from the ad-hoc modeling stage of a project into the more formal version controlled stage.

The techniques presented in this article are also used when reconciling models to code using the Java to UML transform as the reverse of the UML to Java 5 transform. The temporary model that is constructed by the transform is used as the source in a fuse dialog, and the original UML model is used as the target.

The techniques as presented in this article are usable for this reconciliation operation, which provides a powerful mechanism for examining and capturing architectural and structural changes from the code base.



Get products and technologies



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into Rational software on developerWorks

ArticleTitle=Comparing and merging UML models in IBM Rational Software Architect: Part 7. Ad-hoc modeling – Fusing two models with diagrams