svn commit: r15389 - trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2008-07-28 00:27:44-0700
New Revision: 15389

Modified:
   trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java

Log:
Issue 4994: Reuse existing extent instead of creating a new one

Modified: trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java?view=diff&rev=15389&p1=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java&p2=trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java&r1=15388&r2=15389
==============================================================================
--- trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java	(original)
+++ trunk/src/argouml-core-model-mdr/src/org/argouml/model/mdr/XmiReaderImpl.java	2008-07-28 00:27:44-0700
@@ -151,18 +151,31 @@
         
         Collection<RefObject> newElements = Collections.emptyList();
 
-        RefPackage extent;
-        try {
-            extent = modelImpl.getRepository().createExtent(
-                    inputSource.getSystemId(), modelImpl.getMofPackage());
-        } catch (CreationFailedException e1) {
-            throw new UmlException("Extent creation failed", e1);
+        String extentName = inputSource.getSystemId();
+        if (extentName == null) {
+            extentName = inputSource.getPublicId();
+        }
+        if (extentName == null) {
+            extentName = modelImpl.MODEL_EXTENT_NAME;
+        }
+        RefPackage extent = modelImpl.getRepository().getExtent(extentName);
+        if (extent != null) {
+            LOG.warn("Using existing extent " + extentName);
+            // extent.refDelete();
+        } else {
+
+            try {
+                extent = modelImpl.getRepository().createExtent(
+                        inputSource.getSystemId(), modelImpl.getMofPackage());
+            } catch (CreationFailedException e1) {
+                throw new UmlException("Extent creation failed", e1);
+            }
+
+            modelImpl.addExtent((UmlPackage) extent, readOnly);
         }
         
-        modelImpl.addExtent((UmlPackage) extent, readOnly);
-        
         try {
-            LOG.info("Loading '" + inputSource.getSystemId() + "'");
+            LOG.info("Loading to extent'" + extentName + "'");
 
             InputConfig config = new InputConfig();
             config.setUnknownElementsListener(this);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.