cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skolbac...@apache.org
Subject [08/10] cayenne git commit: Exclude table settings in reverse engineering dialog Added @since tag to new public classes
Date Mon, 19 Dec 2016 11:46:24 GMT
Exclude table settings in reverse engineering dialog
Added @since tag to new public classes


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

Branch: refs/heads/master
Commit: 06c918302310430952ea145d2f046d0210b6dc19
Parents: 163a871
Author: Nikita Timofeev <stariy95@gmail.com>
Authored: Thu Dec 15 12:10:00 2016 +0300
Committer: Nikita Timofeev <stariy95@gmail.com>
Committed: Thu Dec 15 12:10:00 2016 +0300

----------------------------------------------------------------------
 docs/doc/src/main/resources/RELEASE-NOTES.txt   |  1 +
 .../cayenne/modeler/action/MigrateAction.java   | 13 ++++---
 .../action/ReverseEngineeringAction.java        |  3 +-
 .../dialog/db/DbActionOptionsDialog.java        | 13 ++++---
 .../modeler/dialog/db/load/DbLoaderContext.java |  9 ++++-
 .../dialog/db/load/DbLoaderOptionsDialog.java   | 29 +++++++++++----
 .../modeler/dialog/db/load/LoadDataMapTask.java |  3 ++
 .../dialog/db/merge/DbMigrateOptionsDialog.java | 39 --------------------
 8 files changed, 50 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 07dcd5b..0c1637d 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -18,6 +18,7 @@ CAY-2164 Relocate builder bootstrap methods from ServerRuntimeBuilder to
ServerR
 CAY-2165 Explicit "contribution" API for easier expansion of DI collections and maps
 CAY-2166 Auto-loading of Cayenne modules
 CAY-2168 Split DbLoader to parts and clean it up
+CAY-2172 Cleanup Modeler import and migrate db actions
 
 Bug Fixes:
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
index af0dcd0..e6b7a8d 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/MigrateAction.java
@@ -20,11 +20,10 @@
 package org.apache.cayenne.modeler.action;
 
 import org.apache.cayenne.dbsync.merge.factory.MergerTokenFactoryProvider;
-import org.apache.cayenne.dbsync.reverse.dbload.DbLoader;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.db.DataSourceWizard;
-import org.apache.cayenne.modeler.dialog.db.merge.DbMigrateOptionsDialog;
+import org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog;
 import org.apache.cayenne.modeler.dialog.db.merge.MergerOptions;
 
 import java.awt.event.ActionEvent;
@@ -33,7 +32,7 @@ import java.util.Collection;
 /**
  * Action that alter database schema to match a DataMap.
  */
-public class MigrateAction extends DBWizardAction<DbMigrateOptionsDialog> {
+public class MigrateAction extends DBWizardAction<DbActionOptionsDialog> {
 
     public MigrateAction(Application application) {
         super(getActionName(), application);
@@ -55,7 +54,7 @@ public class MigrateAction extends DBWizardAction<DbMigrateOptionsDialog>
{
             throw new IllegalStateException("No current DataMap selected.");
         }
 
-        DbMigrateOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
+        DbActionOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
         String selectedCatalog = optionsDialog == null ? null : optionsDialog.getSelectedCatalog();
         String selectedSchema = optionsDialog == null ? null : optionsDialog.getSelectedSchema();
 
@@ -71,7 +70,9 @@ public class MigrateAction extends DBWizardAction<DbMigrateOptionsDialog>
{
     }
 
     @Override
-    protected DbMigrateOptionsDialog createDialog(Collection<String> catalogs, Collection<String>
schemas, String currentCatalog, String currentSchema) {
-        return new DbMigrateOptionsDialog(catalogs, schemas, currentCatalog, currentSchema);
+    protected DbActionOptionsDialog createDialog(Collection<String> catalogs, Collection<String>
schemas,
+                                                 String currentCatalog, String currentSchema)
{
+        return new DbActionOptionsDialog(Application.getFrame(), "Migrate DB Schema: Select
Catalog and Schema",
+                catalogs, schemas, currentCatalog, currentSchema);
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ReverseEngineeringAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ReverseEngineeringAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ReverseEngineeringAction.java
index a2fefb7..de1c75e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ReverseEngineeringAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ReverseEngineeringAction.java
@@ -91,7 +91,8 @@ public class ReverseEngineeringAction extends DBWizardAction<DbLoaderOptionsDial
     }
 
     @Override
-    protected DbLoaderOptionsDialog createDialog(Collection<String> catalogs, Collection<String>
schemas, String currentCatalog, String currentSchema) {
+    protected DbLoaderOptionsDialog createDialog(Collection<String> catalogs, Collection<String>
schemas,
+                                                 String currentCatalog, String currentSchema)
{
         return new DbLoaderOptionsDialog(catalogs, schemas, currentCatalog, currentSchema);
     }
 }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbActionOptionsDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbActionOptionsDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbActionOptionsDialog.java
index 19c479b..20eb185 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbActionOptionsDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/DbActionOptionsDialog.java
@@ -38,7 +38,10 @@ import com.jgoodies.forms.builder.DefaultFormBuilder;
 import com.jgoodies.forms.layout.FormLayout;
 import org.apache.cayenne.modeler.util.CayenneDialog;
 
-public abstract class DbActionOptionsDialog extends CayenneDialog {
+/**
+ * @since 4.0
+ */
+public class DbActionOptionsDialog extends CayenneDialog {
 
     protected static final String WILDCARD_PATTERN = ".*";
     public static final int CANCEL = 0;
@@ -78,9 +81,6 @@ public abstract class DbActionOptionsDialog extends CayenneDialog {
         DefaultFormBuilder builder = new DefaultFormBuilder(layout);
         builder.setDefaultDialogBorder();
 
-        catalogLabel = builder.append("Select Catalog:", catalogSelector, true);
-        schemaLabel = builder.append("Select Schema:", schemaSelector);
-
         initForm(builder);
 
         JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
@@ -141,7 +141,10 @@ public abstract class DbActionOptionsDialog extends CayenneDialog {
         }
     }
 
-    protected abstract void initForm(DefaultFormBuilder builder);
+    protected void initForm(DefaultFormBuilder builder) {
+        catalogLabel = builder.append("Select Catalog:", catalogSelector, true);
+        schemaLabel = builder.append("Select Schema:", schemaSelector);
+    }
 
     public int getChoice() {
         return choice;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderContext.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderContext.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderContext.java
index 65b9b6e..d11691a 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderContext.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderContext.java
@@ -44,6 +44,9 @@ import org.apache.cayenne.util.Util;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+/**
+ * @since 4.0
+ */
 public class DbLoaderContext {
 
     private static Log LOGGER = LogFactory.getLog(DbLoaderContext.class);
@@ -116,7 +119,11 @@ public class DbLoaderContext {
         ReverseEngineering reverseEngineering = new ReverseEngineering();
         reverseEngineering.addCatalog(new Catalog(dialog.getSelectedCatalog()));
         reverseEngineering.addSchema(new Schema(dialog.getSelectedSchema()));
-        reverseEngineering.addIncludeTable(new IncludeTable(dialog.getTableNamePattern()));
+        reverseEngineering.addIncludeTable(new IncludeTable(dialog.getTableIncludePattern()));
+        if(dialog.getTableExcludePattern() != null) {
+            reverseEngineering.addExcludeTable(new ExcludeTable(dialog.getTableExcludePattern()));
+        }
+        // Add here auto_pk_support table
         reverseEngineering.addExcludeTable(new ExcludeTable("auto_pk_support|AUTO_PK_SUPPORT"));
         reverseEngineering.addIncludeProcedure(new IncludeProcedure(dialog.getProcedureNamePattern()));
         FiltersConfigBuilder filtersConfigBuilder = new FiltersConfigBuilder(reverseEngineering);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderOptionsDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderOptionsDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderOptionsDialog.java
index e1c422e..192a5aa 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderOptionsDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/DbLoaderOptionsDialog.java
@@ -35,7 +35,8 @@ import javax.swing.JTextField;
  */
 public class DbLoaderOptionsDialog extends DbActionOptionsDialog {
 
-    private JTextField tableNamePatternField;
+    private JTextField tableIncludePatternField;
+    private JTextField tableExcludePatternField;
     private JTextField meaningfulPk;
     private JTextField procNamePatternField;
     private JComboBox<String> strategyCombo;
@@ -52,9 +53,13 @@ public class DbLoaderOptionsDialog extends DbActionOptionsDialog {
 
     @Override
     protected void initForm(DefaultFormBuilder builder) {
-        tableNamePatternField = new JTextField();
-        tableNamePatternField.setToolTipText("<html>Regular expression to filter table
names.<br>" +
+        super.initForm(builder);
+        tableIncludePatternField = new JTextField();
+        tableIncludePatternField.setToolTipText("<html>Regular expression to filter
table names.<br>" +
                 "Default expression <b>.*</b> includes all tables.</html>");
+        tableExcludePatternField = new JTextField();
+        tableExcludePatternField.setToolTipText("<html>Regular expression to filter
table names.<br>" +
+                "Empty by default excludes nothing.</html>");
         procNamePatternField = new JTextField();
         procNamePatternField.setToolTipText("<html>Regular expression to filter stored
procedures names.<br>" +
                 "Default expression <b>.*</b> includes all stored procedures.</html>");
@@ -65,7 +70,8 @@ public class DbLoaderOptionsDialog extends DbActionOptionsDialog {
         strategyCombo = new JComboBox<>();
         strategyCombo.setEditable(true);
 
-        builder.append("Table Name Pattern:", tableNamePatternField);
+        builder.append("Table Name Include Pattern:", tableIncludePatternField);
+        builder.append("Table Name Exclude Pattern:", tableExcludePatternField);
         builder.append("Procedure Name Pattern:", procNamePatternField);
         builder.append("Naming Strategy:", strategyCombo);
         builder.append("Tables with Meaningful PK Pattern:", meaningfulPk);
@@ -74,7 +80,7 @@ public class DbLoaderOptionsDialog extends DbActionOptionsDialog {
     protected void initFromModel(Collection<String> catalogs, Collection<String>
schemas, String currentCatalog, String currentSchema) {
         super.initFromModel(catalogs, schemas, currentCatalog, currentSchema);
 
-        this.tableNamePatternField.setText(WILDCARD_PATTERN);
+        this.tableIncludePatternField.setText(WILDCARD_PATTERN);
         this.procNamePatternField.setText(WILDCARD_PATTERN);
 
         Vector<String> arr = NameGeneratorPreferences
@@ -83,9 +89,16 @@ public class DbLoaderOptionsDialog extends DbActionOptionsDialog {
         strategyCombo.setModel(new DefaultComboBoxModel<>(arr));
     }
 
-    String getTableNamePattern() {
-        return "".equals(tableNamePatternField.getText()) ? null : tableNamePatternField
-                .getText();
+    String getTableIncludePattern() {
+        return "".equals(tableIncludePatternField.getText()) ?
+                null :
+                tableIncludePatternField.getText();
+    }
+
+    String getTableExcludePattern() {
+        return "".equals(tableExcludePatternField.getText()) ?
+                null :
+                tableExcludePatternField.getText();
     }
 
     String getMeaningfulPk() {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/LoadDataMapTask.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/LoadDataMapTask.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/LoadDataMapTask.java
index ceb0d44..d592385 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/LoadDataMapTask.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/load/LoadDataMapTask.java
@@ -32,6 +32,9 @@ import org.apache.cayenne.tools.dbimport.DbImportModule;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+/**
+ * @since 4.0
+ */
 final public class LoadDataMapTask extends LongRunningTask {
 
     private static Log LOGGER = LogFactory.getLog(DbLoaderContext.class);

http://git-wip-us.apache.org/repos/asf/cayenne/blob/06c91830/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/DbMigrateOptionsDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/DbMigrateOptionsDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/DbMigrateOptionsDialog.java
deleted file mode 100644
index d044b30..0000000
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/merge/DbMigrateOptionsDialog.java
+++ /dev/null
@@ -1,39 +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.modeler.dialog.db.merge;
-
-import java.util.Collection;
-
-import com.jgoodies.forms.builder.DefaultFormBuilder;
-import org.apache.cayenne.modeler.Application;
-import org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog;
-
-public class DbMigrateOptionsDialog extends DbActionOptionsDialog {
-    
-    public DbMigrateOptionsDialog(Collection<String> catalogs, Collection<String>
schemas,
-                                  String defaultCatalog, String defaultSchema) {
-        super(Application.getFrame(), "Migrate DB Schema: Select Catalog and Schema",
-                catalogs, schemas, defaultCatalog, defaultSchema);
-    }
-
-    @Override
-    protected void initForm(DefaultFormBuilder builder) {
-    }
-}


Mime
View raw message