Browse Source

Pull request #11389: REPORT-89957 数据脱敏-本地规则无法保存

Merge in DESIGN/design from ~YVAN/design:final/11.0 to final/11.0

* commit '9eb4939bac4a6f276415158abcf53e8fd35f99c4':
  REPORT-89957 数据脱敏-本地规则无法保存 【问题原因】还是本地规则这边的问题,有好几个 1. 修改规则触发的updateRule方法,只传入了修改后的规则,修改前的规则未被移除 2. 规则无法保存,ResourceIOUtils.tryWrite接口在远程环境下有问题,会写到服务器上去 3. 所有规则展示的页面,因为之前改动性能,将规则缓存在了页面中,但是没有给刷新缓存的相关逻辑,实际上这个规则展示页面,是可以对本地规则做编辑等操作的,是需要刷新的 【改动思路】 1. updateRule做正确的更新逻辑,删除旧规则,添加新规则 2. ResourceIOUtils.tryWrite换成本地文件系统的IO方法 3. 每次打开所有规则展示的页面之前,刷新一下本地规则缓存 【review建议】
new-design
Yvan-欧阳帆 2 years ago
parent
commit
2c0766eacd
  1. 13
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java
  2. 10
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java

13
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java

@ -275,18 +275,25 @@ public class DesensitizationRuleChoosePane extends JPanel {
@Override
public void actionPerformed(ActionEvent e) {
// 获取当前选中规则
DesensitizationRule selectedValue = getSelectedValue();
// 获取当前选中规则的副本
DesensitizationRule selectedValue = null;
try {
selectedValue = (DesensitizationRule) getSelectedValue().clone();
} catch (CloneNotSupportedException ex) {
throw new RuntimeException(ex);
}
DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(selectedValue.getRuleName()));
editPane.populateBean(selectedValue);
final DesensitizationRule finalRule = selectedValue;
BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@Override
public void doOk() {
DesensitizationRule rule = editPane.updateBean();
// 修改同步到RuleManager中
if (DesensitizationRule.valid(rule)) {
DesensitizationRuleManager.getInstance().updateRule(rule);
DesensitizationRuleManager.getInstance().updateRule(finalRule, rule);
}
setSelectedValue(rule);
fireTableDataChanged();
}

10
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java

@ -250,6 +250,8 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
private ActionListener chooseRuleListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// 重新获取一下本地规则缓存
refreshCustomRuleCache();
DesensitizationRulePane rulePane = new DesensitizationRulePane(latestRules);
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
int selectedRow = table.getSelectedRow();
@ -606,4 +608,12 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
DesensitizationRuleManager.getInstance().getRuleStatus(rule, latestRules) != DesensitizationRuleStatus.NORMAL;
}
/**
* 刷新当前页面的本地规则缓存查询最新本地规则的逻辑也是使用了缓存因此无需考虑耗时
*/
private void refreshCustomRuleCache() {
Map<String, DesensitizationRule> customRules = DesensitizationRuleManager.getInstance().getRulesBySource(DesensitizationRuleSource.CUSTOM);
latestRules.put(DesensitizationRuleSource.CUSTOM, customRules);
}
}

Loading…
Cancel
Save