From 254b7ce2226fbfa38806deb166a2317296112fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvan-=E6=AC=A7=E9=98=B3=E5=B8=86?= Date: Wed, 8 Feb 2023 10:13:14 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-89260=20&&=20REPORT-83847=20=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E8=AE=BE=E8=AE=A1=E4=B8=8B=E5=8D=A1=E9=A1=BF=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E8=A7=84=E5=88=99=E5=BC=82=E5=B8=B8=20=E3=80=90?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=8E=9F=E5=9B=A0=E3=80=91=E5=8D=A1=E9=A1=BF?= =?UTF-8?q?=E6=98=AF=E5=9B=A0=E4=B8=BA=E6=9F=A5=E8=AF=A2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E7=9A=84=E6=93=8D=E4=BD=9C=E6=94=BE=E5=9C=A8=E4=BA=86?= =?UTF-8?q?UI=E7=BA=BF=E7=A8=8B=E9=87=8C=EF=BC=9B=E8=A7=84=E5=88=99?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=98=AF=E5=9B=A0=E4=B8=BA=E8=A7=84=E5=88=99?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=99=A8DesensitizationRuleManager=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E8=A7=84=E5=88=99=E7=BC=93=E5=AD=98=E5=AF=B9=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E5=88=87=E6=8D=A2=E6=97=B6=E7=9A=84=E7=9B=91=E5=90=AC?= =?UTF-8?q?=E5=86=99=E7=9A=84=E6=9C=89=E7=82=B9=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E3=80=90=E6=94=B9=E5=8A=A8=E6=80=9D=E8=B7=AF=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98=E6=98=AF=E5=8A=A0?= =?UTF-8?q?SwingWorker=EF=BC=9B=E8=A7=84=E5=88=99=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E8=BF=99=E4=B8=AA=EF=BC=8C=E6=83=B3=E4=BA=86=E4=B8=8BDesensiti?= =?UTF-8?q?zationRuleManager=E4=B8=AD=E7=9A=84=E8=A7=84=E5=88=99=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=AD=A4=E5=89=8D=E5=8F=AA=E9=92=88=E5=AF=B9=E4=BA=86?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E8=A7=84=E5=88=99=E5=8F=98=E5=8C=96=E3=80=81?= =?UTF-8?q?=E8=BF=9C=E7=A8=8B=E7=8E=AF=E5=A2=83=E5=88=87=E6=8D=A2=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E6=B2=A1=E9=92=88=E5=AF=B9=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E4=B8=8B=E7=9A=84=E8=A7=84=E5=88=99=E5=8F=98=E5=8C=96=EF=BC=8C?= =?UTF-8?q?=E8=80=8C=E4=B8=94=E5=A5=BD=E5=83=8F=E6=B2=A1=E6=9C=89=E5=A4=AA?= =?UTF-8?q?=E5=A5=BD=E7=9A=84=E6=80=9D=E8=B7=AF=E3=80=82=E7=8E=B0=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=E5=81=9A=E6=B3=95=E6=98=AF=E7=9B=B4=E6=8E=A5=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E8=A7=84=E5=88=99=E7=BC=93=E5=AD=98=EF=BC=8C=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E6=9F=A5=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=8C=E5=A5=97?= =?UTF-8?q?=E7=94=A8Config=E6=A1=86=E6=9E=B6=E7=9A=84=E7=BC=93=E5=AD=98=20?= =?UTF-8?q?=E3=80=90review=E5=BB=BA=E8=AE=AE=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TableDataPreviewDesensitizeManager.java | 12 ++- .../TableDataDesensitizationTableModel.java | 89 +++++++++---------- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index 1fbed9f437..5c2b42c257 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -2,6 +2,7 @@ package com.fr.design.data.datapane.preview.desensitization; import com.fr.base.TableData; +import com.fr.data.TableDataSource; import com.fr.data.desensitize.TableDataDesensitizeManager; import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.TableDataDesensitizationItem; @@ -15,11 +16,14 @@ 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.esd.query.StrategicTableData; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; @@ -107,13 +111,17 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage } /** - * 通过TableData获取其列名 + * 通过TableData获取其列名,理论上一定存在缓存值 * * @param tableData * @return */ public List getColumnNamesByTableData(TableData tableData) { - return DesignTableDataManager.getColumnNamesByTableData(tableData); + TableDataSource editingTableDataSource = DesignTableDataManager.getEditingTableDataSource(); + if (editingTableDataSource != null && tableData instanceof StrategicTableData) { + return Arrays.asList(DesignTableDataManager.getSelectedColumnNames(editingTableDataSource, ((StrategicTableData) tableData).getDsName())); + } + return Collections.EMPTY_LIST; } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java index c1d958bf9f..375f280bdf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java @@ -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.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; 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.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import org.jetbrains.annotations.Nullable; @@ -29,6 +29,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.table.TableCellEditor; @@ -38,9 +39,11 @@ import java.awt.Color; 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.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -61,17 +64,15 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter columnNames; + private List columnNames = new ArrayList<>(); /** * key为用户组唯一标识(id拼接),value为用户组名称 */ - private Map roleMap; + private final Map roleMap = new LinkedHashMap<>(); private Component parent; @@ -84,12 +85,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter() { + + @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 @@ -210,6 +231,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter