cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [2/9] cayenne git commit: fix maven config loading
Date Thu, 11 Dec 2014 10:49:47 GMT
fix maven config loading


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

Branch: refs/heads/master
Commit: 4e08de86bb83913f672a1e7f2e6b3c2ba8bfa5ed
Parents: 4649832
Author: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Authored: Tue Dec 9 15:50:46 2014 +0300
Committer: alexkolonitsky <Alex.Kolonitsky@gmail.com>
Committed: Tue Dec 9 15:50:46 2014 +0300

----------------------------------------------------------------------
 .../java/org/apache/cayenne/access/DbLoader.java |  2 +-
 .../access/loader/filters/EntityFilters.java     |  7 +++++++
 .../dbimport/config/FiltersConfigBuilder.java    |  4 ++++
 .../tools/DbImporterMojoConfigurationTest.java   | 19 +++++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/4e08de86/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
index 6c55ffc..e1b5a5b 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/DbLoader.java
@@ -373,7 +373,7 @@ public class DbLoader {
 
                 DbAttribute attr = loadDbAttribute(rs);
                 attr.setEntity(dbEntity);
-                Filter<DbAttribute> filter = filters.filter(path).columnFilter();
+                Filter<DbAttribute> filter = filters.filter(new DbPath(dbEntity.getCatalog(),
dbEntity.getSchema(), dbEntity.getName())).columnFilter();
                 if (!filter.isInclude(attr)) {
                     if (LOGGER.isDebugEnabled()) {
                         LOGGER.debug("Skip column for '" + attr.getEntity().getName() + "."
+ attr.getName()

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4e08de86/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
index 22b96bc..fb4fe93 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/EntityFilters.java
@@ -59,6 +59,13 @@ public class EntityFilters {
                 && (proceduresFilters == null || NULL.equals(proceduresFilters));
     }
 
+    public boolean isDefault() {
+        return dbPath == null || DbPath.EMPTY.equals(dbPath)
+                && (tableFilters != null && TRUE.equals(tableFilters))
+                && (columnFilters != null && TRUE.equals(columnFilters))
+                && (proceduresFilters == null || NULL.equals(proceduresFilters));
+    }
+
     public DbPath getDbPath() {
         return dbPath;
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4e08de86/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilder.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilder.java
index 56d6354..d553a6e 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilder.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/config/FiltersConfigBuilder.java
@@ -46,6 +46,10 @@ public final class FiltersConfigBuilder {
     }
 
     public FiltersConfigBuilder add(EntityFilters filter) {
+        if (filter.isDefault()) {
+            return this;
+        }
+
         if (!filter.isEmpty()) {
             this.filters.add(filter);
         } else if (!filter.getDbPath().equals(new DbPath())) {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/4e08de86/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
index 939f185..922c6b7 100644
--- a/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
+++ b/plugins/maven-cayenne-plugin/src/test/java/org/apache/cayenne/tools/DbImporterMojoConfigurationTest.java
@@ -18,16 +18,23 @@
  ****************************************************************/
 package org.apache.cayenne.tools;
 
+import static org.apache.cayenne.access.loader.filters.FilterFactory.NULL;
+import static org.apache.cayenne.access.loader.filters.FilterFactory.exclude;
 import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalog;
 import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertCatalogAndSchema;
 import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertFlat;
 import static org.apache.cayenne.tools.dbimport.config.DefaultReverseEngineeringLoaderTest.assertSchemaContent;
 
+import org.apache.cayenne.access.loader.filters.DbPath;
+import org.apache.cayenne.access.loader.filters.EntityFilters;
+import org.apache.cayenne.access.loader.filters.FiltersConfig;
 import org.apache.cayenne.tools.dbimport.DbImportConfiguration;
 import org.apache.cayenne.tools.dbimport.config.Schema;
 import org.apache.maven.plugin.testing.AbstractMojoTestCase;
 import org.junit.Test;
 
+import java.util.Collections;
+
 public class DbImporterMojoConfigurationTest extends AbstractMojoTestCase {
 
     @Test
@@ -44,6 +51,18 @@ public class DbImporterMojoConfigurationTest extends AbstractMojoTestCase
{
     }
 
     @Test
+    public void testLoadSchema2() throws Exception {
+        FiltersConfig filters = getCdbImport("pom-schema-2.xml").toParameters()
+                .getDbLoaderConfig().getFiltersConfig();
+
+        DbPath path = new DbPath(null, "NHL_STATS");
+        assertEquals(Collections.singletonList(path), filters.getDbPaths());
+
+        EntityFilters filter = filters.filter(path);
+        assertEquals(filter, new EntityFilters(path, exclude("^ETL_.*"), exclude("^ETL_.*"),
NULL));
+    }
+
+    @Test
     public void testLoadCatalogAndSchema() throws Exception {
         assertCatalogAndSchema(getCdbImport("pom-catalog-and-schema.xml").getReverseEngineering());
     }


Mime
View raw message