cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [9/9] cayenne git commit: Merge branch '47'
Date Thu, 11 Dec 2014 10:49:54 GMT
Merge branch '47'

Conflicts:
	cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java


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

Branch: refs/heads/master
Commit: 60ed6905382a44a38b52aad89bb0d259c2533df9
Parents: 2a6ef00 4ad9e8c
Author: aadamchik <aadamchik@apache.org>
Authored: Thu Dec 11 13:43:54 2014 +0300
Committer: aadamchik <aadamchik@apache.org>
Committed: Thu Dec 11 13:43:54 2014 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/access/DbLoader.java     | 32 +++++----
 .../apache/cayenne/access/DbLoaderDelegate.java | 19 ++++++
 .../access/loader/BooleanNameFilter.java        |  2 +-
 .../access/loader/DbLoaderConfiguration.java    | 21 +++++-
 .../access/loader/DefaultDbLoaderDelegate.java  | 11 +++
 .../access/loader/LoggingDbLoaderDelegate.java  | 72 ++++++++++++++++++++
 .../cayenne/access/loader/NameFilter.java       |  2 +-
 .../access/loader/filters/EntityFilters.java    |  9 ++-
 .../access/loader/filters/FilterFactory.java    |  2 +-
 .../mapper/DefaultJdbc2JavaTypeMapper.java      |  2 +-
 .../loader/mapper/Jdbc2JavaTypeMapper.java      |  2 +-
 .../java/org/apache/cayenne/map/DataMap.java    |  6 +-
 .../java/org/apache/cayenne/merge/DbMerger.java |  1 -
 .../access/loader/filters/FiltersFactory.java   |  2 +-
 .../apache/cayenne/tools/DbImporterTask.java    |  4 ++
 .../org/apache/cayenne/tools/ExcludeTable.java  |  2 +-
 .../cayenne/tools/dbimport/DbImportAction.java  |  5 ++
 .../tools/dbimport/DbImportConfiguration.java   | 11 ++-
 .../dbimport/DbImportDbLoaderDelegate.java      |  3 +-
 .../tools/dbimport/config/AntNestedElement.java |  2 +-
 .../cayenne/tools/dbimport/config/Catalog.java  | 13 +++-
 .../config/DefaultReverseEngineeringLoader.java |  7 +-
 .../config/DefaultTypeMapperBuilder.java        |  2 +-
 .../tools/dbimport/config/ExcludeColumn.java    |  2 +-
 .../tools/dbimport/config/ExcludeProcedure.java |  2 +-
 .../tools/dbimport/config/FilterContainer.java  | 31 ++++++++-
 .../dbimport/config/FiltersConfigBuilder.java   |  6 +-
 .../tools/dbimport/config/IncludeColumn.java    |  2 +-
 .../tools/dbimport/config/IncludeProcedure.java |  2 +-
 .../tools/dbimport/config/IncludeTable.java     |  2 +-
 .../tools/dbimport/config/PatternParam.java     |  2 +-
 .../dbimport/config/ReverseEngineering.java     | 29 +++++++-
 .../config/ReverseEngineeringLoader.java        |  2 +-
 .../cayenne/tools/dbimport/config/Schema.java   | 14 +++-
 .../cayenne/tools/dbimport/config/Type.java     |  2 +-
 .../tools/dbimport/config/TypeMapper.java       |  2 +-
 .../cayenne/tools/DbImporterTaskTest.java       | 10 +--
 .../DefaultReverseEngineeringLoaderTest.java    | 13 ++++
 .../tools/build-skip-relationships-loading.xml  | 37 ++++++++++
 ...erseEngineering-skipRelationshipsLoading.xml | 23 +++++++
 .../modeler/dialog/db/DbLoaderHelper.java       |  3 +-
 .../apache/cayenne/tools/DbImporterMojo.java    |  2 +
 .../tools/DbImporterMojoConfigurationTest.java  | 28 ++++++--
 .../cayenne/tools/DbImporterMojoTest.java       | 49 +++++++++++--
 .../cayenne/tools/config/pom-schema-2.xml       | 41 +++++++++++
 .../config/pom-skip-relationships-loading.xml   | 39 +++++++++++
 .../dbimport/testPreserveRelationships-pom.xml  | 44 ++++++++++++
 .../dbimport/testPreserveRelationships.map.xml  | 44 ++++++++++++
 .../testPreserveRelationships.map.xml-result    | 34 +++++++++
 .../dbimport/testPreserveRelationships.sql      | 28 ++++++++
 .../testSkipRelationshipsLoading-pom.xml        | 43 ++++++++++++
 .../testSkipRelationshipsLoading.map.xml-result | 36 ++++++++++
 .../dbimport/testSkipRelationshipsLoading.sql   | 30 ++++++++
 .../dbimport/testUnFlattensManyToMany-pom.xml   | 40 +++++++++++
 .../dbimport/testUnFlattensManyToMany.map.xml   | 55 +++++++++++++++
 .../testUnFlattensManyToMany.map.xml-result     | 60 ++++++++++++++++
 .../tools/dbimport/testUnFlattensManyToMany.sql | 42 ++++++++++++
 57 files changed, 970 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
----------------------------------------------------------------------
diff --cc cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
index 3b098c8,4fc17c3..0e38ce9
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
@@@ -18,9 -18,23 +18,10 @@@
   ****************************************************************/
  package org.apache.cayenne.access;
  
 -import java.sql.Connection;
 -import java.sql.DatabaseMetaData;
 -import java.sql.ResultSet;
 -import java.sql.SQLException;
 -import java.util.ArrayList;
 -import java.util.Arrays;
 -import java.util.Collection;
 -import java.util.HashMap;
 -import java.util.LinkedList;
 -import java.util.List;
 -import java.util.Map;
 -import java.util.Set;
 -import java.util.TreeSet;
 -
  import org.apache.cayenne.access.loader.DbLoaderConfiguration;
+ import org.apache.cayenne.access.loader.DefaultDbLoaderDelegate;
  import org.apache.cayenne.access.loader.ManyToManyCandidateEntity;
 +import org.apache.cayenne.access.loader.filters.DbPath;
  import org.apache.cayenne.access.loader.filters.EntityFilters;
  import org.apache.cayenne.access.loader.filters.Filter;
  import org.apache.cayenne.access.loader.filters.FiltersConfig;
@@@ -208,11 -207,14 +209,11 @@@ public class DbLoader 
      /**
       * Returns all tables for given combination of the criteria. Tables returned
       * as DbEntities without any attributes or relationships.
 -     * 
       *
       * @param config
 -     *
 -     * @param types
 -     *            The types of table names to retrieve, null returns all types.
 +     * @param types  The types of table names to retrieve, null returns all types.
       * @return
-      * @since 3.2
+      * @since 4.0
       */
      public Map<DbPath, Map<String, DbEntity>> getTables(DbLoaderConfiguration
config, String[] types)
              throws SQLException {
@@@ -294,26 -300,11 +295,23 @@@
                  // if so, consult the delegate what to do
                  DbEntity oldEnt = map.getDbEntity(dbEntity.getName());
                  if (oldEnt != null) {
 +                    Collection<ObjEntity> oldObjEnt = map.getMappedEntities(oldEnt);
 +                    if (!oldObjEnt.isEmpty()) {
 +                        for (ObjEntity objEntity : oldObjEnt) {
 +                            LOGGER.debug("Delete ObjEntity: " + objEntity.getName());
 +                            map.removeObjEntity(objEntity.getName(), true);
 +                            delegate.objEntityRemoved(objEntity);
 +                        }
 +                    }
 +
 +                    LOGGER.debug("Overwrite DbEntity: " + oldEnt.getName());
                      map.removeDbEntity(oldEnt.getName(), true);
 +                    delegate.dbEntityRemoved(oldEnt);
                  }
 +
                  map.addDbEntity(dbEntity);
  
-                 // notify delegate
-                 if (delegate != null) {
-                     delegate.dbEntityAdded(dbEntity);
-                 }
+                 delegate.dbEntityAdded(dbEntity);
  
                  // delegate might have thrown this entity out... so check if it is still
                  // around before continuing processing
@@@ -751,11 -744,13 +757,13 @@@
          List<DbEntity> entities = loadDbEntities(dataMap, config, tables);
  
          if (entities != null) {
-             loadDbRelationships(config, tables);
-             Collection<ObjEntity> loadedObjEntities = loadObjEntities(dataMap, config,
entities);
+             if (!config.isSkipRelationshipsLoading()) {
+                 loadDbRelationships(config, tables);
+             }
  
 -            loadObjEntities(dataMap, config, entities);
 -            flattenManyToManyRelationships(dataMap);
 -            fireObjEntitiesAddedEvents(dataMap);
++            Collection<ObjEntity> loadedObjEntities = loadObjEntities(dataMap, config,
entities);
 +            flattenManyToManyRelationships(dataMap, loadedObjEntities);
 +            fireObjEntitiesAddedEvents(loadedObjEntities);
          }
      }
  

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
----------------------------------------------------------------------
diff --cc cayenne-server/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
index 1919c46,f5833d7..ec31e10
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoaderDelegate.java
@@@ -19,7 -19,9 +19,8 @@@
  
  package org.apache.cayenne.access;
  
 -import org.apache.cayenne.CayenneException;
  import org.apache.cayenne.map.DbEntity;
+ import org.apache.cayenne.map.DbRelationship;
  import org.apache.cayenne.map.ObjEntity;
  
  /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DefaultDbLoaderDelegate.java
----------------------------------------------------------------------
diff --cc cayenne-server/src/main/java/org/apache/cayenne/access/loader/DefaultDbLoaderDelegate.java
index 1e8a593,e512e90..70a0230
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DefaultDbLoaderDelegate.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/DefaultDbLoaderDelegate.java
@@@ -18,8 -18,10 +18,9 @@@
   ****************************************************************/
  package org.apache.cayenne.access.loader;
  
 -import org.apache.cayenne.CayenneException;
  import org.apache.cayenne.access.DbLoaderDelegate;
  import org.apache.cayenne.map.DbEntity;
+ import org.apache.cayenne.map.DbRelationship;
  import org.apache.cayenne.map.ObjEntity;
  
  /**

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-server/src/main/java/org/apache/cayenne/map/DataMap.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportDbLoaderDelegate.java
----------------------------------------------------------------------
diff --cc cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportDbLoaderDelegate.java
index 3ff918e,99f9bc8..a97fd03
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportDbLoaderDelegate.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DbImportDbLoaderDelegate.java
@@@ -19,7 -19,13 +19,8 @@@
  
  package org.apache.cayenne.tools.dbimport;
  
 -import java.util.ArrayList;
 -import java.util.Collections;
 -import java.util.List;
 -
 -import org.apache.cayenne.CayenneException;
  import org.apache.cayenne.access.DbLoaderDelegate;
+ import org.apache.cayenne.access.loader.DefaultDbLoaderDelegate;
  import org.apache.cayenne.map.DbEntity;
  import org.apache.cayenne.map.ObjEntity;
  

http://git-wip-us.apache.org/repos/asf/cayenne/blob/60ed6905/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
----------------------------------------------------------------------
diff --cc modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
index 201db31,d9e01d1..5d9d1b3
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbLoaderHelper.java
@@@ -197,9 -213,26 +198,9 @@@ public class DbLoaderHelper 
          }
      }
  
-     final class LoaderDelegate implements DbLoaderDelegate {
+     private final class LoaderDelegate extends DefaultDbLoaderDelegate {
  
 -        public boolean overwriteDbEntity(DbEntity ent) throws CayenneException {
 -            checkCanceled();
 -
 -            if (!overwritePreferenceSet) {
 -                DbLoaderMergeDialog dialog = DbLoaderHelper.getMergeDialogInstance();
 -                dialog.initFromModel(DbLoaderHelper.this, ent.getName());
 -                dialog.centerWindow();
 -                dialog.setVisible(true);
 -                dialog.setVisible(false);
 -            }
 -
 -            if (stoppingReverseEngineering) {
 -                throw new CayenneException("Should stop DB import.");
 -            }
 -
 -            return overwritingEntities;
 -        }
 -
 +        @Override
          public void dbEntityAdded(DbEntity entity) {
              checkCanceled();
  


Mime
View raw message