cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r407079 - in /incubator/cayenne/main/trunk/cayenne/cayenne-java/src: cayenne/java/org/objectstyle/cayenne/ tests/java/org/objectstyle/cayenne/
Date Tue, 16 May 2006 21:02:27 GMT
Author: aadamchik
Date: Tue May 16 14:02:10 2006
New Revision: 407079

URL: http://svn.apache.org/viewcvs?rev=407079&view=rev
Log:
CAY-457

Modified:
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneContextGraphManager.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextChangeLog.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextStateLog.java
    incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/CayenneContextTst.java

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneContextGraphManager.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneContextGraphManager.java?rev=407079&r1=407078&r2=407079&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneContextGraphManager.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/CayenneContextGraphManager.java
Tue May 16 14:02:10 2006
@@ -143,6 +143,19 @@
         return stateLog.dirtyNodes(state);
     }
 
+    public synchronized Object unregisterNode(Object nodeId) {
+        Object node = super.unregisterNode(nodeId);
+        
+        // remove node from other collections...
+        if (node != null) {
+            stateLog.unregisterNode(nodeId);
+            changeLog.unregisterNode(nodeId);
+            return node;
+        }
+
+        return null;
+    }
+
     // ****** Sync Events API *****
     /**
      * Clears commit marker, but keeps all recorded operations.

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextChangeLog.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextChangeLog.java?rev=407079&r1=407078&r2=407079&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextChangeLog.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextChangeLog.java
Tue May 16 14:02:10 2006
@@ -61,11 +61,13 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.objectstyle.cayenne.graph.CompoundDiff;
 import org.objectstyle.cayenne.graph.GraphDiff;
+import org.objectstyle.cayenne.graph.NodeDiff;
 
 /**
  * Stores graph operations in the order they were performed, optionally allowing to set
@@ -83,6 +85,20 @@
         reset();
     }
 
+    void unregisterNode(Object nodeId) {
+        Iterator it = diffs.iterator();
+        while (it.hasNext()) {
+            Object next = it.next();
+
+            if (next instanceof NodeDiff) {
+
+                if (nodeId.equals(((NodeDiff) next).getNodeId())) {
+                    it.remove();
+                }
+            }
+        }
+    }
+
     void setMarker(String markerTag) {
         markers.put(markerTag, new Integer(diffs.size()));
     }
@@ -208,4 +224,5 @@
             return new ArrayList(list.subList(offset, offset + size));
         }
     }
+
 }

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextStateLog.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextStateLog.java?rev=407079&r1=407078&r2=407079&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextStateLog.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/ObjectContextStateLog.java
Tue May 16 14:02:10 2006
@@ -168,8 +168,12 @@
         return objects;
     }
 
+    void unregisterNode(Object nodeId) {
+        dirtyIds.remove(nodeId);
+    }
+
     // *** GraphChangeHandler methods
-    
+
     public void nodeIdChanged(Object nodeId, Object newId) {
         if (dirtyIds.remove(nodeId)) {
             dirtyIds.add(newId);
@@ -199,4 +203,5 @@
     public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) {
         dirtyIds.add(nodeId);
     }
+
 }

Modified: incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/CayenneContextTst.java
URL: http://svn.apache.org/viewcvs/incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/CayenneContextTst.java?rev=407079&r1=407078&r2=407079&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/CayenneContextTst.java
(original)
+++ incubator/cayenne/main/trunk/cayenne/cayenne-java/src/tests/java/org/objectstyle/cayenne/CayenneContextTst.java
Tue May 16 14:02:10 2006
@@ -288,7 +288,11 @@
         Persistent newObject = context.newObject(MockPersistentObject.class);
         context.deleteObject(newObject);
         assertEquals(PersistenceState.TRANSIENT, newObject.getPersistenceState());
-        assertFalse(context.internalGraphManager().dirtyNodes().contains(newObject));
+        assertFalse(context.internalGraphManager().dirtyNodes().contains(
+                newObject.getObjectId()));
+        
+        // see CAY-547 for details...
+        assertFalse(context.internalGraphManager().dirtyNodes().contains(null));
 
         // COMMITTED
         Persistent committed = new MockPersistentObject();
@@ -314,7 +318,7 @@
         context.deleteObject(deleted);
         assertEquals(PersistenceState.DELETED, committed.getPersistenceState());
     }
-    
+
     public void testBeforePropertyReadShouldInflateHollow() {
 
         ObjectId gid = new ObjectId("MtTable1", "a", "b");
@@ -323,8 +327,8 @@
         inflated.setObjectId(gid);
         inflated.setGlobalAttribute1("abc");
 
-        MockClientConnection connection = new MockClientConnection(new GenericResponse(Arrays
-                .asList(new Object[] {
+        MockClientConnection connection = new MockClientConnection(new GenericResponse(
+                Arrays.asList(new Object[] {
                     inflated
                 })));
         ClientChannel channel = new ClientChannel(connection);



Mime
View raw message