Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 314971 - Merging the UML metamodel with diagrams for OMG's UML 2.4 RTF
Summary: Merging the UML metamodel with diagrams for OMG's UML 2.4 RTF
Status: VERIFIED FIXED
Alias: None
Product: MDT.UML2
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 blocker (vote)
Target Milestone: RC4   Edit
Assignee: Kenn Hussey CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-28 23:21 EDT by Nicolas Rouquette CLA
Modified: 2010-06-07 17:02 EDT (History)
2 users (show)

See Also:
Kenn.Hussey: pmc_approved+
Ed.Merks: pmc_approved+
Kenn.Hussey: review+


Attachments
UML 2.4 Infrastructure Library (test example) (1.28 MB, application/octet-stream)
2010-05-28 23:22 EDT, Nicolas Rouquette CLA
no flags Details
UML 2.4 PrimitiveTypes library (test example) (9.50 KB, application/octet-stream)
2010-05-28 23:22 EDT, Nicolas Rouquette CLA
no flags Details
UML 2.4 L0 package merge map. (5.68 KB, application/octet-stream)
2010-05-28 23:23 EDT, Nicolas Rouquette CLA
no flags Details
Patch (966 bytes, patch)
2010-05-28 23:26 EDT, Nicolas Rouquette CLA
no flags Details | Diff
alternative patch (1.33 KB, patch)
2010-05-31 14:27 EDT, Kenn Hussey CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Rouquette CLA 2010-05-28 23:21:05 EDT
For the last ballot for UML 2.4 ending in 3 days from now, I have created many diagrams with RSA 7.5 for UML's infrastructure & superstructure. 
I've done dozens of package merges with the help of the fix  https://bugs.eclipse.org/bugs/show_bug.cgi?id=313837

I was in package merge heaven until I updated the model to reflect the resolution for OMG issue 13993: http://www.omg.org/issues/issue13993.txt
The resolution we just finished today involves separating PrimitiveTypes from the InfrastructureLibrary, thus requiring updating all of the package merge maps. 
Now, all package merges fail, including the simplest of all, L0

The problem is subtle but it's been out in the open for several years in:
org.eclipse.uml2.uml.util.UMLUtil.PackageMerger.merge(Package, Map<String, String>, DiagnosticChain, Map<Object, Object>)


		public Map<EObject, List<EObject>> merge(
				org.eclipse.uml2.uml.Package package_,
				Map<String, String> options, DiagnosticChain diagnostics,
				Map<Object, Object> context) {
			receivingPackage = package_;

			mergedPackages = getAllMergedPackages(package_);

			copyAll(mergedPackages);
			copyReferences();

			receivingPackage.getPackageMerges().clear();

			if (options != null) {
				processOptions(options, diagnostics, context);
			}

			return resultingToMergedEObjectMap;
		}
		
As written, the code implicitly assumes that clearing the Package::receivingPackage  collection will be enough to delete the PackageMerge relationships. As long as we've been merging UML infrastructure/superstructure that had no diagrams this code didn't create any problems because by removing the unique in a model to a PackageMerge element was enough to effectively delete it from the model. Since we've been using RSA 7.5 to do the diagrams and RSA uses the GMF notation metamodel to store diagrams as instances of the notation metamodel, every element/relationship in the model shown in a specific diagram has an extra reference from the GMF node/edge showing the element/relationship.

When an RSA diagram shows a package merge relationship from the model, the extra reference to the UML::PackageMerge relationship due to the GMF edge object is enough to alter the behavior of the code above where the UML::PackageMerge element is no longer deleted from the model but left dangling without being logically part of the extent of the model. 

To experience this problem, load the models attached: InfrastructureLibrary.uml, PrimitiveTypes.uml and L0.uml.
Open L0.uml and merge the L0 package with default options.

Then, try to save the model; this will trigger a Dangling HREF exception. 

Before saving, you can also try to validate the model; this time, you'll get a cleaner message about a GMF edge object having a dangling reference to a package merge relationship.

With the simple attached patch, everything works properly. Of course, the diagram in the merged model have lost their reference(s) to the PackageMerge elements that have been deleted but that is to be expected.
Comment 1 Nicolas Rouquette CLA 2010-05-28 23:22:08 EDT
Created attachment 170446 [details]
UML 2.4 Infrastructure Library (test example)
Comment 2 Nicolas Rouquette CLA 2010-05-28 23:22:41 EDT
Created attachment 170447 [details]
UML 2.4 PrimitiveTypes library (test example)
Comment 3 Nicolas Rouquette CLA 2010-05-28 23:23:55 EDT
Created attachment 170448 [details]
UML 2.4 L0 package merge map.

Try merging this model and then either validating or saving the model to reproduce this bug.
Comment 4 Nicolas Rouquette CLA 2010-05-28 23:26:47 EDT
Created attachment 170449 [details]
Patch
Comment 5 Kenn Hussey CLA 2010-05-31 14:27:13 EDT
Created attachment 170574 [details]
alternative patch

Here's a slightly different patch. Please confirm that this meets your needs.
Comment 6 Nicolas Rouquette CLA 2010-05-31 16:11:07 EDT
Thanks Kenn!

This works just fine. We can merge UML 2.4 any way we want, before removing tool-specific content (e.g., diagrams) or after (i.e., diagrams stay in the resulting package)

With this, Eclipse UML2 unconditionally supports the metamodeling workflows involved in the production of OMG UML 2.4.
Of course, this doesn't mean that Eclipse UML2 provides support for OMG UML 2.4 itself; only that the metamodeling machinery needed to produce it works as advertised and in compliance with the fine print of the OMG specifications.
Comment 7 Kenn Hussey CLA 2010-05-31 16:25:10 EDT
The changes have been committed to CVS.
Comment 8 Kenn Hussey CLA 2010-06-07 16:55:33 EDT
This fix is available in 3.1.0 RC4.
Comment 9 Nicolas Rouquette CLA 2010-06-07 17:02:32 EDT
Excellent! This turns out to be useful because merging the UML with diagrams does preserve in the resulting model the diagram information.
Of course, if we do the conversion prior to merging, then we'd be able to merge without this fix but then we loose much more information that may be useful for other purposes.