cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abulat...@apache.org
Subject [cayenne] branch master updated: CAY-2538 Modeler: dbImport configuration unclear behavior
Date Mon, 29 Apr 2019 11:25:53 GMT
This is an automated email from the ASF dual-hosted git repository.

abulatski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new bc3f09a  CAY-2538 Modeler: dbImport configuration unclear behavior
bc3f09a is described below

commit bc3f09ab31cb5345bf6a3fc5bc6d774db126600a
Author: Arseni Bulatski <ancarseni@gmail.com>
AuthorDate: Mon Apr 29 14:22:49 2019 +0300

    CAY-2538 Modeler: dbImport configuration unclear behavior
---
 RELEASE-NOTES.txt                                  |  1 +
 .../reverse/filters/FiltersConfigBuilder.java      | 27 +++++++++++++++-------
 .../dbsync/reverse/filters/TableFilter.java        |  9 ++------
 3 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 311b8ea..bf53690 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -44,6 +44,7 @@ CAY-2531 Modeler: Importing same schema after Import Revert clears all entities
 CAY-2533 Modeler: Exception on validating ObjRelationship without db path
 CAY-2535 Modeler: Impossible to import stored procedure apart from db tables
 CAY-2537 Modeler: Schema Generation Complete popup window is hidden
+CAY-2538 Modeler: dbImport configuration unclear behavior
 CAY-2544 Possible name clash of ivar and property name in generated class
 CAY-2547 CayenneDataObject serialization issue
 CAY-2553 Wrong disjoint prefetch query qualifier
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
index 8756528..7513e99 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/FiltersConfigBuilder.java
@@ -18,6 +18,12 @@
  */
 package org.apache.cayenne.dbsync.reverse.filters;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import java.util.regex.Pattern;
+
 import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
 import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeColumn;
 import org.apache.cayenne.dbsync.reverse.dbimport.ExcludeProcedure;
@@ -30,12 +36,6 @@ import org.apache.cayenne.dbsync.reverse.dbimport.PatternParam;
 import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
 import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-
 /**
  * @since 4.0
  */
@@ -376,16 +376,27 @@ public final class FiltersConfigBuilder {
             }
 
             for (Schema schema : catalog.getSchemas()) {
-                if (schema.getIncludeTables().isEmpty() && catalog.getIncludeTables().isEmpty()
&& engineering.getIncludeTables().isEmpty()) {
+                if (hasCatalogEmptyInclude(catalog, schema)) {
                     schema.addIncludeTable(new IncludeTable());
                 }
             }
         }
 
         for (Schema schema : engineering.getSchemas()) {
-            if (schema.getIncludeTables().isEmpty() && engineering.getIncludeTables().isEmpty())
{
+            if (hasSchemaEmptyInclude(schema)) {
                 schema.addIncludeTable(new IncludeTable());
             }
         }
     }
+
+    private boolean hasCatalogEmptyInclude(Catalog catalog, Schema schema) {
+        return catalog.getIncludeTables().isEmpty() &&
+                catalog.getIncludeProcedures().isEmpty() &&
+                hasSchemaEmptyInclude(schema);
+    }
+
+    private boolean hasSchemaEmptyInclude(Schema schema) {
+           return schema.getIncludeTables().isEmpty() && engineering.getIncludeTables().isEmpty()
&&
+                   schema.getIncludeProcedures().isEmpty() && engineering.getIncludeProcedures().isEmpty();
+    }
 }
diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/TableFilter.java
b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/TableFilter.java
index ac7a4e7..2062cb7 100644
--- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/TableFilter.java
+++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/filters/TableFilter.java
@@ -19,12 +19,12 @@
 package org.apache.cayenne.dbsync.reverse.filters;
 
 
-import org.apache.cayenne.util.Util;
-
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 
+import org.apache.cayenne.util.Util;
+
 /**
  * TableFilter contain at least one IncludeTable always.
  */
@@ -37,11 +37,6 @@ public class TableFilter {
      * Includes can contain only one include table
      */
     public TableFilter(SortedSet<IncludeTableFilter> includes, SortedSet<Pattern>
excludes) {
-        if (includes.isEmpty()) {
-            throw new IllegalArgumentException("TableFilter should contain at least one IncludeTableFilter
always " +
-                    "and it is builder responsibility. If you need table filter without includes,
use EmptyTableFilter");
-        }
-
         this.includes = includes;
         this.excludes = excludes;
     }


Mime
View raw message