Search in sources :

Example 1 with DBPDataSourceProvider

use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by dbeaver.

the class PostgreDebugAdapterFactory method getAdapter.

@SuppressWarnings("unchecked")
@Override
public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
    if (adapterType == DBGController.class) {
        if (adaptableObject instanceof DBPDataSourceContainer) {
            DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
            DBPDriver driver = sourceContainer.getDriver();
            if (driver == null) {
                return null;
            }
            DBPDataSourceProvider dataSourceProvider = driver.getDataSourceProvider();
            if (dataSourceProvider instanceof PostgreDataSourceProvider) {
                PostgreDebugController postgreDebugController = new PostgreDebugController(sourceContainer);
                return (T) postgreDebugController;
            }
        }
    } else if (adapterType == DBGResolver.class) {
        if (adaptableObject instanceof DBPDataSourceContainer) {
            DBPDataSourceContainer sourceContainer = (DBPDataSourceContainer) adaptableObject;
            DBPDataSource dataSource = sourceContainer.getDataSource();
            if (dataSource instanceof PostgreDataSource) {
                PostgreDataSource postgeDataSource = (PostgreDataSource) dataSource;
                return (T) new PostgreResolver(postgeDataSource);
            }
        }
    }
    return null;
}
Also used : PostgreDataSource(org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource) DBGResolver(org.jkiss.dbeaver.debug.DBGResolver) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) PostgreDataSourceProvider(org.jkiss.dbeaver.ext.postgresql.PostgreDataSourceProvider) PostgreDebugController(org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugController) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider)

Example 2 with DBPDataSourceProvider

use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by serge-rider.

the class AuthModelDatabaseNative method loadCredentials.

@NotNull
@Override
public CREDENTIALS loadCredentials(@NotNull DBPDataSourceContainer dataSource, @NotNull DBPConnectionConfiguration configuration) {
    CREDENTIALS credentials = createCredentials();
    DBPDataSourceProvider dataSourceProvider = dataSource.getDriver().getDataSourceProvider();
    if (dataSourceProvider instanceof DBAUserCredentialsProvider) {
        credentials.setUserName(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserName(configuration));
        credentials.setUserPassword(((DBAUserCredentialsProvider) dataSourceProvider).getConnectionUserPassword(configuration));
    } else {
        credentials.setUserName(configuration.getUserName());
        credentials.setUserPassword(configuration.getUserPassword());
    }
    boolean allowsEmptyPassword = dataSource.getDriver().isAllowsEmptyPassword();
    if (credentials.getUserPassword() == null && allowsEmptyPassword) {
        credentials.setUserPassword("");
    }
    return credentials;
}
Also used : DBAUserCredentialsProvider(org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) NotNull(org.jkiss.code.NotNull)

Example 3 with DBPDataSourceProvider

use of org.jkiss.dbeaver.model.DBPDataSourceProvider in project dbeaver by serge-rider.

the class DataSourceUtils method getDataSourceAddressText.

@NotNull
public static String getDataSourceAddressText(DBPDataSourceContainer dataSourceContainer) {
    DBPDataSourceProvider dataSourceProvider = dataSourceContainer.getDriver().getDataSourceProvider();
    if (dataSourceProvider instanceof DBPInformationProvider) {
        String objectInformation = ((DBPInformationProvider) dataSourceProvider).getObjectInformation(dataSourceContainer, DBPInformationProvider.INFO_TARGET_ADDRESS);
        if (!CommonUtils.isEmpty(objectInformation)) {
            return objectInformation;
        }
    }
    DBPConnectionConfiguration cfg = dataSourceContainer.getConnectionConfiguration();
    String hostText = getTargetTunnelHostName(cfg);
    String hostPort = cfg.getHostPort();
    if (!CommonUtils.isEmpty(hostPort)) {
        return hostText + ":" + hostPort;
    }
    return hostText;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DBPInformationProvider(org.jkiss.dbeaver.model.DBPInformationProvider) DBPDataSourceProvider(org.jkiss.dbeaver.model.DBPDataSourceProvider) NotNull(org.jkiss.code.NotNull)

Aggregations

DBPDataSourceProvider (org.jkiss.dbeaver.model.DBPDataSourceProvider)3 NotNull (org.jkiss.code.NotNull)2 DBGResolver (org.jkiss.dbeaver.debug.DBGResolver)1 PostgreDataSourceProvider (org.jkiss.dbeaver.ext.postgresql.PostgreDataSourceProvider)1 PostgreDebugController (org.jkiss.dbeaver.ext.postgresql.debug.internal.impl.PostgreDebugController)1 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)1 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 DBPInformationProvider (org.jkiss.dbeaver.model.DBPInformationProvider)1 DBAUserCredentialsProvider (org.jkiss.dbeaver.model.auth.DBAUserCredentialsProvider)1 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)1 DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)1