Browse Source

Merge pull request #11420 in DESIGN/design from final/11.0 to release/11.0

* commit '1557bad5a3e7cd5d637eebda5d9b615fff4f844f':
  REPORT-90013 设计器新增不支持的数据连接类型可以保存 【问题原因】 【改动思路】修改校验方案
  REPORT-90013 设计器新增不支持的数据连接类型可以保存 【问题原因】之前每个空bean对象都是新建的且写equals方法 【改动思路】修改空bean对象,实现equals方法
newui
superman 2 years ago
parent
commit
be2f72caa2
  1. 3
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListDialogActionAdapter.java
  2. 29
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  3. 27
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

3
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);

29
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<ConnectionBean> addedOrUpdatedConnections) {
Set<String> 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<ConnectionBean> addedOrUpdatedConnections) throws Exception {

27
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionManagerPane.java

@ -1,17 +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.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;
@ -69,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 (!bean.equals(DatabaseResultBean.DefaultBean())) {
throw new DataBaseNotSupportedException(bean.getMsg());
}
}
}
}
}
Loading…
Cancel
Save