Workflow for using transformations to merge changes when you develop in both Java and UML
If you use both UML models and Java to plan and develop a system, you can use transformations and their reverse transformations to merge and synchronize your work.
In IBM DevOps Model Architect, the functionality for merging changes between Java and UML changed.
For example, the following use case shows a typical workflow and the results of merging development changes between Java and UML in product versions that were earlier than Rational Software Architect 7.5.4.
Workflow before version Rational Software Architect 7.5.4
If you developed your system in both Java code and UML models, you would typically expect to follow this workflow to keep changes between the two synchronized:
- Add new Java code elements to a Java project. For example, you might add new classes, attributes, and methods to the Java code.
- Add these new elements to the UML model by running the Java-to-UML transformation.
- Modify the UML elements that the Java-to-UML transformation generated from the Java elements that you added.
- Attempt to merge the changes that you made to the UML elements in the model with the Java code by running the reverse UML-to-Java transformation.
If you followed this workflow, your attempt to merge the changes that you made to UML model elements that the Java-to-UML transformation generated from the Java elements that you added would fail. The UML-to-Java transformation could not propagate the UML changes to the Java code because the Java elements that you added manually do not have the @generated tags that are required for UML-to-Java transformation to merge UML changes into Java. The UML-to-Java transformation would not override the code without the @generated tags, so the changes you made in UML would not merge into the Java code. To work around this issue and synchronize the model with the code, you must manually add @generated tags to each new code element, and then run the UML-to-Java transformation.
To synchronize your changes between Java and UML, you would need to follow this workflow, which involves an additional step:
- Add new Java code elements to a Java project.
- Add the new elements to the model by running the Java-to-UML transformation.
- Manually add @generated tags to each new code element.
- Modify the UML elements that the Java-to-UML transformation generated from the Java elements.
- Merge the changes that you made to the UML elements in the model with the Java code by running the reverse UML-to-Java transformation.
The synchronization workflow is different in DevOps Model Architect
Example In DevOps Model Architect
In DevOps Model Architect, you can instruct the UML-to-Java transformation to overwrite elements (attributes) in Java code. This feature, which you invoke by clicking Link Java to UML, automatically adds @generated tags to Java elements that you created manually, so that the UML-to-Java transformation can propagate the UML changes to Java. This option also adds other Java transformation javadoc comments and preserves existing method bodies by adding //begin-user-code and //end-user-code comments. When you click Link Java to UML, the Java elements are linked to their corresponding UML model elements and the UML-to-Java transform can overwrite the corresponding source code elements. After you click this button, subsequent transformations merge as you expect, because the Java elements are linked to the corresponding model elements.
In DevOps Model Architect, this is the workflow you follow to synchronize changes between Java and UML:
- Add new Java code elements to a Java project.
- Add these new elements to the UML model by running the Java-to-UML transformation.
- Link all code elements to the model by clicking Link Java to UML.
- Modify the UML model elements.
- Merge the changes that you made in the model with the Java code by running the UML-to-Java transformation.