Browse Source

Pull request #14470: REPORT-114392 FR-FBP版本本地设计适配 适配数据中心

Merge in DESIGN/design from ~DESTINY.LIN/design:fbp-1.0 to fbp-1.0

* commit '116d4ea2e4ee0b8dafde596675cb8d4d9f67ffb1':
  REPORT-114392 FR-FBP版本本地设计适配 代码规范
  REPORT-114392 FR-FBP版本本地设计适配 适配数据中心
fbp-1.0
Destiny.Lin-林锦龙 5 months ago
parent
commit
9a90660c2b
  1. 80
      designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java
  2. 43
      designer-realize/src/main/java/com/fanruan/boot/env/DesignCorePluginComponent.java
  3. 2
      designer-realize/src/main/java/com/fanruan/boot/env/function/DesignUpdateComponent.java

80
designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java

@ -4,8 +4,13 @@ import com.fr.base.TableData;
import com.fr.base.TableDataBean;
import com.fr.data.MultiResultTableData;
import com.fr.data.TableDataSource;
import com.fr.decision.webservice.bean.dataset.ServerDataSetBean;
import com.fr.decision.webservice.v10.datasource.dataset.processor.impl.DataSetProcessorFactory;
import com.fr.design.data.BasicTableDataUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.MapCompareUtils;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
@ -17,22 +22,22 @@ import com.fr.file.TableDataOperatorImpl;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.log.FineLoggerFactory;
import com.fr.rpc.ExceptionHandler;
import com.fr.rpc.RPCInvokerExceptionInfo;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import com.fr.third.org.apache.commons.collections4.MapUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.repository.tabledata.TableDataRepository;
import javax.swing.DefaultListModel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@ -42,7 +47,7 @@ import java.util.Map;
public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController {
private boolean isNamePermitted = true;
private Map<String, String> dsNameChangedMap = new HashMap<>();
private final Map<String, TableData> populatedTableDataSnapshot = new LinkedHashMap<>();
public TableDataPaneListPane() {
super();
dsNameChangedMap.clear();
@ -197,7 +202,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override
public void populate(TableDataSource tds) {
List<NameObject> nameObjectList = new ArrayList<NameObject>();
populatedTableDataSnapshot.clear();
Iterator tableDataNameIterator = tds.getTableDataNameIterator();
while (tableDataNameIterator.hasNext()) {
String tableDataName = (String) tableDataNameIterator.next();
@ -205,6 +210,11 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
if (tableData != null) {
nameObjectList.add(new NameObject(tableDataName, tableData));
try {
populatedTableDataSnapshot.put(tableDataName, (TableData) tableData.clone());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
@ -233,15 +243,59 @@ public class TableDataPaneListPane extends JListControlPane implements TableData
@Override
public void update(Map<String, TableData> tableDataMap) {
List<TableDataBean> tableDataBeans = getUpdateTableDataBeans();
try {
WorkContext.getCurrent().get(TableDataOperator.class, new ExceptionHandler() {
@Override
public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) {
// 走老的方式
return saveByOldWay(tableDataBeans);
Nameable[] res = this.update();
Map<String, TableData> dataMap = new HashMap<>();
Arrays.stream(res).map(n -> (NameObject) n).forEach(no -> dataMap.put(no.getName(), (TableData) no.getObject()));
List<ServerDataSetBean> addDatas = new ArrayList<>();
List<ServerDataSetBean> updateDatas = new ArrayList<>();
List<ServerDataSetBean> deleteDatas = new ArrayList<>();
MapCompareUtils.contrastMapEntries(populatedTableDataSnapshot, dataMap, (entryEventKind, s, tabledata) -> {
try {
switch (entryEventKind) {
case REMOVED:
deleteDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata));
break;
case ADDED:
addDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata));
break;
case UPDATED:
updateDatas.add(DataSetProcessorFactory.getServerDataSetBean(s, tabledata));
break;
default:
break;
}
}).saveTableData(new ArrayList<>(tableDataMap.keySet()), tableDataBeans);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}, new MapCompareUtils.UpdateRule<String, TableData>() {
@Override
public boolean needUpdate(TableData origin, TableData tableData) {
return needUpdate0(origin, tableData);
}
/**
* 是否需要更新处理
*/
private boolean needUpdate0(TableData origin, TableData tableData) {
return !tableData.equals(origin);
}
});
submit(addDatas, updateDatas, deleteDatas);
}
private void submit(List<ServerDataSetBean> addDatas, List<ServerDataSetBean> updateDatas, List<ServerDataSetBean> deleteDatas){
try {
for (ServerDataSetBean bean : addDatas) {
TableDataRepository.getInstance().add(bean);
}
for (ServerDataSetBean bean : updateDatas) {
TableDataRepository.getInstance().update(bean);
}
for (ServerDataSetBean bean : deleteDatas) {
TableDataRepository.getInstance().delete(bean);
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

43
designer-realize/src/main/java/com/fanruan/boot/env/DesignCorePluginComponent.java vendored

@ -0,0 +1,43 @@
package com.fanruan.boot.env;
import com.fanruan.boot.CorePluginComponent;
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.carina.annotions.Supplemental;
import com.fanruan.plugin.autonomy.AutonomyClassManagerGroup;
import com.fanruan.plugin.autonomy.AutonomyClassManagerProvider;
import com.fr.plugin.ExtraClassManager;
/**
* DesignCorePluginComponent
*
* @author Destiny.Lin
* @since 11.0
* Created on 2024/8/9
*/
@FineComponent(name = "design_plugin_core")
@DependsOn(dependencies = {"design_plugin"})
public class DesignCorePluginComponent extends CorePluginComponent {
/**
* prepare
*/
@Supplemental
public void supportFunctionDef() {
super.supportFunctionDef();
}
/**
* start
*/
@Start
public void start() {
ExtraClassManager.getInstance().registerAutonomyClassManager(Carina.getApplicationContext().group(AutonomyClassManagerGroup.class).getAll().toArray(new AutonomyClassManagerProvider[0]));
/// 插件下沉不能直接调用fbp的逻辑,此时内置服务器未启动,一部分逻辑要拆到内置服务器启动的时候再做
//super.start();
}
}

2
designer-realize/src/main/java/com/fanruan/boot/env/function/DesignUpdateComponent.java vendored

@ -32,7 +32,7 @@ import java.util.List;
* Created on 2024/7/2
*/
@FineComponent(name = "design_function_update")
@DependsOn(dependencies = "design_plugin")
@DependsOn(dependencies = "design_plugin_core")
public class DesignUpdateComponent {
/**

Loading…
Cancel
Save