Browse Source

Merge pull request #15130 in DESIGN/design from fbp/release to fbp/feature

* commit '8faff3b79c50706c185a334c988765339ca776f9':
  REPORT-137542 - 远程设计下长时间设计后切换模板卡慢
  REPORT-130954 fix: 设计器启动屏蔽不支持的功能
  REPORT-137543 【fr-fbp冒烟】【数据源】设计器数据连接 重命名判断异常
fbp/feature
superman 1 month ago
parent
commit
8b8a33995b
  1. 5
      designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java
  2. 3
      designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java
  3. 6
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java
  4. 4
      designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionListPane.java
  5. 27
      designer-base/src/main/java/com/fr/design/data/datapane/connect/LocalConnectionSource.java
  6. 65
      designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java
  7. 5
      designer-base/src/main/java/com/fr/design/data/datapane/preview/TableDataBeanHelper.java
  8. 5
      designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java
  9. 62
      designer-realize/src/main/java/com/fanruan/boot/adaptation/DesignServerSupportModule.java
  10. 5
      designer-realize/src/main/java/com/fanruan/boot/adaptation/ReportAdaptationComponent.java

5
designer-base/src/main/java/com/fr/design/actions/server/GlobalTableDataAction.java

@ -24,11 +24,8 @@ import com.fr.design.menu.MenuKeySet;
import com.fr.esd.event.DSMapping;
import com.fr.esd.event.DsNameTarget;
import com.fr.esd.event.StrategyEventsNotifier;
import com.fr.log.FineLoggerFactory;
import com.fr.report.LockItem;
import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import javax.swing.KeyStroke;
@ -85,7 +82,7 @@ public class GlobalTableDataAction extends UpdateAction implements ResponseDataS
// 锁定成功,执行后续操作
final DesignerFrame designerFrame = DesignerContext.getDesignerFrame();
final List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData();
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
final Map<String, TableData> tableDataMap = new HashMap<>();
for (ServerDataSetBean bean : beans) {
try {

3
designer-base/src/main/java/com/fr/design/data/datapane/TreeTableDataComboBox.java

@ -14,7 +14,6 @@ import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.stable.StringUtils;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import javax.swing.*;
@ -70,7 +69,7 @@ public class TreeTableDataComboBox extends UIComboBox {
// 全局数据集
List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData();
Map<String, TableData> map = new HashMap<>();
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
try {
for (ServerDataSetBean bean : beans) {
map.put(bean.getDatasetName() , TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData()));

6
designer-base/src/main/java/com/fr/design/data/datapane/connect/ConnectionComboBoxPanel.java

@ -1,8 +1,6 @@
package com.fr.design.data.datapane.connect;
import com.fanruan.config.impl.data.ConnectionConfigProviderFactory;
import com.fine.theme.icon.LazyIcon;
import com.fr.base.svg.IconUtils;
import com.fr.data.impl.AbstractDatabaseConnection;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
@ -15,9 +13,7 @@ import com.fr.design.gui.ibutton.UILockButton;
import com.fr.report.LockItem;
import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.entity.connection.ConnectionBean;
import com.fr.workspace.server.repository.authority.RemoteAuthorityRepository;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import javax.swing.SwingUtilities;
import java.awt.Dimension;
@ -91,7 +87,7 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel {
if (noAuthConnections == null) {
return nameList.iterator();
}
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
for (Map.Entry<String, Connection> connectionEntry : connectionMap.entrySet()) {
String conName = connectionEntry.getKey();
if (noAuthConnections.contains(conName)) {

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

@ -207,7 +207,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
public void populate(Map<String, Connection> connectionMap) {
List<NameObject> nameObjectList = new ArrayList<NameObject>();
populatedConnectionsSnapshot.clear();
final Map<String, Connection> map = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> map = ConnectionInfoBeanHelper.getCurrentConnectionMap();
for (Map.Entry<String, Connection> entry : map.entrySet()) {
nameObjectList.add(new NameObject(entry.getKey(), entry.getValue()));
try {
@ -369,7 +369,7 @@ public class ConnectionListPane extends JListControlPane implements ConnectionSh
public static void showDialog(Window parent) {
try {
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
final ConnectionManagerPane connectionManagerPane = new ConnectionManagerPane() {
@Override
public void complete() {

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

@ -1,7 +1,10 @@
package com.fr.design.data.datapane.connect;
import com.fanruan.config.impl.data.ConnectionConfigProviderFactory;
import com.fanruan.datasource.driver.bean.DriverLoaderBean;
import com.fr.data.driver.DriverClassNotFoundException;
import com.fr.data.driver.DriverLoader;
import com.fr.data.driver.config.DriverLoaderConfig;
import com.fr.data.impl.Connection;
import com.fr.decision.webservice.bean.datasource.ConnectionInfoBean;
import com.fr.decision.webservice.exception.general.DriverNotFoundException;
@ -9,13 +12,15 @@ import com.fr.decision.webservice.v10.datasource.connection.processor.impl.Conne
import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper;
import com.fr.design.i18n.Toolkit;
import com.fr.log.FineLoggerFactory;
import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.workspace.engine.exception.DriverUnExistException;
import com.fr.workspace.server.repository.connection.BaseConnectionSource;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 本地Connection资源操作
@ -98,6 +103,26 @@ public class LocalConnectionSource extends BaseConnectionSource {
}
@Override
public Map<String, DriverLoaderBean> getDriverLoaders() throws Exception {
return DriverLoaderConfig.getInstance().getDriverLoaders().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, entry -> convertDriverLoader(entry.getValue()), (a, b) -> a, LinkedHashMap::new));
}
private DriverLoaderBean convertDriverLoader(DriverLoader driverLoader) {
if (driverLoader == null) {
return null;
}
DriverLoaderBean driverLoaderBean = new DriverLoaderBean();
driverLoaderBean.setName(driverLoader.getName());
driverLoaderBean.setDriverClass(driverLoader.getDriverClass());
driverLoaderBean.setDriverList(driverLoader.getDriverList());
driverLoaderBean.setDriverJarFiles(driverLoader.getDriverJarFiles());
driverLoaderBean.setLoadingStrategy(driverLoader.getLoadingStrategy());
return driverLoaderBean;
}
@Override
public boolean lock(String str) {
// 本地默认锁定成功,让其执行后续动作

65
designer-base/src/main/java/com/fr/design/data/datapane/preview/ConnectionInfoBeanHelper.java

@ -22,20 +22,30 @@ import com.fr.decision.webservice.bean.datasource.JDBCConnectionBean;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.ConnectionProcessorFactory;
import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JDBCConnectionProcessor;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
import com.fr.event.Null;
import com.fr.log.FineLoggerFactory;
import com.fr.module.tool.ActivatorToolBox;
import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import com.fr.third.guava.cache.CacheBuilder;
import com.fr.third.guava.cache.CacheLoader;
import com.fr.third.guava.cache.LoadingCache;
import com.fr.third.springframework.beans.BeanUtils;
import com.fr.workspace.server.repository.WorkplaceConstants;
import com.fr.workspace.server.repository.connection.ConnectionCacheEvent;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.tabledata.DataEncryptionHelper;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
/**
* 数据连接传输工具类
@ -50,19 +60,38 @@ public class ConnectionInfoBeanHelper {
private static final int ORACLE_DEFAULT_FETCH_SIZE = 128;
private static final int DB2_DEFAULT_FETCH_SIZE = 50;
private static final int POSTGRE_DEFAULT_FETCH_SIZE = 10000;
public static final int CACHE_MAX_SIZE = 1;
public static final String VALUE = "value";
private static LoadingCache<String, Map<String, Connection>> cache = CacheBuilder.newBuilder()
// 缓存容量1
.maximumSize(CACHE_MAX_SIZE)
// 默认写入过60S后过期
.expireAfterWrite(60, TimeUnit.SECONDS)
.build(new CacheLoader<String, Map<String, Connection>>() {
@Override
public Map<String, Connection> load(String s) throws Exception {
return updateCache();
}
});
static {
FETCH_SIZE_MAP.put("oracle", ORACLE_DEFAULT_FETCH_SIZE);
FETCH_SIZE_MAP.put("ibm-db2", DB2_DEFAULT_FETCH_SIZE);
FETCH_SIZE_MAP.put("postgresql", POSTGRE_DEFAULT_FETCH_SIZE);
// 监听数据连接缓存失效
EventDispatcher.listen(ConnectionCacheEvent.REMOVE, new Listener<Null>() {
@Override
public void on(Event event, Null aNull) {
cache.invalidateAll();
}
});
}
/**
* 获取连接Map
*/
public static Map<String, Connection> createConnectionMap(ConnectionInfoBean[] beans) {
private static Map<String, Connection> updateCache() {
Map<String, Connection> ans = new HashMap<>();
ConnectionInfoBean[] beans = ConnectionRepository.getInstance().getAll();
for (ConnectionInfoBean infoBean : beans) {
try {
if (JDBCConnectionProcessor.KEY.acceptConnectionTypes().contains(infoBean.getConnectionType())) {
@ -77,23 +106,33 @@ public class ConnectionInfoBeanHelper {
return ans;
}
/**
* 获取连接Map
*/
public static Map<String, Connection> getCurrentConnectionMap() {
try {
return cache.get(VALUE);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
/**
* 根据bean创建连接
*/
public static Connection createConnection(ConnectionInfoBean infoBean) {
Connection connection = null;
try {
if (JDBCConnectionProcessor.KEY.acceptConnectionTypes().contains(infoBean.getConnectionType())) {
connection = createJDBCConnection(infoBean);
} else {
connection = ConnectionProcessorFactory.createConnection(infoBean, true);
}
Connection connection = cache.get(VALUE).get(infoBean.getConnectionName());
if (connection != null) {
connection.setConnectionName(infoBean.getConnectionName());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return connection;
}
return connection;
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
/**

5
designer-base/src/main/java/com/fr/design/data/datapane/preview/TableDataBeanHelper.java

@ -25,13 +25,10 @@ import com.fr.general.sql.SqlUtils;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator;
import com.fr.security.encryption.transmission.TransmissionEncryptionManager;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.tabledata.DataEncryptionHelper;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
@ -52,7 +49,7 @@ public class TableDataBeanHelper {
*/
public static Map<String, TableData> getServerTableDatas() {
final List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData();
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
final Map<String, TableData> tableDataMap = new HashMap<>();
try {
for (ServerDataSetBean bean : beans) {

5
designer-base/src/main/java/com/fr/design/data/tabledata/wrapper/TableDataFactory.java

@ -31,7 +31,6 @@ import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
import com.fr.workspace.server.repository.connection.ConnectionRepository;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import javax.swing.Icon;
@ -205,7 +204,7 @@ public abstract class TableDataFactory {
clearAll();
try {
List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData();
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
Map<String, TableData> tableDataMap = new HashMap<>();
for (ServerDataSetBean bean : beans) {
tableDataMap.put(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData()));
@ -229,7 +228,7 @@ public abstract class TableDataFactory {
Map<String, TableData> tableDataMap = new HashMap<>();
try {
List<ServerDataSetBean> beans = TableDataRepository.getInstance().getAllTableData();
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.createConnectionMap(ConnectionRepository.getInstance().getAll());
final Map<String, Connection> connectionMap = ConnectionInfoBeanHelper.getCurrentConnectionMap();
for (ServerDataSetBean bean : beans) {
tableDataMap.put(bean.getDatasetName(), TableDataBeanHelper.getTableDataSet(connectionMap, bean.getDatasetType(), bean.getDatasetData()));
}

62
designer-realize/src/main/java/com/fanruan/boot/adaptation/DesignServerSupportModule.java

@ -0,0 +1,62 @@
package com.fanruan.boot.adaptation;
import com.fanruan.portal.module.PortalModuleManager;
import com.fr.third.guava.collect.Sets;
import java.util.Optional;
import java.util.Set;
import static com.fanruan.portal.authority.PortalAuthorityItems.ENTERPRISE_GENERAL_ID;
import static com.fanruan.portal.authority.PortalAuthorityItems.ENTERPRISE_ID;
import static com.fanruan.portal.authority.PortalAuthorityItems.MAP_ID;
import static com.fanruan.portal.authority.PortalAuthorityItems.PORTAL_MANAGEMENT_ID;
import static com.fanruan.portal.authority.PortalAuthorityItems.SECURITY_ID;
/**
* 内置服务器支持展示的模块预期调用顺序在业务模块之后
*
* @author Anner
* @since 11.0
* Created on 2024/10/15
*/
public class DesignServerSupportModule {
private final static Set<String> SUPPORT_MODULE = Sets.newHashSet(
// 系统管理
PORTAL_MANAGEMENT_ID,
// 企业设置
ENTERPRISE_ID,
// 企业设置 - 通用设置
ENTERPRISE_GENERAL_ID,
// 安全管理
SECURITY_ID,
// 地图管理
MAP_ID
);
/**
* 注册一下支持展示的模块
*
* @param moduleName name
*/
public static void register(String moduleName) {
Optional.of(moduleName).ifPresent(SUPPORT_MODULE::add);
}
/**
* 取消注册展示的模块
*
* @param moduleName name
*/
public static void unregister(String moduleName) {
Optional.of(moduleName).ifPresent(SUPPORT_MODULE::remove);
}
/**
* 启动入口重建一下展示的module
*/
public static void rebuild() {
PortalModuleManager.allModules().keySet().stream()
.filter(m -> !SUPPORT_MODULE.contains(m))
.forEach(PortalModuleManager::unregister);
}
}

5
designer-realize/src/main/java/com/fanruan/boot/adaptation/ReportAdaptationComponent.java

@ -1,6 +1,7 @@
package com.fanruan.boot.adaptation;
import com.fanruan.carina.Carina;
import com.fanruan.carina.annotions.DependsOn;
import com.fanruan.carina.annotions.FineComponent;
import com.fanruan.carina.annotions.Start;
import com.fanruan.plugins.resource.PluginResourceHelper;
@ -57,8 +58,8 @@ import java.util.TreeSet;
* Created on 2024/6/24
*/
@FineComponent(name = "fine_report_adaptation")
@DependsOn(dependencies = {"fine_report"})
public class ReportAdaptationComponent {
/**
* 启动
*/
@ -74,6 +75,8 @@ public class ReportAdaptationComponent {
// 插件controller注册
PluginControllerManager.getInstance().init();
// 过滤掉内置服务器不支持的模块
DesignServerSupportModule.rebuild();
}
private void listenEmbedServletFilter(ServletContext servletContext) {

Loading…
Cancel
Save