Browse Source
Merge in DESIGN/design from ~RINOUX/design:feature/x to feature/x * commit '341c48d84f0cf898820824740c3b9630d779cac8': KERNEL-7160 服务器数据集支持research/11.0
ju|剧浩宇
4 years ago
9 changed files with 327 additions and 192 deletions
@ -0,0 +1,47 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane.db; |
||||
|
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.esd.event.DSMapping; |
||||
import com.fr.esd.event.DsNameTarget; |
||||
import com.fr.esd.event.StrategyEventsNotifier; |
||||
import com.fr.esd.event.xml.XMLSavedHook; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
public class DBTableDataSavedHook implements XMLSavedHook<DBTableData> { |
||||
|
||||
private static final long serialVersionUID = 4925391747683335372L; |
||||
|
||||
private final String tplPath; |
||||
private String origName; |
||||
|
||||
private String origConnection; |
||||
|
||||
private String origQuery; |
||||
|
||||
public DBTableDataSavedHook(String tplPath, DBTableData origDBTableData) { |
||||
this.tplPath = tplPath; |
||||
this.origName = origDBTableData.getDsName(); |
||||
this.origConnection = origDBTableData.getDatabase().toString(); |
||||
this.origQuery = origDBTableData.getQuery(); |
||||
} |
||||
|
||||
@Override |
||||
public void doAfterSaved(DBTableData saved) { |
||||
String dsName = saved.getDsName(); |
||||
String conn = saved.getDatabase().toString(); |
||||
String query = saved.getQuery(); |
||||
|
||||
|
||||
//检查数据集名称、数据链接和sql是否修改,如果修改需要触发缓存监听事件
|
||||
if (!dsName.equals(origName) || !conn.equals(origConnection) || !query.equals(origQuery)) { |
||||
if (StringUtils.isNotEmpty(tplPath) && StringUtils.isNotEmpty(origName)) { |
||||
//新建数据集的origName为null,不用触发
|
||||
StrategyEventsNotifier.modifyDataSet(new DSMapping(tplPath, new DsNameTarget(origName))); |
||||
} |
||||
} |
||||
|
||||
this.origName = dsName; |
||||
this.origConnection = conn; |
||||
this.origQuery = query; |
||||
} |
||||
} |
@ -0,0 +1,70 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane.db; |
||||
|
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
||||
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.stable.StringUtils; |
||||
|
||||
/** |
||||
* @author rinoux |
||||
* @version 10.0 |
||||
* Created by rinoux on 2021/3/19 |
||||
*/ |
||||
public class ServerStrategyConfigHandler implements StrategyConfigHandler { |
||||
private final DBTableData tableData; |
||||
|
||||
private final String origName; |
||||
|
||||
private final String origConnection; |
||||
|
||||
private final String origQuery; |
||||
|
||||
public ServerStrategyConfigHandler(DBTableData tableData) { |
||||
this.tableData = tableData; |
||||
this.origName = tableData.getDsName(); |
||||
this.origConnection = tableData.getDatabase().toString(); |
||||
this.origQuery = tableData.getQuery(); |
||||
} |
||||
|
||||
@Override |
||||
public StrategyConfig find() { |
||||
StrategyConfig strategyConfig = null; |
||||
if (tableData != null) { |
||||
try { |
||||
strategyConfig = tableData.getStrategyConfig() == null ? null : tableData.getStrategyConfig().clone(); |
||||
} catch (CloneNotSupportedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
return strategyConfig; |
||||
} |
||||
|
||||
@Override |
||||
public void save(DBTableData saved, StrategyConfig strategyConfig) { |
||||
String conn = saved.getDatabase().toString(); |
||||
String query = saved.getQuery(); |
||||
|
||||
|
||||
//检查数据链接和sql是否修改,如果修改需要触发缓存监听事件
|
||||
if (!conn.equals(origConnection) || !query.equals(origQuery)) { |
||||
if (StringUtils.isNotEmpty(origName)) { |
||||
//新建数据集的origName为null,不用触发
|
||||
StrategyEventsNotifier.modifyDataSet(DSMapping.ofServerDS(new DsNameTarget(origName))); |
||||
} |
||||
} |
||||
|
||||
|
||||
//配置变动事件
|
||||
try { |
||||
final StrategyConfig orig = tableData.getStrategyConfig(); |
||||
saved.setStrategyConfig(strategyConfig.clone()); |
||||
StrategyEventsNotifier.compareAndFireConfigEvents(orig, strategyConfig, DSMapping.ofServerDS(new DsNameTarget(saved.getDsName()))); |
||||
} catch (CloneNotSupportedException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane.db; |
||||
|
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
public enum StrategyConfigFrom { |
||||
GLOBAL(0, Toolkit.i18nText("Fine-Design_ESD_Use_Global_Settings")), |
||||
|
||||
INDIVIDUAL(1, Toolkit.i18nText("Fine-Design_ESD_Use_Individual_Settings")); |
||||
|
||||
int index; |
||||
|
||||
String displayText; |
||||
|
||||
StrategyConfigFrom(int index, String displayText) { |
||||
this.index = index; |
||||
this.displayText = displayText; |
||||
} |
||||
|
||||
|
||||
public int getIndex() { |
||||
return this.index; |
||||
} |
||||
|
||||
|
||||
public String getDisplayText() { |
||||
return this.displayText; |
||||
} |
||||
|
||||
|
||||
public String toString() { |
||||
return getDisplayText(); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane.db; |
||||
|
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
||||
|
||||
/** |
||||
* @author rinoux |
||||
* @version 10.0 |
||||
* Created by rinoux on 2021/3/19 |
||||
*/ |
||||
public interface StrategyConfigHandler { |
||||
|
||||
StrategyConfig find(); |
||||
|
||||
void save(DBTableData saved, StrategyConfig config); |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.data.tabledata.tabledatapane.db; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.data.impl.DBTableData; |
||||
import com.fr.design.data.DesignerStrategyConfigUtils; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.esd.core.strategy.config.StrategyConfig; |
||||
import com.fr.esd.query.StrategicTableData; |
||||
import com.fr.workspace.WorkContext; |
||||
|
||||
/** |
||||
* @author rinoux |
||||
* @version 10.0 |
||||
* Created by rinoux on 2021/3/19 |
||||
*/ |
||||
public class TemplateStrategyConfigHandler implements StrategyConfigHandler { |
||||
|
||||
DBTableData tableData; |
||||
|
||||
public TemplateStrategyConfigHandler(DBTableData tableData) { |
||||
this.tableData = tableData; |
||||
} |
||||
|
||||
@Override |
||||
public StrategyConfig find() { |
||||
StrategyConfig strategyConfig = null; |
||||
if (tableData != null) { |
||||
//设置保存数据集的事件检查钩子
|
||||
String tplPath = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getEditingFILE().getPath(); |
||||
|
||||
//新建模版此时不存在,不需要注册钩子
|
||||
if (tableData.getXmlSavedHook() == null && WorkContext.getWorkResource().exist(tplPath)) { |
||||
tableData.setXmlSavedHook(new DBTableDataSavedHook(tplPath, tableData)); |
||||
} |
||||
|
||||
//获取当前的缓存配置,没有就创建一份
|
||||
String dsName = tableData.getDsName(); |
||||
|
||||
//这里为了之前兼容插件创建的配置,缓存配置不在DBTableData,而是从模版attr读取
|
||||
strategyConfig = DesignerStrategyConfigUtils.getStrategyConfig(dsName); |
||||
} |
||||
|
||||
return strategyConfig; |
||||
} |
||||
|
||||
@Override |
||||
public void save(DBTableData saved, StrategyConfig config) { |
||||
|
||||
} |
||||
} |
Loading…
Reference in new issue