mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-21 05:50:36 +08:00
dbeaver/pro#9515 do not duplicate driver props fix (#4560)
* dbeaver/pro#9515 do not duplicate driver props fix * dbeaver/pro#9515 pass default values * dbeaver/pro#9515 fix using mutable list * dbeaver/pro#9515 add comment --------- Co-authored-by: Ainur <ainur.iagudin@dbeaver.com> Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com> Co-authored-by: Ainur <59531286+yagudin10@users.noreply.github.com>
This commit is contained in:
co-authored by
Ainur
Daria Marutkina
Ainur
parent
6d13275021
commit
f4b55add99
@@ -50,7 +50,6 @@ import org.jkiss.dbeaver.model.rm.RMProjectType;
|
||||
import org.jkiss.dbeaver.registry.DataSourceNavigatorSettings;
|
||||
import org.jkiss.dbeaver.runtime.properties.PropertyCollector;
|
||||
import org.jkiss.dbeaver.runtime.properties.PropertySourceCustom;
|
||||
import org.jkiss.utils.ArrayUtils;
|
||||
import org.jkiss.utils.CommonUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -209,9 +208,16 @@ public class WebServiceUtils extends WebCommonUtils {
|
||||
dataSourceContainer,
|
||||
cfg
|
||||
);
|
||||
Map<String, Object> connectionProperties = driver.getConnectionProperties();
|
||||
List<DBPPropertyDescriptor> propertyList = new ArrayList<>(Arrays.asList(properties));
|
||||
Set<String> propertyNames = propertyList.stream().map(DBPPropertyDescriptor::getId).collect(Collectors.toSet());
|
||||
Map<String, Object> connectionProperties = new LinkedHashMap<>(driver.getConnectionProperties());
|
||||
// In case of collision, value from connectionProperties will be used for a driver property.
|
||||
// Default value of property will be from driver.
|
||||
for (Map.Entry<String, Object> connProp : connectionProperties.entrySet()) {
|
||||
String propName = connProp.getKey();
|
||||
if (propertyNames.contains(propName)) {
|
||||
continue;
|
||||
}
|
||||
Object propValue = connProp.getValue();
|
||||
DBPPropertyDescriptor dbpPropertyDescriptor = new PropertyDescriptor(
|
||||
null,
|
||||
@@ -223,19 +229,20 @@ public class WebServiceUtils extends WebCommonUtils {
|
||||
propValue,
|
||||
null
|
||||
);
|
||||
properties = ArrayUtils.add(DBPPropertyDescriptor.class, properties, dbpPropertyDescriptor);
|
||||
propertyList.add(dbpPropertyDescriptor);
|
||||
cfg.setProperty(propName, (String) propValue);
|
||||
}
|
||||
if (properties == null) {
|
||||
if (propertyList.isEmpty()) {
|
||||
return new WebPropertyInfo[0];
|
||||
}
|
||||
connectionProperties.putAll(cfg.getProperties());
|
||||
|
||||
PropertySourceCustom propertySource = new PropertySourceCustom(
|
||||
properties,
|
||||
cfg.getProperties()
|
||||
propertyList,
|
||||
connectionProperties
|
||||
);
|
||||
|
||||
return Arrays.stream(properties)
|
||||
return propertyList.stream()
|
||||
.map(p -> new WebPropertyInfo(webSession, p, propertySource)).toArray(WebPropertyInfo[]::new);
|
||||
} catch (DBException e) {
|
||||
log.error("Error reading driver properties:\n" + e.getMessage());
|
||||
|
||||
Reference in New Issue
Block a user