cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torehal...@apache.org
Subject svn commit: r764253 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/
Date Sat, 11 Apr 2009 20:54:41 GMT
Author: torehalset
Date: Sat Apr 11 20:54:41 2009
New Revision: 764253

URL: http://svn.apache.org/viewvc?rev=764253&view=rev
Log:
CAY-947: Database Schema Migration should sort tokens
All AddRelationshipToDb are after all other tokens. That seem to
be a simple solution working for me..

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=764253&r1=764252&r2=764253&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Sat Apr 11 20:54:41 2009
@@ -37,6 +37,7 @@
 Bug Fixes Since M5:
 
 CAY-940 CayenneModeler fails on load of existing project file or upon creation of new project
on IBM's Java 1.6.0 SDK on 32-bit ppc
+CAY-947 Database Schema Migration should sort tokens
 CAY-1139 EJBQL condition translation - must track the type of condition
 CAY-1143 CayenneModeler 'Import DataMap' function error
 CAY-1144 EJBQL mixed GROUP BY clause is generated incorrectly

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java?rev=764253&r1=764252&r2=764253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToDbToken.java
Sat Apr 11 20:54:41 2009
@@ -29,7 +29,7 @@
  * database.
  * 
  */
-public abstract class AbstractToDbToken implements MergerToken {
+public abstract class AbstractToDbToken implements MergerToken, Comparable<MergerToken>
{
     
     public final MergeDirection getDirection() {
         return MergeDirection.TO_DB;
@@ -69,6 +69,11 @@
         public String getTokenValue() {
             return getEntity().getName();
         }
+        
+        public int compareTo(MergerToken o) {
+            // default order as tokens are created
+            return 0;
+        }
 
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java?rev=764253&r1=764252&r2=764253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToDb.java
Sat Apr 11 20:54:41 2009
@@ -71,5 +71,14 @@
     public DbRelationship getRelationship() {
         return rel;
     }
+    
+    @Override
+    public int compareTo(MergerToken o) {
+        // add all AddRelationshipToDb to the end.
+        if (o instanceof AddRelationshipToDb) {
+            return super.compareTo(o);
+        }
+        return 1;
+    }
 
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java?rev=764253&r1=764252&r2=764253&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DbMerger.java
Sat Apr 11 20:54:41 2009
@@ -24,6 +24,8 @@
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -170,6 +172,21 @@
                 }
             }
         }
+        
+        // sort. use a custom Comparator since only toDb tokens
+        // are comparable by now
+        Collections.sort(tokens, new Comparator<MergerToken>() {
+
+            public int compare(MergerToken o1, MergerToken o2) {
+                if ((o1 instanceof AbstractToDbToken)
+                        && (o2 instanceof AbstractToDbToken)) {
+                    AbstractToDbToken d1 = (AbstractToDbToken) o1;
+                    AbstractToDbToken d2 = (AbstractToDbToken) o2;
+                    return d1.compareTo(d2);
+                }
+                return 0;
+            }
+        });
 
         return tokens;
     }



Mime
View raw message