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: Modeler: add table types filter to refresh db schema.
Date Fri, 19 Jul 2019 08:31:46 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 74ab8d1  Modeler: add table types filter to refresh db schema.
74ab8d1 is described below

commit 74ab8d146484deff180f1dae2348c237dd935b33
Author: Arseni Bulatski <ancarseni@gmail.com>
AuthorDate: Fri Jul 19 11:30:07 2019 +0300

    Modeler: add table types filter to refresh db schema.
---
 .../cayenne/modeler/action/LoadDbSchemaAction.java  | 18 ++++++++++--------
 .../editor/dbimport/DatabaseSchemaLoader.java       | 21 +++++++++++++--------
 .../modeler/editor/dbimport/DbImportView.java       |  6 ++++++
 .../dbimport/ReverseEngineeringConfigPanel.java     |  2 +-
 4 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/LoadDbSchemaAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/LoadDbSchemaAction.java
index da0c659..5958812 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/LoadDbSchemaAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/LoadDbSchemaAction.java
@@ -19,6 +19,11 @@
 
 package org.apache.cayenne.modeler.action;
 
+import javax.swing.JOptionPane;
+import javax.swing.tree.TreePath;
+import java.awt.event.ActionEvent;
+import java.sql.SQLException;
+
 import org.apache.cayenne.dbsync.reverse.dbimport.ReverseEngineering;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.dialog.db.DataSourceWizard;
@@ -30,16 +35,11 @@ import org.apache.cayenne.modeler.pref.DBConnectionInfo;
 import org.apache.cayenne.modeler.pref.DataMapDefaults;
 import org.apache.cayenne.modeler.util.CayenneAction;
 
-import javax.swing.JOptionPane;
-import javax.swing.tree.TreePath;
-import java.awt.event.ActionEvent;
-import java.sql.SQLException;
-
 import static org.apache.cayenne.modeler.pref.DBConnectionInfo.DB_ADAPTER_PROPERTY;
+import static org.apache.cayenne.modeler.pref.DBConnectionInfo.JDBC_DRIVER_PROPERTY;
+import static org.apache.cayenne.modeler.pref.DBConnectionInfo.PASSWORD_PROPERTY;
 import static org.apache.cayenne.modeler.pref.DBConnectionInfo.URL_PROPERTY;
 import static org.apache.cayenne.modeler.pref.DBConnectionInfo.USER_NAME_PROPERTY;
-import static org.apache.cayenne.modeler.pref.DBConnectionInfo.PASSWORD_PROPERTY;
-import static org.apache.cayenne.modeler.pref.DBConnectionInfo.JDBC_DRIVER_PROPERTY;
 
 /**
  * @since 4.1
@@ -91,7 +91,9 @@ public class LoadDbSchemaAction extends CayenneAction {
                     draggableTreePanel.getSourceTree().updateTableColumns(databaseReverseEngineering);
                 } else {
                     ReverseEngineering databaseReverseEngineering = new DatabaseSchemaLoader()
-                            .load(connectionInfo, getApplication().getClassLoadingService());
+                            .load(connectionInfo,
+                                    getApplication().getClassLoadingService(),
+                                    rootParent.getTableTypes());
                     draggableTreePanel.getSourceTree()
                             .setEnabled(true);
                     draggableTreePanel.getSourceTree()
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DatabaseSchemaLoader.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DatabaseSchemaLoader.java
index c18dedf..30403a4 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DatabaseSchemaLoader.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DatabaseSchemaLoader.java
@@ -19,6 +19,12 @@
 
 package org.apache.cayenne.modeler.editor.dbimport;
 
+import javax.swing.tree.TreePath;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collection;
+
 import org.apache.cayenne.dbsync.reverse.dbimport.Catalog;
 import org.apache.cayenne.dbsync.reverse.dbimport.IncludeColumn;
 import org.apache.cayenne.dbsync.reverse.dbimport.IncludeProcedure;
@@ -28,12 +34,6 @@ import org.apache.cayenne.dbsync.reverse.dbimport.Schema;
 import org.apache.cayenne.modeler.ClassLoadingService;
 import org.apache.cayenne.modeler.pref.DBConnectionInfo;
 
-import javax.swing.tree.TreePath;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Collection;
-
 public class DatabaseSchemaLoader {
 
     private static final String INCLUDE_ALL_PATTERN = "%";
@@ -48,9 +48,14 @@ public class DatabaseSchemaLoader {
         databaseReverseEngineering = new ReverseEngineering();
     }
 
-    public ReverseEngineering load(DBConnectionInfo connectionInfo, ClassLoadingService loadingService)
throws SQLException {
+    public ReverseEngineering load(DBConnectionInfo connectionInfo,
+                                   ClassLoadingService loadingService,
+                                   String[] tableTypesFromConfig) throws SQLException {
         try (Connection connection = connectionInfo.makeDataSource(loadingService).getConnection())
{
-            String[] types = {"TABLE", "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL
TEMPORARY", "ALIAS", "SYNONYM"};
+            String[] types = tableTypesFromConfig != null && tableTypesFromConfig.length
!= 0 ?
+                    tableTypesFromConfig :
+                    new String[]{"TABLE", "VIEW", "SYSTEM TABLE",
+                            "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM"};
             try (ResultSet rs = connection.getMetaData().getCatalogs()) {
                 String defaultCatalog = connection.getCatalog();
                 while (rs.next()) {
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
index 4987c15..1d4ca2f 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
@@ -284,4 +284,10 @@ public class DbImportView extends JPanel {
     public boolean isInitFromModel() {
         return initFromModel;
     }
+
+    public String[] getTableTypes() {
+        return configPanel
+                .getReverseEngineeringBySelectedMap()
+                .getTableTypes();
+    }
 }
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/ReverseEngineeringConfigPanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/ReverseEngineeringConfigPanel.java
index 90b5bd9..3950729 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/ReverseEngineeringConfigPanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/ReverseEngineeringConfigPanel.java
@@ -102,7 +102,7 @@ public class ReverseEngineeringConfigPanel extends JPanel {
         stripFromTableNames.setText(reverseEngineering.getStripFromTableNames());
     }
 
-    private ReverseEngineering getReverseEngineeringBySelectedMap() {
+    ReverseEngineering getReverseEngineeringBySelectedMap() {
         DataMap dataMap = projectController.getCurrentDataMap();
         return projectController.getApplication().getMetaData().get(dataMap, ReverseEngineering.class);
     }


Mime
View raw message