cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1397181 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/DbArcId.java main/java/org/apache/cayenne/access/FlattenedArcKey.java test/java/org/apache/cayenne/access/DbArcIdTest.java
Date Thu, 11 Oct 2012 17:20:19 GMT
Author: aadamchik
Date: Thu Oct 11 17:20:18 2012
New Revision: 1397181

URL: http://svn.apache.org/viewvc?rev=1397181&view=rev
Log:
iCAY-1747 New algorithm for tracking changes to DbEntities underlying flattened attributes
and relationships

using DbRelationship instead of 'name' in DbArcId

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java?rev=1397181&r1=1397180&r2=1397181&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
Thu Oct 11 17:20:18 2012
@@ -2,6 +2,7 @@ package org.apache.cayenne.access;
 
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.util.EqualsBuilder;
 import org.apache.cayenne.util.HashCodeBuilder;
 
@@ -18,23 +19,23 @@ final class DbArcId {
 
     private DbEntity entity;
     private ObjectId sourceId;
-    private String incomingArc;
+    private DbRelationship incomingArc;
 
-    DbArcId(DbEntity entity, ObjectId sourceId, String incomingArc) {
+    DbArcId(DbEntity entity, ObjectId sourceId, DbRelationship incomingArc) {
         this.entity = entity;
         this.sourceId = sourceId;
         this.incomingArc = incomingArc;
     }
-    
+
     DbEntity getEntity() {
         return entity;
     }
-    
+
     ObjectId getSourceId() {
         return sourceId;
     }
-    
-    String getIncominArc() {
+
+    DbRelationship getIncominArc() {
         return incomingArc;
     }
 
@@ -44,7 +45,7 @@ final class DbArcId {
         if (this.hashCode == 0) {
             HashCodeBuilder builder = new HashCodeBuilder(3, 5);
             builder.append(sourceId);
-            builder.append(incomingArc);
+            builder.append(incomingArc.getName());
             this.hashCode = builder.toHashCode();
         }
 
@@ -65,6 +66,7 @@ final class DbArcId {
         DbArcId id = (DbArcId) object;
 
         return new EqualsBuilder().append(sourceId, id.sourceId)
-                .append(incomingArc, id.incomingArc).isEquals();
+                .append(incomingArc.getName(), id.incomingArc.getName())
+                .isEquals();
     }
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java?rev=1397181&r1=1397180&r2=1397181&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
Thu Oct 11 17:20:18 2012
@@ -78,9 +78,8 @@ final class FlattenedArcKey {
                             + dbRelationships.get(1));
         }
 
-        id1 = new DbArcId((DbEntity) r1.getTargetEntity(), sourceId,
-                r1.getName());
-        id2 = new DbArcId(id1.getEntity(), destinationId, r2.getName());
+        id1 = new DbArcId((DbEntity) r1.getTargetEntity(), sourceId, r1);
+        id2 = new DbArcId(id1.getEntity(), destinationId, r2);
     }
 
     /**
@@ -282,7 +281,8 @@ final class FlattenedArcKey {
                 .compareTo(id2.getSourceId().getEntityName());
 
         if (compare == 0) {
-            compare = id1.getIncominArc().compareTo(id2.getIncominArc());
+            compare = id1.getIncominArc().getName()
+                    .compareTo(id2.getIncominArc().getName());
 
             if (compare == 0) {
                 // since ordering is mostly important for detecting equivalent

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java?rev=1397181&r1=1397180&r2=1397181&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
Thu Oct 11 17:20:18 2012
@@ -4,43 +4,52 @@ import junit.framework.TestCase;
 
 import org.apache.cayenne.ObjectId;
 import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
 
 public class DbArcIdTest extends TestCase {
 
     public void testHashCode() {
-        
+
         DbEntity e = new DbEntity("X");
 
-        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"), "r1");
+        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r1"));
         int h1 = id1.hashCode();
         assertEquals(h1, id1.hashCode());
         assertEquals(h1, id1.hashCode());
 
-        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"), "r1");
+        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r1"));
         assertEquals(h1, id1_eq.hashCode());
 
-        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"), "r2");
+        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r2"));
         assertFalse(h1 == id2.hashCode());
 
-        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"), "r1");
+        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"),
+                new DbRelationship("r1"));
         assertFalse(h1 == id3.hashCode());
     }
 
     public void testEquals() {
 
         DbEntity e = new DbEntity("X");
-        
-        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"), "r1");
+
+        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r1"));
         assertTrue(id1.equals(id1));
 
-        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"), "r1");
+        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r1"));
         assertTrue(id1.equals(id1_eq));
         assertTrue(id1_eq.equals(id1));
 
-        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"), "r2");
+        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"),
+                new DbRelationship("r2"));
         assertFalse(id1.equals(id2));
 
-        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"), "r1");
+        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"),
+                new DbRelationship("r1"));
         assertFalse(id1.equals(id3));
 
         assertFalse(id1.equals(new Object()));



Mime
View raw message