From c385f65542308bc1e7e1292655beef3674209665 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 25 Oct 2024 11:28:25 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-138311=20=E3=80=90fr-fbp=E5=86=92?= =?UTF-8?q?=E7=83=9F=E3=80=91=E3=80=90=E6=95=B0=E6=8D=AE=E6=BA=90=E3=80=91?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=95=B0=E6=8D=AE=E9=9B=86=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=90=8E=E9=A2=84=E8=A7=88=20=E6=97=A0=E6=B3=95=E5=BC=B9?= =?UTF-8?q?=E5=87=BA=E5=8F=82=E6=95=B0=E7=9A=84=E5=BC=B9=E7=AA=97=EF=BC=8C?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=8A=A5=E9=94=99=E6=88=96=E8=80=85=E7=A9=BA?= =?UTF-8?q?=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 4 + .../function/DesignDatasourceComponent.java | 4 +- .../data/DesignTableDataConfigWrapper.java | 100 ++++++++++++++++++ 3 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 designer-realize/src/main/java/com/fanruan/data/DesignTableDataConfigWrapper.java diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index 9c932f0370..f7a682d891 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -622,6 +622,10 @@ public abstract class DesignTableDataManager { private static boolean checkBean(PreviewSourceBean bean, TableData tableData) { if (bean.getDataName().isEmpty()) { if (tableData instanceof ConditionTableData || tableData instanceof RecursionTableData) { + if (bean.getDataSource() instanceof TableDataSourceTailor.EmptyTableDataSource) { + // 用tabledata传的时候不能是EmptyTableDataSource,因此这里得重新弄个source + bean.setDataSource(new TableDataSourceTailor.TableDataOnlySource()); + } bean.getDataSource().putTableData(StringUtils.EMPTY, tableData); return true; } diff --git a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java index ce2e398b2e..ac4ad00875 100644 --- a/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java +++ b/designer-realize/src/main/java/com/fanruan/boot/env/function/DesignDatasourceComponent.java @@ -12,6 +12,7 @@ import com.fanruan.config.impl.data.ConnectionConfigWriter; import com.fanruan.config.impl.data.ConnectionConfigWriterFactory; import com.fanruan.config.impl.data.TableDataConfigProviderFactory; import com.fanruan.data.ConnectionConfigWrapper; +import com.fanruan.data.DesignTableDataConfigWrapper; import com.fanruan.datasource.connection.processor.ElasticSearchConnectionProcessor; import com.fanruan.datasource.connection.processor.FTPConnectionProcessor; import com.fanruan.datasource.connection.processor.LocalFileConnectionProcessor; @@ -42,7 +43,6 @@ import com.fr.decision.webservice.v10.datasource.connection.processor.impl.JNDIC import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.DataSetProcessorFactory; import com.fr.design.data.datapane.connect.LocalConnectionSource; import com.fr.design.data.tabledata.LocalTableDataSource; -import com.fr.file.TableDataConfigWrapper; import com.fr.workspace.server.repository.connection.ConnectionRepository; import com.fr.workspace.server.repository.connection.ConnectionWriterShell; import com.fr.workspace.server.repository.connection.LocalConnectionShell; @@ -83,7 +83,7 @@ public class DesignDatasourceComponent extends DatasourceComponent { public void start() { // 服务器数据集与数据连接设计器这边先手动切为finedb存储,后续数据中心适配后再切为他们提供的wrapper ConnectionConfigProviderFactory.registerConnectionConfigProvider(ConnectionConfigWrapper.getInstance()); - TableDataConfigProviderFactory.getInstance().registerTableDataConfigProvider(new TableDataConfigWrapper()); + TableDataConfigProviderFactory.getInstance().registerTableDataConfigProvider(new DesignTableDataConfigWrapper()); registerDriverClassLoader(); ConnectionConfigWriterFactory.registerConnectionConfigWriter((ConnectionConfigWriter) ConnectionConfigProviderFactory.getConfigProvider()); Carina.getApplicationContext().singleton(ConnectionWriterShell.class).set(ConnectionConfigWriterFactory.getConfigWriter()); diff --git a/designer-realize/src/main/java/com/fanruan/data/DesignTableDataConfigWrapper.java b/designer-realize/src/main/java/com/fanruan/data/DesignTableDataConfigWrapper.java new file mode 100644 index 0000000000..4115d24410 --- /dev/null +++ b/designer-realize/src/main/java/com/fanruan/data/DesignTableDataConfigWrapper.java @@ -0,0 +1,100 @@ +package com.fanruan.data; + +import com.fanruan.config.impl.data.TableDataConfigProvider; +import com.fr.base.TableData; +import com.fr.decision.webservice.bean.dataset.ServerDataSetBean; +import com.fr.design.data.datapane.preview.ConnectionInfoBeanHelper; +import com.fr.design.data.datapane.preview.TableDataBeanHelper; +import com.fr.file.TableDataConfig; +import com.fr.log.FineLoggerFactory; +import com.fr.transaction.Configurations; +import com.fr.transaction.WorkerAdaptor; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.repository.tabledata.TableDataRepository; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; + +/** + * 设计器的TableData配置Wrapper + *

防止底层错误调用

+ * + * @author Destiny.Lin + * @since 11.0 + * Created on 2024/10/25 + */ +public class DesignTableDataConfigWrapper implements TableDataConfigProvider { + @Override + public Map getTableDatas() { + return TableDataConfig.getInstance().getTableDatas(); + } + + @Override + public void removeTableData(String tableDataName) { + Configurations.update(new WorkerAdaptor(TableDataConfig.class) { + @Override + public void run() { + TableDataConfig.getInstance().removeTableData(tableDataName); + } + }); + } + + @Nullable + @Override + public TableData getTableData(String name) { + if (WorkContext.getCurrent().isLocal()) { + return TableDataConfig.getInstance().getTableData(name); + } + ServerDataSetBean bean = TableDataRepository.getInstance().getTableData(name); + try { + if (bean == null) { + return null; + } + return TableDataBeanHelper.getTableDataSet(ConnectionInfoBeanHelper.getCurrentConnectionMap(), bean.getDatasetType(), bean.getDatasetData()); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + return null; + } + } + + @Override + public void addTableData(String name, TableData tableData) { + Configurations.update(new WorkerAdaptor(TableDataConfig.class) { + @Override + public void run() { + TableDataConfig.getInstance().addTableData(name, tableData); + } + }); + } + + @Override + public void renameTableData(String oldName, String newName) { + Configurations.update(new WorkerAdaptor(TableDataConfig.class) { + @Override + public void run() { + TableDataConfig.getInstance().renameTableData(oldName, newName); + } + }); + } + + @Override + public void updateTableData(String tableDataName, TableData tableData) { + Configurations.update(new WorkerAdaptor(TableDataConfig.class) { + @Override + public void run() { + TableDataConfig.getInstance().removeTableData(tableDataName); + TableDataConfig.getInstance().addTableData(tableDataName, tableData); + } + }); + } + + @Override + public void removeAllTableData() { + Configurations.update(new WorkerAdaptor(TableDataConfig.class) { + @Override + public void run() { + TableDataConfig.getInstance().removeAllTableData(); + } + }); + } +}