cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dkazimirc...@apache.org
Subject svn commit: r1151367 - in /cayenne/main/branches/STABLE-3.0/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/
Date Wed, 27 Jul 2011 07:33:51 GMT
Author: dkazimirchyk
Date: Wed Jul 27 07:33:50 2011
New Revision: 1151367

URL: http://svn.apache.org/viewvc?rev=1151367&view=rev
Log:
CAY-1469 Modeler: dbRelationships renaming problem

we need to update dbAttributePaths of all flattened ObjAttributes on dbRelationshipChanged
event

Modified:
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
    cayenne/main/branches/STABLE-3.0/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java?rev=1151367&r1=1151366&r2=1151367&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/DbEntity.java
Wed Jul 27 07:33:50 2011
@@ -537,6 +537,18 @@ public class DbEntity extends Entity imp
         // handle relationship name changes
         if (e.getId() == RelationshipEvent.CHANGE && e.isNameChange()) {
             String oldName = e.getOldName();
+            
+            DataMap map = getDataMap();
+            if (map != null) {
+                
+                // updating dbAttributePaths for attributes of all ObjEntities
+                for (ObjEntity objEntity : getDataMap().getObjEntities()) {
+                    
+                    for (ObjAttribute attribute : objEntity.getAttributes()) {
+                        attribute.updateDbAttributePath();
+                    }
+                }
+            }
 
             // clear the relationship out of the collection
             relationships.remove(oldName);

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java?rev=1151367&r1=1151366&r2=1151367&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjAttribute.java
Wed Jul 27 07:33:50 2011
@@ -368,4 +368,27 @@ public class ObjAttribute extends Attrib
 
         return attribute;
     }
+    
+    /**
+     * Updates DbAttributePath for this ObjAttribute
+     */
+    public void updateDbAttributePath() {
+        
+        if (isFlattened()) {
+            StringBuilder newDbAttributePath = new StringBuilder();
+            
+            Iterator<CayenneMapEntry> dbPathIterator = getDbPathIterator();
+            
+            while (dbPathIterator.hasNext()) {
+                CayenneMapEntry next = dbPathIterator.next();
+                
+                newDbAttributePath.append(next.getName());
+                if (next instanceof DbRelationship) {
+                    newDbAttributePath.append('.');
+                }
+            }
+            
+            setDbAttributePath(newDbAttributePath.toString());
+        }
+    }
 }

Modified: cayenne/main/branches/STABLE-3.0/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.0/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java?rev=1151367&r1=1151366&r2=1151367&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.0/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java
(original)
+++ cayenne/main/branches/STABLE-3.0/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/ResolveDbRelationshipDialog.java
Wed Jul 27 07:33:50 2011
@@ -321,10 +321,7 @@ public class ResolveDbRelationshipDialog
         if (!Util.nullSafeEquals(sourceEntityName, relationship.getName())) {
             String oldName = relationship.getName();
 
-            ProjectUtil.setRelationshipName(
-                    relationship.getSourceEntity(),
-                    relationship,
-                    sourceEntityName);
+            relationship.setName(sourceEntityName);
 
             undo.addNameUndo(relationship, oldName, sourceEntityName);
 
@@ -369,10 +366,7 @@ public class ResolveDbRelationshipDialog
 
                 String oldName = reverseRelationship.getName();
 
-                ProjectUtil.setRelationshipName(
-                        reverseRelationship.getSourceEntity(),
-                        reverseRelationship,
-                        targetEntityName);
+                reverseRelationship.setName(targetEntityName);
 
                 undo.addNameUndo(reverseRelationship, oldName, targetEntityName);
 



Mime
View raw message