Browse Source

Pull request #1674: REPORT-31291 数据连接权限控制问题

Merge in DESIGN/design from ~HADES/design:release/10.0 to release/10.0

* commit '6740020f6576e88b62547a58a4e663c2fbcca0d6':
  REPORT-31291 数据连接权限控制问题
feature/big-screen
Hades 5 years ago
parent
commit
c1efec493f
  1. 34
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

34
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -1,12 +1,10 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.BaseUtils;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.DialectFactory; import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator; import com.fr.data.operator.DataOperator;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
@ -37,6 +35,7 @@ import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext; import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
@ -61,9 +60,10 @@ import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Set;
/** /**
* @author zhou * @author zhou
@ -210,10 +210,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected void initDsNameComboBox() { protected void initDsNameComboBox() {
dsNameComboBox.setRefreshingModel(true); dsNameComboBox.setRefreshingModel(true);
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(getHasAuthConnections());
List<String> dsList = new ArrayList<>();
dsList.addAll(connectionConfig.getConnections().keySet());
FilterableComboBoxModel dsNameComboBoxModel = new FilterableComboBoxModel(dsList);
dsNameComboBox.setModel(dsNameComboBoxModel); dsNameComboBox.setModel(dsNameComboBoxModel);
dsNameComboBox.setRefreshingModel(false); dsNameComboBox.setRefreshingModel(false);
} }
@ -322,14 +319,31 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
return null; // peter:选中了当前的零长度的节点,直接返回. return null; // peter:选中了当前的零长度的节点,直接返回.
} }
ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); ConnectionConfig connectionConfig = ConnectionConfig.getInstance();
for (Map.Entry<String, Connection> entry : connectionConfig.getConnections().entrySet()) { List<String> authConnections = getHasAuthConnections();
if (ComparatorUtils.equals(selectedDSName, entry.getKey())) { for (String name : authConnections) {
return entry.getValue(); if (ComparatorUtils.equals(selectedDSName, name)) {
return connectionConfig.getConnection(name);
} }
} }
return null; return null;
} }
private List<String> getHasAuthConnections() {
List<String> authConnections = new ArrayList<>();
Set<String> allConnections = ConnectionConfig.getInstance().getConnections().keySet();
Collection<String> noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections();
if (noAuthConnections == null) {
return authConnections;
}
for (String name : allConnections) {
if (!noAuthConnections.contains(name)) {
authConnections.add(name);
}
}
return authConnections;
}
/** /**
* 刷新没多大用而且要刷新也不是这儿刷新 * 刷新没多大用而且要刷新也不是这儿刷新
*/ */

Loading…
Cancel
Save