mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-19 10:56:04 +08:00
dbeaver/pro#9612 api for connection types (#4426)
* dbeaver/pro#9612 api for connection types * dbeaver/pro#9612 add more fields for connection type info * dbeaver/pro#9612 renaming and event handling * dbeaver/pro#9612 fix doc and add all inputs
This commit is contained in:
@@ -65,6 +65,7 @@ public class WebConnectionConfig {
|
||||
private Boolean defaultAutoCommit;
|
||||
private String defaultCatalogName;
|
||||
private String defaultSchemaName;
|
||||
private String connectionType;
|
||||
@NotNull
|
||||
private Map<String, String> defaultUserPreferences = new LinkedHashMap<>();
|
||||
|
||||
@@ -120,6 +121,7 @@ public class WebConnectionConfig {
|
||||
for (Map<String, Object> nhc : JSONUtils.getObjectList(params, "networkHandlersConfig")) {
|
||||
networkHandlersConfig.add(new WebNetworkHandlerConfigInput(nhc));
|
||||
}
|
||||
connectionType = JSONUtils.getString(params, "connectionType");
|
||||
}
|
||||
|
||||
@Property
|
||||
@@ -381,4 +383,13 @@ public class WebConnectionConfig {
|
||||
public void setDefaultUserPreferences(@NotNull Map<String, String> defaultUserPreferences) {
|
||||
this.defaultUserPreferences = defaultUserPreferences;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getConnectionType() {
|
||||
return connectionType;
|
||||
}
|
||||
|
||||
public void setConnectionType(@Nullable String connectionType) {
|
||||
this.connectionType = connectionType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,6 +586,11 @@ public class WebConnectionInfo {
|
||||
return tools;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getConnectionType() {
|
||||
return dataSourceContainer.getConnectionConfiguration().getConnectionType().getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates param that checks whether credentials were saved only in session.
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jkiss.dbeaver.model.access.DBAAuthCredentials;
|
||||
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
|
||||
import org.jkiss.dbeaver.model.app.DBPProject;
|
||||
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
|
||||
import org.jkiss.dbeaver.model.connection.DBPConnectionType;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDataSourceProviderDescriptor;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
import org.jkiss.dbeaver.model.impl.auth.AuthModelDatabaseNativeCredentials;
|
||||
@@ -40,6 +41,7 @@ import org.jkiss.dbeaver.model.net.DBWHandlerConfiguration;
|
||||
import org.jkiss.dbeaver.model.net.ssh.SSHConstants;
|
||||
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
|
||||
import org.jkiss.dbeaver.model.websocket.event.datasource.WSDataSourceDisconnectEvent;
|
||||
import org.jkiss.dbeaver.registry.DataSourceProviderRegistry;
|
||||
import org.jkiss.dbeaver.registry.network.NetworkHandlerDescriptor;
|
||||
import org.jkiss.dbeaver.registry.network.NetworkHandlerRegistry;
|
||||
import org.jkiss.dbeaver.runtime.DBWorkbench;
|
||||
@@ -320,6 +322,13 @@ public class WebDataSourceUtils {
|
||||
if (config.getConfigurationType() != null) {
|
||||
dsConfig.setConfigurationType(config.getConfigurationType());
|
||||
}
|
||||
if (config.getConnectionType() != null) {
|
||||
DBPConnectionType connectionType = DataSourceProviderRegistry.getInstance().getConnectionType(config.getConnectionType(), null);
|
||||
if (connectionType != null) {
|
||||
dsConfig.setConnectionType(connectionType);
|
||||
}
|
||||
}
|
||||
|
||||
if (CommonUtils.isEmpty(config.getUrl())) {
|
||||
dsConfig.setUrl(driver.getConnectionURL(dsConfig));
|
||||
}
|
||||
|
||||
@@ -570,6 +570,8 @@ type ConnectionInfo {
|
||||
|
||||
"List of tools that can be used with this connection. Returns empty list if no tools are available"
|
||||
tools: [String!]! @since(version: "24.1.3")
|
||||
|
||||
connectionType: ID! @since(version: "26.1.2")
|
||||
}
|
||||
|
||||
type ConnectionFolderInfo {
|
||||
@@ -633,6 +635,37 @@ type LogEntry {
|
||||
stackTrace: String
|
||||
}
|
||||
|
||||
type ConnectionType @since(version: "26.1.2") {
|
||||
"Unique identifier of the connection type"
|
||||
id: ID!
|
||||
"Human-readable name of the connection type"
|
||||
name: String!
|
||||
"Description of the connection type"
|
||||
description: String
|
||||
"Color of the connection type (for light theme)"
|
||||
colorLight: String!
|
||||
"Alternative color of the connection type (for dark theme)"
|
||||
colorDark: String
|
||||
"Is autocommit enabled for this connection type"
|
||||
autocommit: Boolean!
|
||||
"Confirm execution of queries for this connection type"
|
||||
confirmExecute: Boolean!
|
||||
"Confirm data change operations (INSERT, UPDATE, DELETE) for this connection type"
|
||||
confirmDataChange: Boolean!
|
||||
"Smart commit mode is enabled for this connection type"
|
||||
smartCommit: Boolean!
|
||||
"Recover smart commit mode is enabled for this connection type"
|
||||
smartCommitRecover: Boolean!
|
||||
"Auto-close transactions is enabled for this connection type"
|
||||
autoCloseTransactions: Boolean!
|
||||
"Auto-close idle transactions period in seconds for this connection type"
|
||||
closeIdleTransactionPeriod: Int!
|
||||
"Auto-close connections is enabled for this connection type"
|
||||
autoCloseConnections: Boolean!
|
||||
"Auto-close idle connections period in seconds for this connection type"
|
||||
closeIdleConnectionPeriod: Int!
|
||||
}
|
||||
|
||||
####################################################
|
||||
# Input types
|
||||
####################################################
|
||||
@@ -745,6 +778,8 @@ input ConnectionConfig {
|
||||
defaultSchemaName: String @since(version: "25.0.5") @deprecated(reason: "25.2.1 use expertPropertyValues instead")
|
||||
"Default user settings for connection"
|
||||
defaultUserPreferences: Object @since(version: "26.0.2")
|
||||
|
||||
connectionType: ID @since(version: "26.1.2")
|
||||
}
|
||||
|
||||
####################################################
|
||||
@@ -790,6 +825,8 @@ extend type Query {
|
||||
|
||||
"Returns connection driver properties based on configuration"
|
||||
listConnectionDriverProperties( projectId: ID!, config: ConnectionConfig! ): [ObjectPropertyInfo!]!
|
||||
|
||||
listConnectionTypes: [ConnectionType!]! @since(version: "26.1.2")
|
||||
}
|
||||
|
||||
extend type Mutation {
|
||||
|
||||
+4
@@ -25,6 +25,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.model.connection.DBPConnectionType;
|
||||
import org.jkiss.dbeaver.model.rm.RMConstants;
|
||||
import org.jkiss.dbeaver.registry.DataSourceNavigatorSettings;
|
||||
import org.jkiss.dbeaver.registry.settings.ProductSettingDescriptor;
|
||||
@@ -115,6 +116,9 @@ public interface DBWServiceCore extends DBWService {
|
||||
@NotNull Map<String, Object> connectionConfig
|
||||
) throws DBWebException;
|
||||
|
||||
@NotNull
|
||||
List<DBPConnectionType> getConnectionTypes(@NotNull WebSession webSession, @Nullable String id);
|
||||
|
||||
@WebAction
|
||||
WebConnectionInfo getConnectionState(WebSession webSession, @Nullable String projectId, String connectionId) throws DBWebException;
|
||||
|
||||
|
||||
+5
@@ -87,6 +87,11 @@ public class WebServiceBindingCore extends WebServiceBindingBase<DBWServiceCore>
|
||||
getArgumentVal(env, "projectId"),
|
||||
getArgumentVal(env, "config")
|
||||
)
|
||||
).dataFetcher(
|
||||
"listConnectionTypes", env -> getService(env).getConnectionTypes(
|
||||
getWebSession(env),
|
||||
getArgument(env, "id")
|
||||
)
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
+10
@@ -45,6 +45,7 @@ import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
|
||||
import org.jkiss.dbeaver.model.app.DBPProject;
|
||||
import org.jkiss.dbeaver.model.auth.SMObjectType;
|
||||
import org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration;
|
||||
import org.jkiss.dbeaver.model.connection.DBPConnectionType;
|
||||
import org.jkiss.dbeaver.model.connection.DBPDriver;
|
||||
import org.jkiss.dbeaver.model.exec.DBCConnectException;
|
||||
import org.jkiss.dbeaver.model.navigator.DBNDataSource;
|
||||
@@ -327,6 +328,15 @@ public class WebServiceCore implements DBWServiceCore {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<DBPConnectionType> getConnectionTypes(@NotNull WebSession webSession, @Nullable String id) {
|
||||
return DataSourceProviderRegistry.getInstance().getConnectionTypes().stream()
|
||||
.map(ct -> id == null || id.equals(ct.getId()) ? ct : null)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WebConnectionInfo initConnection(
|
||||
|
||||
Reference in New Issue
Block a user