Browse Source

Pull request #11287: REPORT-89167 && REPORT-83493 平台脱敏规则变动时的交互问题

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

* commit '9baf1437ce3a9e21c50eb7fb47e68438e440dac4':
  REPORT-89167 && REPORT-83493 平台脱敏规则变动时的交互问题 【问题原因】与产品沟通修改成更容易理解的交互还有规则变动时的生效逻辑,大致如下: 1. 规则异常的提示放在数据集"数据脱敏设置"页面中,鼠标悬停"异常"文字时,出现气泡提示,气泡无法点击;"数据脱敏设置"页面中的规则表,表上增加刷新按钮,点击刷新后会刷新当前规则,刷新逻辑: 规则被禁用 ---- 原规则不变 规则被删除 ---- 原规则删除 规则被修改 ---- 原规则B被替换成B* 2. 假如模板中存在A、B平台规则,A规则正常,B规则被修改成了B*规则,此时不管是模板预览、数据集脱敏效果预览等计算相关的逻辑里,生效规则为A和B*。即计算场景里会自动替换被修改的规则 3. 上面的替换是临时替换,保存模板时并不会将B*写入模板xml中。仅在"数据脱敏设置"页面里,用户在点击"异常",弹窗提示出现后,再点击确定 + 保存模板时,才会修改模板xml文件 【改动方案】同上 【review建议】
newui
Yvan-欧阳帆 2 years ago
parent
commit
ec7d76bc4a
  1. 18
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java
  2. 67
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java
  3. 7
      designer-base/src/main/resources/com/fr/design/standard/refresh/refresh_normal.svg

18
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java

@ -2,10 +2,10 @@ package com.fr.design.data.datapane.preview.desensitization;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.desensitize.TableDataDesensitizeManager;
import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem; import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.manage.DesensitizationManager; import com.fr.data.desensitize.manage.DesensitizationManager;
import com.fr.data.desensitize.rule.DesensitizationRuleManager;
import com.fr.data.desensitize.util.DesentizationUtils; import com.fr.data.desensitize.util.DesentizationUtils;
import com.fr.decision.webservice.bean.user.DepartmentPostBean; import com.fr.decision.webservice.bean.user.DepartmentPostBean;
import com.fr.decision.webservice.bean.user.RoleBean; import com.fr.decision.webservice.bean.user.RoleBean;
@ -79,7 +79,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
Collection<TableDataDesensitizationItem> desensitizationItems = ((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems(); Collection<TableDataDesensitizationItem> desensitizationItems = ((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems();
if (DesentizationUtils.isCollectionNotEmpty(desensitizationItems)) { if (DesentizationUtils.isCollectionNotEmpty(desensitizationItems)) {
// 更新规则 // 更新规则
dealWithLastedRules(desensitizationItems); desensitizationItems = TableDataDesensitizeManager.getInstance().dealWithLastedRules(desensitizationItems);
// 对脱敏配置项集合做过滤和排序处理 // 对脱敏配置项集合做过滤和排序处理
List<TableDataDesensitizationItem> items = desensitizationItems.stream() List<TableDataDesensitizationItem> items = desensitizationItems.stream()
.filter(item -> isAvaliableItem4Preview(item, model)) .filter(item -> isAvaliableItem4Preview(item, model))
@ -106,16 +106,6 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
matchColumnIndex(item, model) >= 0; matchColumnIndex(item, model) >= 0;
} }
/**
* 在预览计算前将Item中的规则替换为最新规则防止平台规则被临时修改
*/
private void dealWithLastedRules(Collection<TableDataDesensitizationItem> desensitizationItems) {
desensitizationItems.forEach(item -> {
// 获取最新的规则
item.setRule(DesensitizationRuleManager.getInstance().getLastedDesentizationRule(item.getRule()));
});
}
/** /**
* 通过TableData获取其列名 * 通过TableData获取其列名
* *
@ -185,7 +175,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
* @param positionName * @param positionName
* @return * @return
*/ */
public String mergeRoleText(String departmentName, String positionName) { private String mergeRoleText(String departmentName, String positionName) {
return departmentName + positionName; return departmentName + positionName;
} }
@ -196,7 +186,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
* @param positionId * @param positionId
* @return * @return
*/ */
public String mergeRoleId(String departmentId, String positionId) { private String mergeRoleId(String departmentId, String positionId) {
return departmentId + CONNECTOR + positionId; return departmentId + CONNECTOR + positionId;
} }

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

@ -40,6 +40,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -132,9 +133,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
return matchRoleNamesByIds(desensitizationItem.getRoleIds()); return matchRoleNamesByIds(desensitizationItem.getRoleIds());
case DesensitizationRuleStatus: case DesensitizationRuleStatus:
// 规则状态 // 规则状态
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(desensitizationItem.getRule()); return needMarkRule(desensitizationItem.getRule()) ? StringUtils.EMPTY : Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status_Abnormal");
// 非正常状态需要标记为异常
return ruleStatus == DesensitizationRuleStatus.NORMAL ? StringUtils.EMPTY : Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status_Abnormal");
default: default:
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
@ -165,7 +164,11 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override @Override
public UITableEditAction[] createAction() { public UITableEditAction[] createAction() {
return new UITableEditAction[]{new AddDesensitizationAction(), new RemoveDesensitizationAction(parent)}; return new UITableEditAction[]{
new AddDesensitizationAction(),
new RemoveDesensitizationAction(parent),
new RefreshTableAction(),
};
} }
/** /**
@ -428,14 +431,16 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
* @param currentItem * @param currentItem
*/ */
public void refreshRuleStatus(TableDataDesensitizationItem currentItem) { public void refreshRuleStatus(TableDataDesensitizationItem currentItem) {
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(currentItem.getRule()); DesensitizationRule rule = currentItem.getRule();
if (ruleStatus == DesensitizationRuleStatus.NORMAL) { if (needMarkRule(rule)) {
// 正常规则时,重置提示Label // 非正常规则,根据规则状态展示不同提示文字
this.ruleStatusLabel.setText(StringUtils.EMPTY); DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(rule);
this.ruleStatusLabel.setToolTipText(null);
} else {
this.ruleStatusLabel.setText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status_Abnormal")); this.ruleStatusLabel.setText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status_Abnormal"));
this.ruleStatusLabel.setToolTipText(ruleStatus.getDescription()); this.ruleStatusLabel.setToolTipText(ruleStatus.getDescription());
} else {
// 正常规则,重置提示Label
this.ruleStatusLabel.setText(StringUtils.EMPTY);
this.ruleStatusLabel.setToolTipText(null);
} }
} }
@ -518,6 +523,36 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
} }
} }
private class RefreshTableAction extends UITableEditAction {
public RefreshTableAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh"));
this.setSmallIcon("/com/fr/design/standard/refresh/refresh", false);
}
@Override
public void actionPerformed(ActionEvent e) {
// 刷新TableData的规则,主要是为了自动替换掉平台中被修改的规则
List<TableDataDesensitizationItem> items = getList();
Iterator<TableDataDesensitizationItem> iterator = items.iterator();
while (iterator.hasNext()) {
TableDataDesensitizationItem item = iterator.next();
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(item.getRule());
if (ruleStatus == DesensitizationRuleStatus.REMOVED) {
// 规则被移除,则删除整条脱敏Item
iterator.remove();
} else {
// 规则被修改、禁用等,更新一下规则
item.setRule(DesensitizationRuleManager.getInstance().getLastedDesentizationRule(item.getRule()));
}
}
fireTableDataChanged();
}
@Override
public void checkEnabled() {}
}
/** /**
* 规则表-列字段编号 * 规则表-列字段编号
*/ */
@ -580,4 +615,16 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
} }
} }
/**
* 是否需要对异常规则做标记需要满足
* 1. 规则非默认空规则
* 2. 规则本身异常
*
* @return
*/
private boolean needMarkRule(DesensitizationRule rule) {
return !rule.equals(DesensitizationRule.createDefaultEmptyRule()) &&
DesensitizationRuleManager.getInstance().getRuleStatus(rule) != DesensitizationRuleStatus.NORMAL;
}
} }

7
designer-base/src/main/resources/com/fr/design/standard/refresh/refresh_normal.svg

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_刷新_normal</title>
<g id="icon_刷新_normal" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M13.0593807,1 C13.4802225,1 13.8213822,1.34115968 13.8213822,1.76200147 L13.8213822,1.76200147 L13.8213822,5.2534957 C13.8213822,5.67433749 13.4802225,6.01549717 13.0593807,6.01549717 L13.0593807,6.01549717 L9.56788646,6.01549717 C9.14704467,6.01549717 8.80588499,5.67433749 8.80588499,5.2534957 C8.80588499,4.83265391 9.14704467,4.49149423 9.56788646,4.49149423 L9.56788646,4.49149423 L11.169634,4.48959417 C10.8434607,4.27112237 10.4895308,4.09123525 10.1125367,3.95402064 C7.56533579,3.02691531 4.74885407,4.34026231 3.82174874,6.88746326 C2.89464341,9.43466421 4.20799041,12.2511459 6.75519136,13.1782513 C9.30239231,14.1053566 12.118874,12.7920096 13.0459794,10.2448086 C13.1899157,9.84934672 13.6271844,9.64544497 14.0226464,9.78938133 C14.4181083,9.9333177 14.62201,10.3705864 14.4780737,10.7660483 C13.2630956,14.1041731 9.57207646,15.8253236 6.23395166,14.6103456 C2.89582685,13.3953675 1.17467636,9.70434836 2.38965442,6.36622356 C3.60463249,3.02809876 7.29565164,1.30694826 10.6337764,2.52192632 C11.3047108,2.76612647 11.9217951,3.11486447 12.467588,3.55405023 L12.297,3.423 L12.2973792,1.76200147 C12.2973792,1.37622983 12.5840481,1.05741329 12.9559816,1.00695618 Z" id="Combined-Shape" fill="#333334" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

Loading…
Cancel
Save