From 33b8a22e2ad7f2d67cd88c7559680b8eeef25cb4 Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 17 Feb 2023 14:26:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-90013=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=9E=E6=8E=A5=E7=B1=BB=E5=9E=8B=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E3=80=91=E4=B9=8B=E5=89=8D=E6=AF=8F=E4=B8=AA=E7=A9=BA?= =?UTF-8?q?bean=E5=AF=B9=E8=B1=A1=E9=83=BD=E6=98=AF=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E7=9A=84=E4=B8=94=E5=86=99equals=E6=96=B9=E6=B3=95=20=E3=80=90?= =?UTF-8?q?=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=A9=BAbean=E5=AF=B9=E8=B1=A1=EF=BC=8C=E5=AE=9E=E7=8E=B0equal?= =?UTF-8?q?s=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/data/datapane/connect/ConnectionManagerPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java index a9798d25c6..6d2c3223fb 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java @@ -8,6 +8,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.file.ConnectionConfig; import com.fr.general.NameObject; import com.fr.license.exception.DataBaseNotSupportedException; +import com.fr.stable.AssistUtils; import com.fr.stable.Nameable; import com.fr.workspace.WorkContext; import com.fr.workspace.server.database.DataBaseTypeOperator; @@ -80,7 +81,7 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio // 仅校验jdbc连接,其他插件数据连接不进行校验 if (connection instanceof JDBCDatabaseConnection) { DatabaseResultBean bean = WorkContext.getCurrent().get(DataBaseTypeOperator.class).validateDatabaseType(connection.getDriver(), connection.feature()); - if (!bean.equals(DatabaseResultBean.DefaultBean())) { + if (!AssistUtils.equals(DatabaseResultBean.EMPTY_BEAN, bean)) { throw new DataBaseNotSupportedException(bean.getMsg()); } } From d91acbb9b733f1cca429b4202fa0586fb6be6e8b Mon Sep 17 00:00:00 2001 From: "Leo.Qin" Date: Fri, 17 Feb 2023 16:21:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-90013=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=8D=E6=94=AF=E6=8C=81=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=BF=9E=E6=8E=A5=E7=B1=BB=E5=9E=8B=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=20=E3=80=90=E9=97=AE=E9=A2=98=E5=8E=9F?= =?UTF-8?q?=E5=9B=A0=E3=80=91=20=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D?= =?UTF-8?q?=E8=B7=AF=E3=80=91=E4=BF=AE=E6=94=B9=E6=A0=A1=E9=AA=8C=E6=96=B9?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConnectionListDialogActionAdapter.java | 3 -- .../datapane/connect/ConnectionListPane.java | 29 +++++++++++++++++++ .../connect/ConnectionManagerPane.java | 28 ------------------ 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java index 635076b596..947cb6e75f 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java @@ -37,9 +37,6 @@ public class ConnectionListDialogActionAdapter extends DialogActionAdapter { return; } try { - // 校验数据库类型 - connectionManagerPane.validateDatabaseType(connectionConfig); - connectionManagerPane.update(connectionConfig); } catch (Exception e) { connectionListDialog.setDoOKSucceed(false); diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java index 0e0a655a08..15dba5d26b 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java @@ -21,6 +21,8 @@ import com.fr.event.EventDispatcher; import com.fr.file.ConnectionConfig; import com.fr.file.ConnectionOperator; import com.fr.general.NameObject; +import com.fr.license.database.BaseDataBaseTypePoint; +import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; @@ -30,12 +32,14 @@ import com.fr.transaction.Configurations; import com.fr.transaction.WorkerFacade; import com.fr.workspace.WorkContext; import com.fr.workspace.server.database.DataBaseTypeOperator; +import org.jetbrains.annotations.NotNull; import java.awt.Window; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -232,10 +236,35 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh } }); + this.validateDatabaseType(addedOrUpdatedConnections); this.validateConnections(addedOrUpdatedConnections); this.alterConnections(removedConnNames, addedOrUpdatedConnections); } + /** + * 校验是否支持所有新增和修改数据连接的数据库类型 + */ + public void validateDatabaseType(@NotNull List addedOrUpdatedConnections) { + Set notSupportedConnections = new HashSet<>(); + if (!addedOrUpdatedConnections.isEmpty()) { + for (ConnectionBean bean : addedOrUpdatedConnections) { + Connection connection = bean.getConnection(); + // 仅校验jdbc连接,其他插件数据连接不进行校验 + boolean connectionIsNotSupported = connection instanceof JDBCDatabaseConnection && !WorkContext.getCurrent().get(DataBaseTypeOperator.class).supportDatabaseType(connection.getDriver(), connection.feature()); + if (connectionIsNotSupported) { + BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature()); + if (dataBaseTypePoint != null && dataBaseTypePoint.getDataBaseType() != null) { + notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType()); + } + } + } + } + if (!notSupportedConnections.isEmpty()) { + throw new DataBaseNotSupportedException(notSupportedConnections, BaseDataBaseTypePoint.getSupportedDatabaseType()); + } + + } + private void validateConnections(List addedOrUpdatedConnections) throws Exception { diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java index 6d2c3223fb..eadf456e09 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java @@ -1,18 +1,8 @@ package com.fr.design.data.datapane.connect; -import com.fr.data.impl.Connection; -import com.fr.data.impl.JDBCDatabaseConnection; import com.fr.design.gui.frpane.LoadingBasicPane; -import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.file.ConnectionConfig; -import com.fr.general.NameObject; -import com.fr.license.exception.DataBaseNotSupportedException; -import com.fr.stable.AssistUtils; -import com.fr.stable.Nameable; -import com.fr.workspace.WorkContext; -import com.fr.workspace.server.database.DataBaseTypeOperator; -import com.fr.workspace.server.database.DatabaseResultBean; import javax.swing.JPanel; import java.awt.BorderLayout; @@ -70,22 +60,4 @@ public class ConnectionManagerPane extends LoadingBasicPane implements Connectio return connectionListPane.isNamePermitted(); } - /** - * 校验是否支持当前选中连接的数据库类型 - */ - public void validateDatabaseType(ConnectionConfig connectionConfig) { - ListModelElement selectedValue = this.connectionListPane.getSelectedValue(); - if (selectedValue != null) { - Nameable wrapper = selectedValue.wrapper; - Connection connection = (Connection) ((NameObject) wrapper).getObject(); - // 仅校验jdbc连接,其他插件数据连接不进行校验 - if (connection instanceof JDBCDatabaseConnection) { - DatabaseResultBean bean = WorkContext.getCurrent().get(DataBaseTypeOperator.class).validateDatabaseType(connection.getDriver(), connection.feature()); - if (!AssistUtils.equals(DatabaseResultBean.EMPTY_BEAN, bean)) { - throw new DataBaseNotSupportedException(bean.getMsg()); - } - } - } - } - } \ No newline at end of file