use of org.jkiss.dbeaver.registry.driver.DriverDescriptor in project dbeaver by serge-rider.
the class DataTypeProviderRegistry method findTransformers.
@Override
public List<AttributeTransformerDescriptor> findTransformers(DBPDataSource dataSource, DBSTypedObject typedObject, Boolean custom) {
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();
// Find in default providers
List<AttributeTransformerDescriptor> result = null;
for (AttributeTransformerDescriptor descriptor : dataTypeTransformers) {
if ((custom == null || custom == descriptor.isCustom()) && ((!descriptor.isGlobal() && descriptor.supportsDataSource(dataSource, dsProvider) && descriptor.supportsType(typedObject)) || (descriptor.isGlobal() && descriptor.supportsType(typedObject)))) {
if (result == null) {
result = new ArrayList<>();
}
result.add(descriptor);
}
}
return result;
}
use of org.jkiss.dbeaver.registry.driver.DriverDescriptor in project dbeaver by dbeaver.
the class DatabaseTab method initializeDriver.
protected void initializeDriver(ILaunchConfiguration configuration) {
String extracted = DebugCore.extractDriverId(configuration);
DriverDescriptor driver = DataSourceProviderRegistry.getInstance().findDriver(extracted);
String driverName = extracted;
if (driver != null) {
driverName = driver.getName();
}
driverText.setText(driverName);
driverText.setData(extracted);
}
use of org.jkiss.dbeaver.registry.driver.DriverDescriptor in project dbeaver by dbeaver.
the class ConfigImportWizard method findOrCreateDriver.
private boolean findOrCreateDriver(ImportConnectionInfo connectionInfo) throws DBException {
final ImportDriverInfo driverInfo = connectionInfo.getDriverInfo();
if (CommonUtils.isEmpty(driverInfo.getDriverClass())) {
throw new DBException("Cannot create driver '" + driverInfo.getName() + "' - no driver class specified");
}
String sampleURL = driverInfo.getSampleURL();
if (CommonUtils.isEmpty(sampleURL)) {
throw new DBException("Cannot create driver '" + driverInfo.getName() + "' - no connection URL pattern specified");
}
{
DriverDescriptor driver = driverClassMap.get(driverInfo.getDriverClass());
if (driver != null) {
connectionInfo.setDriver(driver);
return true;
}
}
final DataSourceProviderRegistry registry = DataSourceProviderRegistry.getInstance();
List<DriverDescriptor> matchedDrivers = new ArrayList<>();
for (DataSourceProviderDescriptor dataSourceProvider : registry.getDataSourceProviders()) {
for (DriverDescriptor driver : dataSourceProvider.getEnabledDrivers()) {
final String driverClassName = driver.getDriverClassName();
if (driverClassName != null && driverClassName.equals(driverInfo.getDriverClass())) {
matchedDrivers.add(driver);
}
}
}
DriverDescriptor driver;
if (matchedDrivers.isEmpty()) {
// Create new driver
final DataSourceProviderDescriptor genericProvider = registry.getDataSourceProvider("generic");
if (genericProvider == null) {
throw new DBException("Generic datasource provider not found");
}
driver = genericProvider.createDriver();
driver.setName(driverInfo.getName());
driver.setDriverClassName(driverInfo.getDriverClass());
driver.setSampleURL(driverInfo.getSampleURL());
driver.setConnectionProperties(driverInfo.getProperties());
driver.setDescription(driverInfo.getDescription());
driver.setDriverDefaultPort(driverInfo.getDefaultPort());
for (String path : driverInfo.getLibraries()) {
driver.addDriverLibrary(path, DBPDriverLibrary.FileType.jar);
}
driver.setModified(true);
genericProvider.addDriver(driver);
connectionInfo.setDriver(driver);
} else if (matchedDrivers.size() == 1) {
// Use the only found driver
driver = matchedDrivers.get(0);
connectionInfo.setDriver(driver);
} else {
// Let user to choose correct driver
driver = SelectObjectDialog.selectObject(getShell(), "Choose driver for connection '" + connectionInfo.getAlias() + "'", "ImportDriverSelector", matchedDrivers);
if (driver == null) {
return false;
}
connectionInfo.setDriver(driver);
}
if (driver != null) {
driverClassMap.put(driver.getDriverClassName(), driver);
return true;
}
return false;
}
use of org.jkiss.dbeaver.registry.driver.DriverDescriptor in project dbeaver by dbeaver.
the class SQLContextTypeRegistry method loadContextTypes.
private void loadContextTypes() {
addContextType(new SQLContextTypeBase());
for (DataSourceProviderDescriptor provider : DataSourceProviderRegistry.getInstance().getDataSourceProviders()) {
if (!provider.isDriversManagable()) {
SQLContextTypeProvider contextType = new SQLContextTypeProvider(provider);
addContextType(contextType);
provider.loadTemplateVariableResolvers(contextType);
} else {
Set<String> categoriesAdded = new HashSet<>();
for (DriverDescriptor driver : provider.getEnabledDrivers()) {
if (!CommonUtils.isEmpty(driver.getCategory())) {
if (categoriesAdded.contains(driver.getCategory())) {
continue;
}
categoriesAdded.add(driver.getCategory());
}
SQLContextTypeDriver contextType = new SQLContextTypeDriver(driver);
addContextType(contextType);
provider.loadTemplateVariableResolvers(contextType);
}
}
}
}
use of org.jkiss.dbeaver.registry.driver.DriverDescriptor in project dbeaver by dbeaver.
the class ConnectionPageNetwork method activatePage.
@Override
public void activatePage() {
DataSourceDescriptor dataSource = wizard.getPageSettings().getActiveDataSource();
DriverDescriptor driver = wizard.getSelectedDriver();
NetworkHandlerRegistry registry = NetworkHandlerRegistry.getInstance();
if (prevDataSource == null || prevDataSource != dataSource) {
for (TabItem item : handlersFolder.getItems()) {
item.dispose();
}
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
try {
createHandlerTab(descriptor);
} catch (DBException e) {
log.warn(e);
}
}
prevDataSource = dataSource;
handlersFolder.layout();
for (TabItem item : handlersFolder.getItems()) {
((Composite) item.getControl()).layout();
}
}
TabItem selectItem = null;
for (NetworkHandlerDescriptor descriptor : registry.getDescriptors(dataSource)) {
DBWHandlerConfiguration configuration = dataSource.getConnectionConfiguration().getHandler(descriptor.getId());
if (configuration == null) {
configuration = new DBWHandlerConfiguration(descriptor, driver);
}
HandlerBlock handlerBlock = configurations.get(descriptor);
if (handlerBlock == null) {
continue;
}
// handlerBlock.useHandlerCheck.setSelection(configuration.isEnabled());
if (selectItem == null && configuration.isEnabled()) {
selectItem = handlerBlock.tabItem;
}
if (!handlerBlock.loadedConfigs.containsKey(dataSource.getId())) {
handlerBlock.configurator.loadSettings(configuration);
handlerBlock.loadedConfigs.put(dataSource.getId(), configuration);
}
enableHandlerContent(descriptor);
}
if (selectItem != null) {
handlersFolder.setSelection(selectItem);
} else {
handlersFolder.setSelection(0);
}
}
Aggregations