cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject cayenne git commit: Refactoring DbImport classes
Date Thu, 29 Sep 2016 09:38:49 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 700623048 -> a851b9f44


Refactoring DbImport classes

* better naming


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

Branch: refs/heads/master
Commit: a851b9f44fc2968739427b06d4953aab866b346d
Parents: 7006230
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Thu Sep 29 11:28:08 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Thu Sep 29 12:38:25 2016 +0300

----------------------------------------------------------------------
 .../filters/LegacyFilterConfigBridge.java       | 150 +++++++++++++++++++
 .../loader/filters/OldFilterConfigBridge.java   | 150 -------------------
 .../cayenne/dbimport/FiltersConfigBuilder.java  |   4 +-
 .../apache/cayenne/tools/DbImporterTask.java    |  24 ++-
 .../tools/dbimport/DefaultDbImportAction.java   |   4 -
 .../apache/cayenne/tools/DbImporterMojo.java    |   4 +-
 6 files changed, 171 insertions(+), 165 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/LegacyFilterConfigBridge.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/LegacyFilterConfigBridge.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/LegacyFilterConfigBridge.java
new file mode 100644
index 0000000..90545c6
--- /dev/null
+++ b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/LegacyFilterConfigBridge.java
@@ -0,0 +1,150 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+package org.apache.cayenne.access.loader.filters;
+
+import static org.apache.commons.lang.StringUtils.isBlank;
+
+/**
+ * @since 4.0
+ */
+public class LegacyFilterConfigBridge {
+
+    private String catalog;
+    private String schema;
+
+    private String includeTableFilters;
+    private String includeColumnFilters;
+    private String includeProceduresFilters;
+    private String excludeTableFilters;
+    private String excludeColumnFilters;
+    private String excludeProceduresFilters;
+
+    private boolean loadProcedures;
+
+    public LegacyFilterConfigBridge() {
+    }
+
+    public LegacyFilterConfigBridge catalog(String catalog) {
+        this.catalog = catalog;
+        return this;
+    }
+
+    public String catalog() {
+        return catalog;
+    }
+
+    public LegacyFilterConfigBridge schema(String schema) {
+        this.schema = schema;
+        return this;
+    }
+
+    public String schema() {
+        return schema;
+    }
+
+    public LegacyFilterConfigBridge includeTables(String tableFilters) {
+        if (isBlank(tableFilters)) {
+            return this;
+        }
+
+        this.includeTableFilters = transform(tableFilters);
+        return this;
+    }
+
+    public LegacyFilterConfigBridge includeColumns(String columnFilters) {
+        if (isBlank(columnFilters)) {
+            return this;
+        }
+
+        this.includeColumnFilters = transform(columnFilters);
+        return this;
+    }
+
+    public LegacyFilterConfigBridge includeProcedures(String proceduresFilters) {
+        if (isBlank(proceduresFilters)) {
+            return this;
+        }
+
+        this.includeProceduresFilters = transform(proceduresFilters);
+        return this;
+    }
+
+    public LegacyFilterConfigBridge excludeTables(String tableFilters) {
+        if (isBlank(tableFilters)) {
+            return this;
+        }
+
+        this.excludeTableFilters = transform(tableFilters);
+        return this;
+    }
+
+    public LegacyFilterConfigBridge excludeColumns(String columnFilters) {
+        if (isBlank(columnFilters)) {
+            return this;
+        }
+
+        this.excludeColumnFilters = transform(columnFilters);
+        return this;
+    }
+
+    public LegacyFilterConfigBridge excludeProcedures(String proceduresFilters) {
+        if (isBlank(proceduresFilters)) {
+            return this;
+        }
+
+        this.excludeProceduresFilters = transform(proceduresFilters);
+        return this;
+    }
+
+    private static String transform(String pattern) {
+        return "^" + pattern.replaceAll("[*?]", ".$0") + "$";
+    }
+
+    public void setProceduresFilters(boolean loadProcedures) {
+        this.loadProcedures = loadProcedures;
+    }
+
+    public String getIncludeTableFilters() {
+        return includeTableFilters;
+    }
+
+    public String getIncludeColumnFilters() {
+        return includeColumnFilters;
+    }
+
+    public String getIncludeProceduresFilters() {
+        return includeProceduresFilters;
+    }
+
+    public String getExcludeTableFilters() {
+        return excludeTableFilters;
+    }
+
+    public String getExcludeColumnFilters() {
+        return excludeColumnFilters;
+    }
+
+    public String getExcludeProceduresFilters() {
+        return excludeProceduresFilters;
+    }
+
+    public boolean isLoadProcedures() {
+        return loadProcedures;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/OldFilterConfigBridge.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/OldFilterConfigBridge.java
b/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/OldFilterConfigBridge.java
deleted file mode 100644
index 647d477..0000000
--- a/cayenne-server/src/main/java/org/apache/cayenne/access/loader/filters/OldFilterConfigBridge.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*****************************************************************
- *   Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License.
- ****************************************************************/
-package org.apache.cayenne.access.loader.filters;
-
-import static org.apache.commons.lang.StringUtils.isBlank;
-
-/**
- * @since 3.2.
- */
-public class OldFilterConfigBridge {
-
-    private String catalog;
-    private String schema;
-
-    private String includeTableFilters;
-    private String includeColumnFilters;
-    private String includeProceduresFilters;
-    private String excludeTableFilters;
-    private String excludeColumnFilters;
-    private String excludeProceduresFilters;
-
-    private boolean loadProcedures;
-
-    public OldFilterConfigBridge() {
-    }
-
-    public OldFilterConfigBridge catalog(String catalog) {
-        this.catalog = catalog;
-        return this;
-    }
-
-    public String catalog() {
-        return catalog;
-    }
-
-    public OldFilterConfigBridge schema(String schema) {
-        this.schema = schema;
-        return this;
-    }
-
-    public String schema() {
-        return schema;
-    }
-
-    public OldFilterConfigBridge includeTables(String tableFilters) {
-        if (isBlank(tableFilters)) {
-            return this;
-        }
-
-        this.includeTableFilters = transform(tableFilters);
-        return this;
-    }
-
-    public OldFilterConfigBridge includeColumns(String columnFilters) {
-        if (isBlank(columnFilters)) {
-            return this;
-        }
-
-        this.includeColumnFilters = transform(columnFilters);
-        return this;
-    }
-
-    public OldFilterConfigBridge includeProcedures(String proceduresFilters) {
-        if (isBlank(proceduresFilters)) {
-            return this;
-        }
-
-        this.includeProceduresFilters = transform(proceduresFilters);
-        return this;
-    }
-
-    public OldFilterConfigBridge excludeTables(String tableFilters) {
-        if (isBlank(tableFilters)) {
-            return this;
-        }
-
-        this.excludeTableFilters = transform(tableFilters);
-        return this;
-    }
-
-    public OldFilterConfigBridge excludeColumns(String columnFilters) {
-        if (isBlank(columnFilters)) {
-            return this;
-        }
-
-        this.excludeColumnFilters = transform(columnFilters);
-        return this;
-    }
-
-    public OldFilterConfigBridge excludeProcedures(String proceduresFilters) {
-        if (isBlank(proceduresFilters)) {
-            return this;
-        }
-
-        this.excludeProceduresFilters = transform(proceduresFilters);
-        return this;
-    }
-
-    private static String transform(String pattern) {
-        return "^" + pattern.replaceAll("[*?]", ".$0") + "$";
-    }
-
-    public void setProceduresFilters(boolean loadProcedures) {
-        this.loadProcedures = loadProcedures;
-    }
-
-    public String getIncludeTableFilters() {
-        return includeTableFilters;
-    }
-
-    public String getIncludeColumnFilters() {
-        return includeColumnFilters;
-    }
-
-    public String getIncludeProceduresFilters() {
-        return includeProceduresFilters;
-    }
-
-    public String getExcludeTableFilters() {
-        return excludeTableFilters;
-    }
-
-    public String getExcludeColumnFilters() {
-        return excludeColumnFilters;
-    }
-
-    public String getExcludeProceduresFilters() {
-        return excludeProceduresFilters;
-    }
-
-    public boolean isLoadProcedures() {
-        return loadProcedures;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
index 2991bd1..d7c4d9d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/dbimport/FiltersConfigBuilder.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.dbimport;
 
-import org.apache.cayenne.access.loader.filters.OldFilterConfigBridge;
+import org.apache.cayenne.access.loader.filters.LegacyFilterConfigBridge;
 import org.apache.cayenne.access.loader.filters.CatalogFilter;
 import org.apache.cayenne.access.loader.filters.IncludeTableFilter;
 import org.apache.cayenne.access.loader.filters.SchemaFilter;
@@ -346,7 +346,7 @@ public final class FiltersConfigBuilder {
         }
     }
 
-    public FiltersConfigBuilder add(OldFilterConfigBridge build) {
+    public FiltersConfigBuilder add(LegacyFilterConfigBridge build) {
         if (!isBlank(build.catalog())) {
             engineering.addCatalog(new Catalog(build.catalog()));
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
index 119ebf4..e4fa545 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/DbImporterTask.java
@@ -18,11 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.tools;
 
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.cayenne.access.loader.filters.OldFilterConfigBridge;
+import org.apache.cayenne.access.loader.filters.LegacyFilterConfigBridge;
 import org.apache.cayenne.configuration.ConfigurationNameMapper;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.XMLDataMapLoader;
@@ -30,7 +26,18 @@ import org.apache.cayenne.configuration.server.DataSourceFactory;
 import org.apache.cayenne.configuration.server.DbAdapterFactory;
 import org.apache.cayenne.conn.DataSourceInfo;
 import org.apache.cayenne.dba.DbAdapter;
-import org.apache.cayenne.dbimport.*;
+import org.apache.cayenne.dbimport.AntNestedElement;
+import org.apache.cayenne.dbimport.Catalog;
+import org.apache.cayenne.dbimport.DefaultReverseEngineeringLoader;
+import org.apache.cayenne.dbimport.ExcludeColumn;
+import org.apache.cayenne.dbimport.ExcludeProcedure;
+import org.apache.cayenne.dbimport.ExcludeTable;
+import org.apache.cayenne.dbimport.FiltersConfigBuilder;
+import org.apache.cayenne.dbimport.IncludeColumn;
+import org.apache.cayenne.dbimport.IncludeProcedure;
+import org.apache.cayenne.dbimport.IncludeTable;
+import org.apache.cayenne.dbimport.ReverseEngineering;
+import org.apache.cayenne.dbimport.Schema;
 import org.apache.cayenne.di.DIBootstrap;
 import org.apache.cayenne.di.Injector;
 import org.apache.cayenne.map.DataMap;
@@ -48,6 +55,9 @@ import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
 
 import javax.sql.DataSource;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
 
 public class DbImporterTask extends Task {
 
@@ -56,7 +66,7 @@ public class DbImporterTask extends Task {
     private final ReverseEngineering reverseEngineering = new ReverseEngineering();
     private boolean isReverseEngineeringDefined = false;
 
-    private final OldFilterConfigBridge filterBuilder = new OldFilterConfigBridge();
+    private final LegacyFilterConfigBridge filterBuilder = new LegacyFilterConfigBridge();
 
     public DbImporterTask() {
         config = new DbImportConfiguration();

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
----------------------------------------------------------------------
diff --git a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
index 0be2223..c51300f 100644
--- a/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
+++ b/cayenne-tools/src/main/java/org/apache/cayenne/tools/dbimport/DefaultDbImportAction.java
@@ -154,17 +154,13 @@ public class DefaultDbImportAction implements DbImportAction {
                 @Override
                 public void objEntityAdded(ObjEntity ent) {
                     loadedObjEntities.add(ent);
-
                     super.objEntityAdded(ent);
                 }
 
             }, existing, log(sort(reverse(mergerFactory, mergeTokens))));
 
             DbLoader.flattenManyToManyRelationships(executed, loadedObjEntities, config.getNameGenerator());
-
             relationshipsSanity(executed);
-
-
             saveLoaded(executed);
         }
     }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/a851b9f4/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
----------------------------------------------------------------------
diff --git a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
index ace3369..3e05c5f 100644
--- a/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
+++ b/plugins/maven-cayenne-plugin/src/main/java/org/apache/cayenne/tools/DbImporterMojo.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.tools;
 
-import org.apache.cayenne.access.loader.filters.OldFilterConfigBridge;
+import org.apache.cayenne.access.loader.filters.LegacyFilterConfigBridge;
 import org.apache.cayenne.configuration.ConfigurationNameMapper;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.configuration.XMLDataMapLoader;
@@ -149,7 +149,7 @@ public class DbImporterMojo extends AbstractMojo {
      */
     private boolean usePrimitives;
 
-    private final OldFilterConfigBridge filterBuilder = new OldFilterConfigBridge();
+    private final LegacyFilterConfigBridge filterBuilder = new LegacyFilterConfigBridge();
 
     /**
      * An object that contains reverse engineering rules.


Mime
View raw message