cayenne-commits mailing list archives

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

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


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

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

    CAY-2538 Modeler: dbImport configuration unclear behavior
    
    (cherry picked from commit bc3f09ab31cb5345bf6a3fc5bc6d774db126600a)
---
 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 20f4d61..8312754 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -19,6 +19,7 @@ CAY-2570 Use MySQL adapter for latest versions of MariaDB
 Bug Fixes:
 
 CAY-2506 Java class generated for Embeddable object is not serializable
+CAY-2538 Modeler: dbImport configuration unclear behavior
 CAY-2550 Modeler: ObjAttribute inspector modifies wrong columns in attribute table
 CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in
dbRelationship
 CAY-2561 Modeler: cgen type combobox doesn't set templates
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