Search in sources :

Example 6 with DBPDriver

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

the class DataTypeProviderRegistry method getDataTypeProvider.

////////////////////////////////////////////////////
// DataType providers
@Nullable
public DBDValueHandlerProvider getDataTypeProvider(@NotNull DBPDataSource dataSource, @NotNull DBSTypedObject typedObject) {
    DBPDriver driver = dataSource.getContainer().getDriver();
    if (!(driver instanceof DriverDescriptor)) {
        log.warn("Bad datasource specified (driver is not recognized by registry) - " + dataSource);
        return null;
    }
    DataSourceProviderDescriptor dsProvider = ((DriverDescriptor) driver).getProviderDescriptor();
    // First try to find type provider for specific datasource type
    for (ValueHandlerDescriptor dtProvider : dataTypeProviders) {
        if (!dtProvider.isGlobal() && dtProvider.supportsDataSource(dataSource, dsProvider) && dtProvider.supportsType(typedObject)) {
            return dtProvider.getInstance();
        }
    }
    // Find in global providers
    for (ValueHandlerDescriptor dtProvider : dataTypeProviders) {
        if (dtProvider.isGlobal() && dtProvider.supportsType(typedObject)) {
            return dtProvider.getInstance();
        }
    }
    return null;
}
Also used : DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DBPDriver(org.jkiss.dbeaver.model.connection.DBPDriver) DataSourceProviderDescriptor(org.jkiss.dbeaver.registry.DataSourceProviderDescriptor) Nullable(org.jkiss.code.Nullable)

Aggregations

DBPDriver (org.jkiss.dbeaver.model.connection.DBPDriver)6 DataSourceProviderDescriptor (org.jkiss.dbeaver.registry.DataSourceProviderDescriptor)2 DriverDescriptor (org.jkiss.dbeaver.registry.driver.DriverDescriptor)2 CSVReader (au.com.bytecode.opencsv.CSVReader)1 NotNull (org.jkiss.code.NotNull)1 Nullable (org.jkiss.code.Nullable)1 DBException (org.jkiss.dbeaver.DBException)1 ImportDriverInfo (org.jkiss.dbeaver.ext.import_config.wizards.ImportDriverInfo)1 WMIDataSource (org.jkiss.dbeaver.ext.wmi.model.WMIDataSource)1 DBPConnectionConfiguration (org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration)1 DBDAttributeTransformerDescriptor (org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)1 XMLException (org.jkiss.utils.xml.XMLException)1