cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: cleanup
Date Tue, 04 Oct 2016 08:51:48 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 8abd632c2 -> b2a3bf575


cleanup


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/b2a3bf57
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/b2a3bf57
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/b2a3bf57

Branch: refs/heads/master
Commit: b2a3bf5753677786398686b594358d38240ca394
Parents: 8abd632
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Tue Oct 4 11:51:43 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Tue Oct 4 11:51:43 2016 +0300

----------------------------------------------------------------------
 .../apache/cayenne/dbsync/merge/DbMerger.java   | 22 +++++++++-----------
 1 file changed, 10 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/b2a3bf57/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbMerger.java
----------------------------------------------------------------------
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbMerger.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbMerger.java
index b3d7119..7e1c261 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbMerger.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/merge/DbMerger.java
@@ -18,7 +18,6 @@
  */
 package org.apache.cayenne.dbsync.merge;
 
-import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactory;
 import org.apache.cayenne.dbsync.reverse.filters.FiltersConfig;
 import org.apache.cayenne.dbsync.reverse.filters.PatternFilter;
@@ -105,14 +104,13 @@ public class DbMerger {
     }
 
     /**
-     * Create and return a {@link List} of {@link MergerToken}s to alter the
-     * given {@link DataNode} to match the given {@link DataMap}
+     * Create MergerTokens that represent the difference between two {@link DataMap} objects.
      */
-    public List<MergerToken> createMergeTokens(DataMap existing, DataMap loadedFomDb)
{
+    public List<MergerToken> createMergeTokens(DataMap dataMap, DataMap dbImport) {
 
-        loadedFomDb.setQuotingSQLIdentifiers(existing.isQuotingSQLIdentifiers());
+        dbImport.setQuotingSQLIdentifiers(dataMap.isQuotingSQLIdentifiers());
 
-        List<MergerToken> tokens = createMergeTokens(filter(existing, filters), loadedFomDb.getDbEntities());
+        List<MergerToken> tokens = createMergeTokens(filter(dataMap, filters), dbImport.getDbEntities());
 
         // sort. use a custom Comparator since only toDb tokens are comparable
         // by now
@@ -140,15 +138,15 @@ public class DbMerger {
         return existingFiltered;
     }
 
-    protected List<MergerToken> createMergeTokens(Collection<DbEntity> existing,
Collection<DbEntity> loadedFromDb) {
-        Collection<DbEntity> dbEntitiesToDrop = new LinkedList<>(loadedFromDb);
+    protected List<MergerToken> createMergeTokens(Collection<DbEntity> entities,
Collection<DbEntity> dbImportedEntities) {
+        Collection<DbEntity> dbEntitiesToDrop = new LinkedList<>(dbImportedEntities);
 
         List<MergerToken> tokens = new LinkedList<>();
-        for (DbEntity dbEntity : existing) {
+        for (DbEntity dbEntity : entities) {
             String tableName = dbEntity.getName();
 
             // look for table
-            DbEntity detectedEntity = findDbEntity(loadedFromDb, tableName);
+            DbEntity detectedEntity = findDbEntity(dbImportedEntities, tableName);
             if (detectedEntity == null) {
                 tokens.add(tokenFactory.createCreateTableToDb(dbEntity));
                 // TODO: does this work properly with createReverse?
@@ -180,7 +178,7 @@ public class DbMerger {
         for (DbEntity e : dbEntitiesToDrop) {
             tokens.add(tokenFactory.createDropTableToDb(e));
             for (DbRelationship relationship : e.getRelationships()) {
-                DbEntity detectedEntity = findDbEntity(existing, relationship.getTargetEntityName());
+                DbEntity detectedEntity = findDbEntity(entities, relationship.getTargetEntityName());
                 if (detectedEntity != null) {
                     tokens.add(tokenFactory.createDropRelationshipToDb(detectedEntity, relationship.getReverseRelationship()));
                 }
@@ -390,7 +388,7 @@ public class DbMerger {
                 merger.valueForNull = new EmptyValueForNullProvider();
             }
 
-            if(merger.filters == null) {
+            if (merger.filters == null) {
                 // default: match all tables, no stored procedures
                 merger.filters = FiltersConfig.create(null, null, TableFilter.everything(),
PatternFilter.INCLUDE_NOTHING);
             }


Mime
View raw message