|
|
@ -9,7 +9,6 @@ import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesen |
|
|
|
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; |
|
|
|
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
|
|
|
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
|
|
@ -21,6 +20,7 @@ import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
|
@ -29,6 +29,7 @@ import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
import javax.swing.event.CellEditorListener; |
|
|
|
import javax.swing.event.CellEditorListener; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
@ -38,8 +39,11 @@ import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
@ -60,17 +64,15 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
|
|
|
|
|
|
|
|
private static final String COMMA = ","; |
|
|
|
private static final String COMMA = ","; |
|
|
|
|
|
|
|
|
|
|
|
private DesensitizationTableData tableData; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当前数据集的所有列名 |
|
|
|
* 当前数据集的所有列名 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> columnNames; |
|
|
|
private List<String> columnNames = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* key为用户组唯一标识(id拼接),value为用户组名称 |
|
|
|
* key为用户组唯一标识(id拼接),value为用户组名称 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<String, String> roleMap; |
|
|
|
private final Map<String, String> roleMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Component parent; |
|
|
|
private Component parent; |
|
|
|
|
|
|
|
|
|
|
@ -83,12 +85,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status"), |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 一些数据相关
|
|
|
|
|
|
|
|
this.tableData = tableData; |
|
|
|
|
|
|
|
// 获取当前数据集的所有列名
|
|
|
|
|
|
|
|
this.columnNames = TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData); |
|
|
|
|
|
|
|
// 获取当前所有用户组
|
|
|
|
|
|
|
|
this.roleMap = TableDataPreviewDesensitizeManager.getInstance().getAllRoles(); |
|
|
|
|
|
|
|
this.parent = parent; |
|
|
|
this.parent = parent; |
|
|
|
this.setColumnClass(new Class[]{ |
|
|
|
this.setColumnClass(new Class[]{ |
|
|
|
// 列名选择
|
|
|
|
// 列名选择
|
|
|
@ -102,15 +98,41 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
// 规则状态
|
|
|
|
// 规则状态
|
|
|
|
DesensitizationRuleStatusPane.class |
|
|
|
DesensitizationRuleStatusPane.class |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
ColumnNamesComboBox columnNamesComboBox = new ColumnNamesComboBox(); |
|
|
|
this.setDefaultEditor(ColumnNamesComboBox.class, new ColumnNamesComboBox()); |
|
|
|
this.setDefaultEditor(ColumnNamesComboBox.class, columnNamesComboBox); |
|
|
|
this.setDefaultEditor(DesensitizationRuleChooser.class, new DesensitizationRuleChooser()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleChooser.class, new DesensitizationRuleChooser()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane()); |
|
|
|
this.setDefaultEditor(EffectedRolesChooser.class, new EffectedRolesChooser()); |
|
|
|
EffectedRolesChooser effectedRolesChooser = new EffectedRolesChooser(); |
|
|
|
|
|
|
|
this.setDefaultEditor(EffectedRolesChooser.class, effectedRolesChooser); |
|
|
|
this.setDefaultEditor(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultRenderer(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultRenderer(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
|
|
|
|
|
|
|
|
this.createTable().getColumnModel().getColumn(TableSequences.DesensitizationRuleStatus.getNum()).setMaxWidth(60); |
|
|
|
this.createTable().getColumnModel().getColumn(TableSequences.DesensitizationRuleStatus.getNum()).setMaxWidth(60); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SwingWorker<Void, Void>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
|
|
|
|
// 获取当前数据集的所有列名
|
|
|
|
|
|
|
|
columnNames.addAll(TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData)); |
|
|
|
|
|
|
|
// 获取当前所有用户组
|
|
|
|
|
|
|
|
roleMap.putAll(TableDataPreviewDesensitizeManager.getInstance().getAllRoles()); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void done() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 更新列名选择框和生效用户组选择框
|
|
|
|
|
|
|
|
columnNamesComboBox.refresh(); |
|
|
|
|
|
|
|
effectedRolesChooser.refresh(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e, "[Desensitization] get column names or all roles failed for {}", e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.execute(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -132,9 +154,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 +185,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(), |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -207,6 +231,13 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询到数据集列名后,更新到下拉框中 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void refresh() { |
|
|
|
|
|
|
|
columnNameComboBox.refreshBoxItems(columnNames); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
@ -325,7 +356,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
private UIComboCheckBox rolesCheckBox; |
|
|
|
private UIComboCheckBox rolesCheckBox; |
|
|
|
|
|
|
|
|
|
|
|
EffectedRolesChooser() { |
|
|
|
EffectedRolesChooser() { |
|
|
|
this.rolesCheckBox = new UIComboCheckBox(roleMap.values().toArray(), true) { |
|
|
|
this.rolesCheckBox = new UIComboCheckBox(new String[]{}, true) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void setLayoutAndAddComponents() { |
|
|
|
protected void setLayoutAndAddComponents() { |
|
|
|
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
|
|
|
|
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
|
|
|
@ -359,6 +390,13 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 查询到所有用户组后,更新到下拉框中 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void refresh() { |
|
|
|
|
|
|
|
rolesCheckBox.refreshCombo(roleMap.values().toArray()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
|
|
|
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); |
|
|
|
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); |
|
|
@ -428,44 +466,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); |
|
|
|
* 标签点击后,处理原规则 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void ruleStatusLabelClick(TableDataDesensitizationItem currentItem) { |
|
|
|
|
|
|
|
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(currentItem.getRule()); |
|
|
|
|
|
|
|
if (ruleStatus == DesensitizationRuleStatus.NORMAL) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 点击Label后,弹窗提示
|
|
|
|
|
|
|
|
int option = FineJOptionPane.showConfirmDialog( |
|
|
|
|
|
|
|
parent, |
|
|
|
|
|
|
|
ruleStatus.getDescription(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
|
|
|
FineJOptionPane.OK_CANCEL_OPTION, |
|
|
|
|
|
|
|
FineJOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
|
|
|
if (option == FineJOptionPane.OK_OPTION && table.getSelectedRow() != -1) { |
|
|
|
|
|
|
|
int selectedRow = table.getSelectedRow(); |
|
|
|
|
|
|
|
// 点击确定后,根据规则状态对规则做处理
|
|
|
|
|
|
|
|
if (ruleStatus == DesensitizationRuleStatus.REMOVED || ruleStatus == DesensitizationRuleStatus.WRONG) { |
|
|
|
|
|
|
|
// 规则被删除或读取错误时,直接删掉
|
|
|
|
|
|
|
|
removeRow(selectedRow); |
|
|
|
|
|
|
|
} else if (ruleStatus == DesensitizationRuleStatus.MODIFIED) { |
|
|
|
|
|
|
|
// 规则被修改时,用新规则替换
|
|
|
|
|
|
|
|
DesensitizationRule lastedRule = DesensitizationRuleManager.getInstance().getLastedDesentizationRule(currentItem.getRule()); |
|
|
|
|
|
|
|
currentItem.setRule(lastedRule); |
|
|
|
|
|
|
|
setRowAt(currentItem, selectedRow); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -518,6 +528,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 +620,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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|