Browse Source

REPORT-83849 && REPORT-89327

【问题原因】未设计远程调用接口;脱敏计算获取的部门id api接口有误,未拼接部分id与职位id
【改动思路】增加远程调用接口;修改获取部分id 的api接口
release/11.0
Leo.Qin 2 years ago
parent
commit
40c8cc7800
  1. 74
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java
  2. 4
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java
  3. 10
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellEditor.java
  4. 27
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java

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

@ -124,80 +124,6 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage
return Collections.EMPTY_LIST;
}
/**
* 这个api会返回 部门职位 + 自定义角色 的Map
* 其中 key为 "pid" + "_" + "id"value为 "ptext" + "text"
*
* @return
*/
public Map<String, String> getAllRoles() {
Map<String, String> rolesMap = new LinkedHashMap<>();
// 处理部门职位相关的用户组
addDepartmentAndPositionRoles2Map(rolesMap);
// 处理自定义角色相关的用户组
addCustomRoles2Map(rolesMap);
return rolesMap;
}
/**
* 获取所有的部门职位按照 key为 "pid" + "_" + "id"value为 "ptext" + "text"的格式添加到参数Map中
*
* @param rolesMap
*/
private void addDepartmentAndPositionRoles2Map(Map<String, String> rolesMap) {
try {
List<DepartmentPostBean> postBeans = PositionService.getInstance().getDepartmentPostNameList();
for (DepartmentPostBean postBean : postBeans) {
String department = postBean.getpText();
String position = postBean.getText();
String departmentId = postBean.getpId();
String positionId = postBean.getId();
if (!ComparatorUtils.equals(DecisionServiceConstants.DECISION_DEP_ROOT, postBean.getId()) && StringUtils.isNotEmpty(position)) {
// 只添加部门和职位同时存在的
rolesMap.put(mergeRoleId(departmentId, positionId), mergeRoleText(department, position));
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add department and position roles to map for {}", e.getMessage());
}
}
/**
* 获取所有的自定义角色按照 id - name添加到参数map里
*
* @param rolesMap
*/
private void addCustomRoles2Map(Map<String, String> rolesMap) {
try {
List<RoleBean> allCustomRole = CustomRoleService.getInstance().getAllCustomRoleNameList(null);
allCustomRole.forEach(roleBean -> rolesMap.put(roleBean.getId(), roleBean.getText()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add custom role to map for {}", e.getMessage());
}
}
/**
* 合并部门 + 职位的名称
*
* @param departmentName
* @param positionName
* @return
*/
private String mergeRoleText(String departmentName, String positionName) {
return departmentName + positionName;
}
/**
* 合并部门 + 职位的id
*
* @param departmentId
* @param positionId
* @return
*/
private String mergeRoleId(String departmentId, String positionId) {
return departmentId + CONNECTOR + positionId;
}
/**
* 根据列名从PreviewTableModel中匹配列序号如果返回-1代表未匹配到
* @param desensitizationItem

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

@ -1,5 +1,6 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.base.operator.org.OrganizationOperator;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.rule.DesensitizationRuleManager;
@ -10,6 +11,7 @@ import com.fr.design.data.tabledata.tabledatapane.loading.TipsPane;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.workspace.WorkContext;
import javax.swing.JPanel;
import javax.swing.SwingWorker;
@ -89,7 +91,7 @@ public class TableDataDesensitizationTablePane extends JPanel {
// 获取当前数据集的所有列名
columnNames.addAll(TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData));
// 获取当前所有用户组
roleMap.putAll(TableDataPreviewDesensitizeManager.getInstance().getAllRoles());
roleMap.putAll(WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles());
// 获取当前最新的所有规则
latestRules.putAll(DesensitizationRuleManager.getInstance().getAllRules());
return null;

10
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellEditor.java

@ -5,6 +5,7 @@ import com.fr.report.cell.desensitization.CellDesensitizationBean;
import javax.swing.AbstractCellEditor;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingWorker;
import javax.swing.border.LineBorder;
import javax.swing.table.TableCellEditor;
import java.awt.Color;
@ -26,6 +27,15 @@ public class DesensitizationCellEditor extends AbstractCellEditor implements Tab
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
// 点击脱敏设置时刷新用户组信息和所有规则
new SwingWorker<Void, Void>(){
@Override
protected Void doInBackground() throws Exception {
editPane.refresh();
return null;
}
}.execute();
editPane.populate((CellDesensitizationBean) value, row);

27
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java

@ -1,11 +1,11 @@
package com.fr.design.mainframe.cell.settingpane.desensitization.model;
import com.fr.base.operator.org.OrganizationOperator;
import com.fr.data.desensitize.rule.DesensitizationRuleManager;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.data.desensitize.rule.base.DesensitizationRuleSource;
import com.fr.data.desensitize.rule.base.DesensitizationRuleStatus;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
@ -22,11 +22,11 @@ import com.fr.design.layout.VerticalFlowLayout;
import com.fr.report.cell.desensitization.CellDesensitizationBean;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.collections4.map.HashedMap;
import com.fr.workspace.WorkContext;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -56,8 +56,8 @@ public class DesensitizationCellPane extends BasicBeanPane {
private UITextField ruleTextField;
private UIComboCheckBox rolesComboBox;
private static final String APOSTROPHE = "...";
private Map<String, String> roleMap;
private DesensitizationRule rule;
private static Map<String, String> roleMap;
private static Map<DesensitizationRuleSource, Map<String, DesensitizationRule>> latestRules;
private CellDesensitizationTableModel model;
@ -141,7 +141,6 @@ public class DesensitizationCellPane extends BasicBeanPane {
public void actionPerformed(ActionEvent e) {
CellDesensitizationBean selectBean = model.getSelectedValue();
latestRules = DesensitizationRuleManager.getInstance().getAllRules();
DesensitizationRulePane rulePane = new DesensitizationRulePane(latestRules);
BasicDialog ruleDialog = rulePane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@ -204,7 +203,6 @@ public class DesensitizationCellPane extends BasicBeanPane {
public void populate(CellDesensitizationBean value, int row) {
refreshRoles();
String ruleName = value.getDesensitizationRule().getRuleName();
ruleTextField.setText(ruleName);
@ -218,14 +216,10 @@ public class DesensitizationCellPane extends BasicBeanPane {
}
/**
* 刷新用户组信息
* combobox组件刷新用户组信息
*/
private void refreshRoles() {
Map<String, String> roles = TableDataPreviewDesensitizeManager.getInstance().getAllRoles();
if (!roleMap.equals(roles)) {
roleMap = roles;
rolesComboBox.refreshCombo(roles.values().toArray());
}
rolesComboBox.refreshCombo(roleMap.values().toArray());
}
private void refreshRuleState(CellDesensitizationBean value) {
@ -310,4 +304,15 @@ public class DesensitizationCellPane extends BasicBeanPane {
return omitText.equals(StringUtils.EMPTY) ? text : omitText;
}
}
/**
* 刷新用户组和平台规则
*/
public void refresh() {
roleMap = WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles();
latestRules = DesensitizationRuleManager.getInstance().getAllRules();
}
}

Loading…
Cancel
Save