Browse Source

REPORT-80693 - 数据脱敏二期(报表)

【问题原因】rt
【改动思路】详见https://kms.fineres.com/pages/viewpage.action?pageId=550539157
【review建议】文档忘记提交评审了,review的时候帮忙打个分,感谢
feature/x
Yvan-欧阳帆 2 years ago
parent
commit
b08e6be68d
  1. 13
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java
  2. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  3. 49
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java
  4. 26
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java
  5. 3
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java
  6. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java
  7. 10
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java
  8. 12
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java
  9. 89
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java
  10. 8
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java

13
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java

@ -116,6 +116,19 @@ public class PreviewTableModel extends AbstractTableModel {
}
}
/**
* 根据列名获取列序号当返回-1时代表异常异常会被忽略不打印日志或给出前台提示
* @param columnName
* @return
*/
public int getColumnIndexWithExceptionIngore(String columnName) {
try {
return dataModel.getColumnIndex(columnName);
} catch (TableDataException ingore) {
return -1;
}
}
public int getRowCount() {
try {
return this.dataModel.getRowCount();

2
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -776,6 +776,6 @@ public class PreviewTablePane extends BasicPane {
*/
private boolean isDesensitizeOpened() {
return tableData instanceof DesensitizationTableData &&
((DesensitizationTableData) tableData).isDesensitizeOpen();
((DesensitizationTableData) tableData).getDesensitizationConfig().isDesensitizeOpened();
}
}

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

@ -3,7 +3,7 @@ package com.fr.design.data.datapane.preview.desensitization;
import com.fr.base.TableData;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationBean;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.manage.DesensitizationManager;
import com.fr.data.desensitize.util.DesentizationUtils;
import com.fr.decision.webservice.bean.user.DepartmentPostBean;
@ -14,12 +14,10 @@ import com.fr.decision.webservice.v10.user.PositionService;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTableModel;
import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashMap;
@ -57,14 +55,14 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
/**
* 判断数据集预览时是否需要脱敏这里不需要判断roleIds因为默认有权限编辑的人一定有权限看脱敏前后字段值
* 只需要保证此数据集存在脱敏配置就行
*
* @param tableData
* @return
*/
public boolean needDesensitize(TableData tableData) {
return tableData instanceof DesensitizationTableData &&
DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationBeans()) &&
((DesensitizationTableData) tableData).getDesensitizationBeans().stream().noneMatch(TableDataDesensitizationBean::invalid);
DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems());
}
/**
@ -75,25 +73,23 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
*/
public PreviewTableModel desensitizeTableModel(TableData tableData, PreviewTableModel model) {
Map<Integer, TableDataDesensitizationBean> desensitizationBeanMap = new LinkedHashMap<>();
Map<Integer, TableDataDesensitizationItem> desensitizationItemMap = new LinkedHashMap<>();
// 获取此数据集的所有脱敏信息
Collection<TableDataDesensitizationBean> desensitizationBeans = ((DesensitizationTableData) tableData).getDesensitizationBeans();
// 去除被禁用的规则 + 排序
List<TableDataDesensitizationBean> sortedBeans = desensitizationBeans
.stream()
.filter(bean -> bean.getDesensitizationRule().isEnable())
.sorted(Comparator.comparingInt(TableDataDesensitizationBean::getColumnIndex))
Collection<TableDataDesensitizationItem> desensitizationItems = ((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems();
if (DesentizationUtils.isCollectionNotEmpty(desensitizationItems)) {
// 先对脱敏配置项集合做过滤和排序处理
List<TableDataDesensitizationItem> items = desensitizationItems.stream()
.filter(item -> item.getRule().isEnable() &&
matchColumnIndex(item, model) >= 0)
.sorted(Comparator.comparingInt(item -> matchColumnIndex(item, model)))
.collect(Collectors.toList());
int columnIndex = 0;
for (TableDataDesensitizationBean sortedBean : sortedBeans) {
// 当map中已包含列序号时,代表对这一列设置了不同的脱敏规则,将key + 1
if (desensitizationBeanMap.containsKey(columnIndex)) {
columnIndex++;
// 然后转换成Map
for (int i = 0; i < items.size(); i++) {
desensitizationItemMap.put(i, items.get(i));
}
desensitizationBeanMap.put(columnIndex, sortedBean);
}
// 包装TableModel
return new DesensitizedPreviewTableModel(model, desensitizationBeanMap);
return new DesensitizedPreviewTableModel(model, desensitizationItemMap);
}
/**
@ -104,16 +100,7 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
* @return
*/
public List<String> getColumnNamesByTableData(TableData tableData) {
List<Map<String, TableDataWrapper>> editingDataSet = DesignTableDataManager.getEditingDataSet(DesignTableDataManager.getEditingTableDataSource());
// 当前所有模板数据集Wrapper,不包括存储过程
Map<String, TableDataWrapper> templeteDataMap = editingDataSet.get(0);
// 当前所有模板数据集Wrapper,包括存储过程
Map<String, TableDataWrapper> dataWrapperMap = DesignTableDataManager.getAllDataSetIncludingProcedure(templeteDataMap);
// 找到匹配当前数据集名称的Wrapper
TableDataWrapper tableDataWrapper = dataWrapperMap.get(tableData.getName());
return tableDataWrapper == null ?
new ArrayList<>() :
tableDataWrapper.calculateColumnNameList();
return DesignTableDataManager.getColumnNamesByTableData(tableData);
}
/**
@ -189,4 +176,8 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
public String mergeRoleId(String departmentId, String positionId) {
return departmentId + CONNECTOR + positionId;
}
public int matchColumnIndex(TableDataDesensitizationItem desensitizationItem, PreviewTableModel previewModel) {
return previewModel.getColumnIndexWithExceptionIngore(desensitizationItem.getColumnName());
}
}

26
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java

@ -1,10 +1,11 @@
package com.fr.design.data.datapane.preview.desensitization.model;
import com.fr.data.desensitize.base.TableDataDesensitizationBean;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.calculate.DesensitizationCalculator;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.design.data.datapane.preview.PreviewTableModel;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
import java.util.Map;
import java.util.Objects;
@ -26,20 +27,20 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel {
/**
* 脱敏后新组装的TableModel中列序号 - 脱敏信息 对应的Map
*/
private Map<Integer, TableDataDesensitizationBean> desensitizationBeanMap;
private Map<Integer, TableDataDesensitizationItem> desensitizationItemMap;
private boolean needDesensitize = false;
public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map<Integer, TableDataDesensitizationBean> desensitizationBeanMap) {
public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map<Integer, TableDataDesensitizationItem> desensitizationItemMap) {
this.previewTableModel = previewTableModel;
this.desensitizationBeanMap = desensitizationBeanMap;
this.desensitizationItemMap = desensitizationItemMap;
}
@Override
public String getColumnName(int column) {
int originIndex = needDesensitize && Objects.nonNull(desensitizationBeanMap.get(column)) ?
desensitizationBeanMap.get(column).getColumnIndex() : column;
return previewTableModel.getColumnName(originIndex);
return needDesensitize ?
desensitizationItemMap.get(column).getColumnName() :
previewTableModel.getColumnName(column);
}
@Override
@ -56,7 +57,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel {
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return needDesensitize && Objects.nonNull(desensitizationBeanMap.get(columnIndex)) ?
return needDesensitize && Objects.nonNull(desensitizationItemMap.get(columnIndex)) ?
getDesensitizedValue(rowIndex, columnIndex) :
previewTableModel.getValueAt(rowIndex, columnIndex);
}
@ -70,7 +71,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel {
*/
private Object getDesensitizedValue(int rowIndex, int columnIndex) {
// 先通过columnIndex找到对应原TableModel的列序号
int originColumnIndex = desensitizationBeanMap.get(columnIndex).getColumnIndex();
int originColumnIndex = TableDataPreviewDesensitizeManager.getInstance().matchColumnIndex(desensitizationItemMap.get(columnIndex), previewTableModel);
// 获取原值
Object value = previewTableModel.getValueAt(rowIndex, originColumnIndex);
// 判空
@ -91,9 +92,8 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel {
* @return
*/
private String desensitizeValue(String strValue, int columnIndex) {
TableDataDesensitizationBean desensitizationBean = desensitizationBeanMap.get(columnIndex);
DesensitizationRule desensitizationRule = desensitizationBean.getDesensitizationRule();
return DesensitizationCalculator.getInstance().desensitize(strValue, desensitizationRule);
DesensitizationRule rule = desensitizationItemMap.get(columnIndex).getRule();
return DesensitizationCalculator.getInstance().desensitize(strValue, rule);
}
/**
@ -102,7 +102,7 @@ public class DesensitizedPreviewTableModel extends PreviewTableModel {
* @return
*/
public int getDesensitizeColumnsCount() {
return desensitizationBeanMap.size();
return desensitizationItemMap.size();
}
/**

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

@ -305,6 +305,9 @@ public class DesensitizationRuleChoosePane extends JPanel {
public void actionPerformed(ActionEvent e) {
// 获取当前选中规则
DesensitizationRule selectedRule = getSelectedValue();
if (selectedRule == null) {
return;
}
DesensitizationRuleDebugPane ruleDebugPane = new DesensitizationRuleDebugPane(selectedRule);
BasicDialog ruleDebugDialog = ruleDebugPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), null, BasicDialog.DEFAULT);
ruleDebugDialog.setVisible(true);

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

@ -52,7 +52,7 @@ public class DesensitizationRuleDebugPane extends BasicPane {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0));
UILabel desensitizationRule = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm"));
UILabel characterReplace = new UILabel(rule.getRuleType().getTypeName());
UILabel characterReplace = new UILabel(rule.getRuleType().getRuleTypeName());
UILabel description = new UILabel(DesensitizationRule.getDescription(rule));
JComponent[][] components = new JComponent[][]{
{desensitizationRule, characterReplace},

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

@ -185,8 +185,8 @@ public class DesensitizationRuleEditPane extends BasicBeanPane<DesensitizationRu
characterAllReplacePane.add(allReplaceLabel);
characterAllReplacePane.add(secondSymbolTextField);
ruleConditionPane.add(characterReplacePane, DesensitizationRuleType.CHARACTER_REPLACE.getTypeName());
ruleConditionPane.add(characterAllReplacePane, DesensitizationRuleType.ALL_CHARACTERS_REPLACE.getTypeName());
ruleConditionPane.add(characterReplacePane, DesensitizationRuleType.CHARACTER_REPLACE.getRuleTypeName());
ruleConditionPane.add(characterAllReplacePane, DesensitizationRuleType.ALL_CHARACTERS_REPLACE.getRuleTypeName());
// 初始化状态为字符替换
switchRuleConditionPane(DesensitizationRuleType.CHARACTER_REPLACE);
@ -200,14 +200,14 @@ public class DesensitizationRuleEditPane extends BasicBeanPane<DesensitizationRu
* @param ruleType
*/
private void switchRuleConditionPane(DesensitizationRuleType ruleType) {
this.cardLayout.show(ruleConditionPane, ruleType.getTypeName());
this.cardLayout.show(ruleConditionPane, ruleType.getRuleTypeName());
}
/**
* 初始化规则类型下拉框
*/
private void initRuleTypeComboBox() {
ruleTypeComboBox = new UIComboBox(Arrays.stream(DesensitizationRuleType.values()).map(DesensitizationRuleType::getTypeName).toArray());
ruleTypeComboBox = new UIComboBox(Arrays.stream(DesensitizationRuleType.values()).map(DesensitizationRuleType::getRuleTypeName).toArray());
ruleTypeComboBox.setSelectedIndex(0);
ruleTypeComboBox.registerChangeListener(new UIObserverListener() {
@Override
@ -253,7 +253,7 @@ public class DesensitizationRuleEditPane extends BasicBeanPane<DesensitizationRu
public void populateBean(DesensitizationRule ob) {
this.rule = ob;
this.ruleNameTextField.setText(rule.getRuleName());
String typeName = rule.getRuleType().getTypeName();
String typeName = rule.getRuleType().getRuleTypeName();
this.ruleTypeComboBox.setSelectedItem(typeName);
switch (DesensitizationRuleType.matchByTypeName(typeName)) {
case CHARACTER_REPLACE:

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

@ -1,7 +1,7 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationBean;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.datapane.preview.desensitization.view.common.DesensitizationOpenPane;
import com.fr.design.i18n.Toolkit;
@ -69,7 +69,7 @@ public class TableDataDesensitizationSettingPane extends BasicBeanPane<Desensiti
@Override
public void populateBean(DesensitizationTableData tableData) {
this.tableData = tableData;
this.desensitizationOpenPane.setDesensitizationOpened(tableData.isDesensitizeOpen());
this.desensitizationOpenPane.setDesensitizationOpened(tableData.getDesensitizationConfig().isDesensitizeOpened());
tableDataDesensitizationTablePane.populateDesensitizationSetting(tableData);
}
@ -84,15 +84,15 @@ public class TableDataDesensitizationSettingPane extends BasicBeanPane<Desensiti
* 保存脱敏启用状态
*/
public void saveDesensitizeOpened() {
tableData.setDesensitizeOpen(this.desensitizationOpenPane.isDesensitizationOpened());
tableData.getDesensitizationConfig().setDesensitizeOpened(this.desensitizationOpenPane.isDesensitizationOpened());
}
/**
* 保存脱敏规则配置信息
*
* @param tableDataDesensitizationBeans
* @param desensitizationItems
*/
public void saveDesensitizationBeans(List<TableDataDesensitizationBean> tableDataDesensitizationBeans) {
tableData.setDesensitizationBeans(tableDataDesensitizationBeans);
public void saveDesensitizationBeans(List<TableDataDesensitizationItem> desensitizationItems) {
tableData.getDesensitizationConfig().setDesensitizationItems(desensitizationItems);
}
}

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

@ -1,7 +1,7 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationBean;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane;
@ -18,7 +18,6 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.CollectionUtils;
import org.jetbrains.annotations.Nullable;
import javax.swing.AbstractCellEditor;
@ -33,6 +32,7 @@ import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
@ -48,7 +48,7 @@ import java.util.Set;
* @version 11.0
* Created by Yvan on 2022/9/23
*/
public class TableDataDesensitizationTableModel extends UITableModelAdapter<TableDataDesensitizationBean> {
public class TableDataDesensitizationTableModel extends UITableModelAdapter<TableDataDesensitizationItem> {
private static final String APOSTROPHE = "...";
@ -106,59 +106,32 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
TableDataDesensitizationBean desensitizationBean = this.getList().get(rowIndex);
TableDataDesensitizationItem desensitizationItem = this.getList().get(rowIndex);
switch (columnIndex) {
case 0:
// 选中的数据集字段名称
return getColumnNameValue(desensitizationBean);
return desensitizationItem.getColumnName();
case 1:
// 脱敏规则名称
return desensitizationBean.getDesensitizationRule().getRuleName();
return desensitizationItem.getRule().getRuleName();
case 2:
// 脱敏规则详情
return DesensitizationRule.getDescription(desensitizationBean.getDesensitizationRule());
return DesensitizationRule.getDescription(desensitizationItem.getRule());
case 3:
// 生效用户组
return matchRoleNamesByIds(desensitizationBean.getRoleIds());
return matchRoleNamesByIds(desensitizationItem.getRoleIds());
default:
return StringUtils.EMPTY;
}
}
/**
* 根据当前选中的Bean获取其对应的列名字段
*
* @param desensitizationBean
* @return
*/
private Object getColumnNameValue(TableDataDesensitizationBean desensitizationBean) {
// 内部列名list为空时直接返回空字符串
if (CollectionUtils.isEmpty(columnNames)) {
return StringUtils.EMPTY;
}
// bean的列字段index不对劲时,返回空字符串
return validColumnIndex(desensitizationBean.getColumnIndex()) ?
columnNames.get(desensitizationBean.getColumnIndex()) :
StringUtils.EMPTY;
}
/**
* 判断字段索引是否越界
*
* @param columnIndex
* @return
*/
private boolean validColumnIndex(int columnIndex) {
return columnIndex >= 0 && columnIndex < columnNames.size();
}
/**
* 通过id匹配此用户组对应的部门职位名称或者说自定义角色名称
*
* @param roleIds
* @return
*/
private List<String> matchRoleNamesByIds(Set<String> roleIds) {
private List<String> matchRoleNamesByIds(Collection<String> roleIds) {
List<String> result = new ArrayList<>();
for (String roleId : roleIds) {
if (roleMap != null && roleMap.containsKey(roleId)) {
@ -184,7 +157,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
* @return
*/
@Nullable
private TableDataDesensitizationBean getCurrentSelectBean() {
private TableDataDesensitizationItem getCurrentSelectBean() {
return table.getSelectedRow() == -1 ?
null :
getList().get(table.getSelectedRow());
@ -203,9 +176,9 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean();
if (Objects.nonNull(desensitizationBean)) {
desensitizationBean.setColumnIndex(columnNameComboBox.getSelectedIndex());
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem)) {
desensitizationItem.setColumnName(columnNames.get(columnNameComboBox.getSelectedIndex()));
fireTableDataChanged();
}
}
@ -220,7 +193,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
columnNameComboBox.setSelectedIndex(getList().get(row).getColumnIndex());
columnNameComboBox.setSelectedItem(getList().get(row).getColumnName());
return columnNameComboBox;
}
@ -232,7 +205,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
columnNameComboBox.setSelectedIndex(getList().get(row).getColumnIndex());
columnNameComboBox.setSelectedItem(getList().get(row).getColumnName());
return columnNameComboBox;
}
}
@ -263,9 +236,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public void doOk() {
rule = rulePane.updateBean();
TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean();
if (Objects.nonNull(desensitizationBean) && Objects.nonNull(rule)) {
desensitizationBean.setDesensitizationRule(rule);
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem) && Objects.nonNull(rule)) {
desensitizationItem.setRule(rule);
desensitizationItem.setRuleName(rule.getRuleName());
fireTableDataChanged();
}
rule = null;
@ -296,9 +270,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean();
if (Objects.nonNull(desensitizationBean) && Objects.nonNull(rule)) {
desensitizationBean.setDesensitizationRule(rule);
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem) && Objects.nonNull(rule)) {
desensitizationItem.setRule(rule);
desensitizationItem.setRuleName(rule.getRuleName());
fireTableDataChanged();
}
}
@ -307,7 +282,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
ruleNameTextField.setText(getList().get(row).getDesensitizationRule().getRuleName());
ruleNameTextField.setText(getList().get(row).getRule().getRuleName());
return choosePane;
}
@ -343,7 +318,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
refreshDescription(getList().get(row).getDesensitizationRule());
refreshDescription(getList().get(row).getRule());
return descriptionLabel;
}
@ -362,9 +337,9 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationBean desensitizationBean = getCurrentSelectBean();
if (Objects.nonNull(desensitizationBean)) {
desensitizationBean.setRoleIds(generateRolesIdsBySelectedValues());
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem)) {
desensitizationItem.setRoleIds(generateRolesIdsBySelectedValues());
fireTableDataChanged();
}
}
@ -385,15 +360,15 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
/**
* 根据当前的规则配置信息生成选中的rolesMap用来展示
*
* @param desensitizationBean
* @param desensitizationItem
* @return
*/
private Map<Object, Boolean> generateRolesCheckBoxSelectedValues(TableDataDesensitizationBean desensitizationBean) {
private Map<Object, Boolean> generateRolesCheckBoxSelectedValues(TableDataDesensitizationItem desensitizationItem) {
Map<Object, Boolean> result = new HashMap<>(roleMap.size());
for (Map.Entry<String, String> roleEntry : roleMap.entrySet()) {
String roleId = roleEntry.getKey();
String roleName = roleEntry.getValue();
if (desensitizationBean.getRoleIds().contains(roleId)) {
if (desensitizationItem.getRoleIds().contains(roleId)) {
result.put(roleName, true);
} else {
result.put(roleName, false);
@ -444,7 +419,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
// 添加一条空白数据
addRow(TableDataDesensitizationBean.createEmyptBean());
addRow(TableDataDesensitizationItem.createDefault());
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1);
}

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

@ -1,7 +1,7 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationBean;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.layout.FRGUIPaneFactory;
@ -32,7 +32,7 @@ public class TableDataDesensitizationTablePane extends JPanel {
/**
* 脱敏信息Table
*/
private UITableEditorPane<TableDataDesensitizationBean> editorPane;
private UITableEditorPane<TableDataDesensitizationItem> editorPane;
public TableDataDesensitizationTablePane(DesensitizationTableData tableData, Component parent) {
this.tableData = tableData;
@ -54,13 +54,13 @@ public class TableDataDesensitizationTablePane extends JPanel {
*/
public void populateDesensitizationSetting(DesensitizationTableData tableData) {
this.tableData = tableData;
editorPane.populate(tableData.getDesensitizationBeans().toArray(new TableDataDesensitizationBean[0]));
editorPane.populate(tableData.getDesensitizationConfig().getDesensitizationItems().toArray(new TableDataDesensitizationItem[0]));
}
/**
* 获取当前对TableData的配置脱敏规则信息
*/
public List<TableDataDesensitizationBean> updateDesensitizationSetting() {
public List<TableDataDesensitizationItem> updateDesensitizationSetting() {
return editorPane.update();
}
}

Loading…
Cancel
Save