Browse Source

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

* commit '8122c128980d762c03274ab58ed0192fde0f35db':
  REPORT-90013 修改实现逻辑
  REPORT-90013 设计器新增不支持的数据连接类型可以保存 【问题原因】远程设计下异常显示内容仍为本地lic信息 【改动思路】增加远程设计下获取支持的数据库类型接口
newui
superman 2 years ago
parent
commit
d66c947d0d
  1. 57
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

57
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java

@ -22,6 +22,7 @@ import com.fr.file.ConnectionConfig;
import com.fr.file.ConnectionOperator; import com.fr.file.ConnectionOperator;
import com.fr.general.NameObject; import com.fr.general.NameObject;
import com.fr.license.database.BaseDataBaseTypePoint; import com.fr.license.database.BaseDataBaseTypePoint;
import com.fr.license.database.DBTypes;
import com.fr.license.exception.DataBaseNotSupportedException; import com.fr.license.exception.DataBaseNotSupportedException;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
@ -34,6 +35,7 @@ import com.fr.workspace.WorkContext;
import com.fr.workspace.server.database.DataBaseTypeOperator; import com.fr.workspace.server.database.DataBaseTypeOperator;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import javax.swing.SwingWorker;
import java.awt.Window; import java.awt.Window;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -45,6 +47,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ExecutionException;
/** /**
* Connection List Pane. * Connection List Pane.
@ -54,6 +57,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
private boolean isNamePermitted = true; private boolean isNamePermitted = true;
private final HashMap<String, String> renameMap = new HashMap<>(); private final HashMap<String, String> renameMap = new HashMap<>();
private final Map<String, Connection> populatedConnectionsSnapshot = new LinkedHashMap<>(); private final Map<String, Connection> populatedConnectionsSnapshot = new LinkedHashMap<>();
private static List<String> supportedDatabaseTypes = new ArrayList<>();
public ConnectionListPane() { public ConnectionListPane() {
renameMap.clear(); renameMap.clear();
@ -67,6 +71,30 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
rename(selectedName, getEditingName()); rename(selectedName, getEditingName());
} }
}); });
getSupportedTypes();
}
/**
* 获取本地远程环境lic中未受限制的数据库类型信息
*/
private static void getSupportedTypes() {
SwingWorker<List<String>, Void> getSupportedTypesWorker = new SwingWorker<List<String>, Void>() {
@Override
protected List<String> doInBackground() {
return WorkContext.getCurrent().get(DataBaseTypeOperator.class).getSupportedDatabaseTypes();
}
@Override
protected void done() {
try {
supportedDatabaseTypes = get();
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
};
getSupportedTypesWorker.execute();
} }
@Override @Override
@ -250,19 +278,40 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
for (ConnectionBean bean : addedOrUpdatedConnections) { for (ConnectionBean bean : addedOrUpdatedConnections) {
Connection connection = bean.getConnection(); Connection connection = bean.getConnection();
// 仅校验jdbc连接,其他插件数据连接不进行校验 // 仅校验jdbc连接,其他插件数据连接不进行校验
boolean connectionIsNotSupported = connection instanceof JDBCDatabaseConnection && !WorkContext.getCurrent().get(DataBaseTypeOperator.class).supportDatabaseType(connection.getDriver(), connection.feature()); if (connection instanceof JDBCDatabaseConnection) {
if (connectionIsNotSupported) {
BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature()); BaseDataBaseTypePoint dataBaseTypePoint = BaseDataBaseTypePoint.getDataBaseTypePoint(connection.getDriver(), connection.feature());
if (dataBaseTypePoint != null && dataBaseTypePoint.getDataBaseType() != null) {
if (connectionIsNotSupported(connection, dataBaseTypePoint)) {
notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType()); notSupportedConnections.addAll(dataBaseTypePoint.getDataBaseType());
} }
} }
} }
} }
if (!notSupportedConnections.isEmpty()) { if (!notSupportedConnections.isEmpty()) {
throw new DataBaseNotSupportedException(notSupportedConnections, BaseDataBaseTypePoint.getSupportedDatabaseType()); throw new DataBaseNotSupportedException(notSupportedConnections, supportedDatabaseTypes);
}
}
/**
* 校验当前数据连接是否被限制
*/
private static boolean connectionIsNotSupported(Connection connection, BaseDataBaseTypePoint dataBaseTypePoint) {
return !validateFRDemo(connection.getDriver(), connection.feature()) &&
(dataBaseTypePoint != null && !supportedDatabaseTypes.containsAll(dataBaseTypePoint.getDatabaseType()));
}
/**
* 校验当前是否为FRDemo不对其进行限制
*/
private static boolean validateFRDemo(String driver, String url) {
if (DBTypes.Sqlite.getDriver().equals(driver) && url.contains(DBTypes.Sqlite.getUrlKey())) {
// 产品:对sqlite类型只允许示例连接FRDemo
String databaseName = url.substring(url.lastIndexOf("/") + 1);
return StringUtils.equals("FRDemo.db", databaseName);
} }
return false;
} }

Loading…
Cancel
Save