svn commit: r13134 - trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: tfmorris
Date: 2007-07-24 11:20:31-0700
New Revision: 13134

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

Log:
Mark 2 bugs in namespace calculations

Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java?view=diff&rev=13134&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&r1=13133&r2=13134
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	(original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java	2007-07-24 11:20:31-0700
@@ -1214,6 +1214,8 @@
         try {
             if (Model.getFacade().getModel(ns) != Model.getFacade().getModel(
                     modelElement)) {
+                // TODO: This will incorrectly return false for 
+                // nested Models - tfm
                 return false;
             }
 
@@ -1451,24 +1453,20 @@
     }
 
     private boolean isValidNamespace(UmlAssociation assoc, Namespace ns) {
-        Iterator it = assoc.getConnection().iterator();
-        List namespaces = new ArrayList();
-        while (it.hasNext()) {
-            AssociationEnd end = (AssociationEnd) it.next();
+        List<Namespace> namespaces = new ArrayList<Namespace>();
+        for (AssociationEnd end 
+                : (List<AssociationEnd>) assoc.getConnection()) {
             namespaces.add(end.getParticipant().getNamespace());
         }
-        it = namespaces.iterator();
-        while (it.hasNext()) {
-            Namespace ns1 = (Namespace) it.next();
-            if (it.hasNext()) {
-                Namespace ns2 = (Namespace) it.next();
-                // TODO: this contains a small error (ns can be part
-                // of hierarchy of namespaces, that's not taken into
-                // account)
-                if (ns == getFirstSharedNamespace(ns1, ns2)) {
-                    return true;
-                }
-            }
+        if (namespaces.size() < 2) {
+            return false;
+        }
+        Namespace ns1 = namespaces.get(0);
+        Namespace ns2 = namespaces.get(1);
+        // TODO: This is incorrect.  AssociationEnds must be
+        // visible from Association's namespace, not vice versa. - tfm
+        if (ns == getFirstSharedNamespace(ns1, ns2)) {
+            return true;
         }
         return false;
     }
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.