use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class PostgreToolScript method getPostgreToolCommandLine.
public static <BASE_OBJECT extends DBSObject, PROCESS_ARG> List<String> getPostgreToolCommandLine(AbstractToolWizard<BASE_OBJECT, PROCESS_ARG> toolWizard, PROCESS_ARG arg) throws IOException {
java.util.List<String> cmd = new ArrayList<>();
toolWizard.fillProcessParameters(cmd, arg);
if (toolWizard.isVerbose()) {
cmd.add("--verbose");
}
DBPConnectionConfiguration connectionInfo = toolWizard.getConnectionInfo();
cmd.add("--host=" + connectionInfo.getHostName());
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
cmd.add("--port=" + connectionInfo.getHostPort());
}
cmd.add("--username=" + toolWizard.getToolUserName());
return cmd;
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class OracleDataSource method initialize.
@Override
public void initialize(@NotNull DBRProgressMonitor monitor) throws DBException {
super.initialize(monitor);
DBPConnectionConfiguration connectionInfo = getContainer().getConnectionConfiguration();
{
String useRuleHintProp = connectionInfo.getProviderProperty(OracleConstants.PROP_USE_RULE_HINT);
if (useRuleHintProp != null) {
useRuleHint = CommonUtils.getBoolean(useRuleHintProp, false);
}
}
this.publicSchema = new OracleSchema(this, 1, OracleConstants.USER_PUBLIC);
{
try (JDBCSession session = DBUtils.openMetaSession(monitor, this, "Load data source meta info")) {
// Check DBA role
this.isAdmin = "YES".equals(JDBCUtils.queryString(session, "SELECT 'YES' FROM USER_ROLE_PRIVS WHERE GRANTED_ROLE='DBA'"));
this.isAdminVisible = isAdmin;
if (!isAdminVisible) {
String showAdmin = connectionInfo.getProviderProperty(OracleConstants.PROP_ALWAYS_SHOW_DBA);
if (showAdmin != null) {
isAdminVisible = CommonUtils.getBoolean(showAdmin, false);
}
}
// Get active schema
this.activeSchemaName = OracleUtils.getCurrentSchema(session);
if (this.activeSchemaName != null) {
if (this.activeSchemaName.isEmpty()) {
this.activeSchemaName = null;
}
}
} catch (SQLException e) {
//throw new DBException(e);
log.warn(e);
}
}
// Cache data types
this.dataTypeCache.getAllObjects(monitor, this);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class ConnectionPageGeneral method saveSettings.
void saveSettings(DataSourceDescriptor dataSource) {
if (dataSourceDescriptor != null && !activated) {
// No changes anyway
return;
}
dataSource.setName(connectionNameText.getText());
dataSource.setSavePassword(savePasswordCheck.getSelection());
try {
dataSource.setDefaultAutoCommit(autocommit.getSelection(), null, true, null);
if (dataSource.isConnected()) {
int levelIndex = isolationLevel.getSelectionIndex();
if (levelIndex <= 0) {
dataSource.setDefaultTransactionsIsolation(null);
} else {
dataSource.setDefaultTransactionsIsolation(supportedLevels.get(levelIndex - 1));
}
}
} catch (DBException e) {
log.error(e);
}
dataSource.setDefaultActiveObject(defaultSchema.getText());
dataSource.setShowSystemObjects(showSystemObjects.getSelection());
dataSource.setShowUtilityObjects(showUtilityObjects.getSelection());
dataSource.setConnectionReadOnly(readOnlyConnection.getSelection());
if (!dataSource.isSavePassword()) {
dataSource.resetPassword();
}
dataSource.setFolder(dataSourceFolder);
final DBPConnectionConfiguration confConfig = dataSource.getConnectionConfiguration();
if (connectionTypeCombo.getSelectionIndex() >= 0) {
confConfig.setConnectionType(connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex()));
}
for (FilterInfo filterInfo : filters) {
if (filterInfo.filter != null) {
dataSource.setObjectFilter(filterInfo.type, null, filterInfo.filter);
}
}
DBPConnectionBootstrap bootstrap = confConfig.getBootstrap();
bootstrap.setIgnoreErrors(ignoreBootstrapErrors);
bootstrap.setInitQueries(bootstrapQueries);
confConfig.setKeepAliveInterval(keepAliveInterval.getSelection());
final String description = descriptionText.getText();
if (description.isEmpty()) {
dataSource.setDescription(null);
} else {
dataSource.setDescription(description);
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class ConnectionPageGeneral method activatePage.
@Override
public void activatePage() {
if (connectionNameText != null) {
ConnectionPageSettings settings = wizard.getPageSettings();
String newName;
if (settings != null) {
DBPConnectionConfiguration connectionInfo = settings.getActiveDataSource().getConnectionConfiguration();
//$NON-NLS-1$
newName = dataSourceDescriptor == null ? "" : settings.getActiveDataSource().getName();
if (CommonUtils.isEmpty(newName)) {
newName = connectionInfo.getDatabaseName();
if (CommonUtils.isEmpty(newName)) {
newName = connectionInfo.getHostName();
}
if (CommonUtils.isEmpty(newName)) {
newName = connectionInfo.getUrl();
}
if (CommonUtils.isEmpty(newName)) {
newName = CoreMessages.dialog_connection_wizard_final_default_new_connection_name;
}
//$NON-NLS-1$
StringTokenizer st = new StringTokenizer(newName, "/\\:,?=%$#@!^&*()");
while (st.hasMoreTokens()) {
newName = st.nextToken();
}
if (!CommonUtils.isEmpty(settings.getDriver().getCategory())) {
//$NON-NLS-1$
newName = settings.getDriver().getCategory() + " - " + newName;
} else {
//$NON-NLS-1$
newName = settings.getDriver().getName() + " - " + newName;
}
newName = CommonUtils.truncateString(newName, 50);
}
} else {
newName = wizard.getSelectedDriver().getName();
}
if (CommonUtils.isEmpty(connectionNameText.getText()) || !connectionNameChanged) {
if (newName != null) {
connectionNameText.setText(newName);
}
connectionNameChanged = false;
}
}
if (dataSourceDescriptor != null) {
if (!activated) {
// Get settings from data source descriptor
final DBPConnectionConfiguration conConfig = dataSourceDescriptor.getConnectionConfiguration();
connectionTypeCombo.select(conConfig.getConnectionType());
dataSourceFolder = dataSourceDescriptor.getFolder();
if (dataSourceDescriptor.getFolder() == null) {
connectionFolderCombo.select(0);
} else {
connectionFolderCombo.select(dataSourceFolder);
}
savePasswordCheck.setSelection(dataSourceDescriptor.isSavePassword());
autocommit.setSelection(dataSourceDescriptor.isDefaultAutoCommit());
showSystemObjects.setSelection(dataSourceDescriptor.isShowSystemObjects());
showUtilityObjects.setSelection(dataSourceDescriptor.isShowUtilityObjects());
readOnlyConnection.setSelection(dataSourceDescriptor.isConnectionReadOnly());
isolationLevel.add("");
if (dataSourceDescriptor.isConnected()) {
DBPDataSource dataSource = dataSourceDescriptor.getDataSource();
isolationLevel.setEnabled(!autocommit.getSelection());
supportedLevels.clear();
DBPTransactionIsolation defaultLevel = dataSourceDescriptor.getActiveTransactionsIsolation();
for (DBPTransactionIsolation level : CommonUtils.safeCollection(dataSource.getInfo().getSupportedTransactionsIsolation())) {
if (!level.isEnabled())
continue;
isolationLevel.add(level.getTitle());
supportedLevels.add(level);
if (level.equals(defaultLevel)) {
isolationLevel.select(isolationLevel.getItemCount() - 1);
}
}
if (dataSource instanceof DBSObjectContainer) {
new SchemaReadJob((DBSObjectContainer) dataSource).schedule();
}
} else {
isolationLevel.setEnabled(false);
}
defaultSchema.setText(CommonUtils.notEmpty(conConfig.getBootstrap().getDefaultObjectName()));
keepAliveInterval.setSelection(conConfig.getKeepAliveInterval());
if (dataSourceDescriptor.getDescription() != null) {
descriptionText.setText(dataSourceDescriptor.getDescription());
}
activated = true;
}
} else {
if (eventsButton != null) {
eventsButton.setFont(getFont());
DataSourceDescriptor dataSource = getActiveDataSource();
for (DBPConnectionEventType eventType : dataSource.getConnectionConfiguration().getDeclaredEvents()) {
if (dataSource.getConnectionConfiguration().getEvent(eventType).isEnabled()) {
eventsButton.setFont(boldFont);
break;
}
}
}
// Default settings
savePasswordCheck.setSelection(true);
connectionTypeCombo.select(0);
autocommit.setSelection((connectionTypeCombo.getItem(0)).isAutocommit());
if (dataSourceFolder != null) {
connectionFolderCombo.select(dataSourceFolder);
} else {
connectionFolderCombo.select(0);
}
showSystemObjects.setSelection(true);
showUtilityObjects.setSelection(false);
readOnlyConnection.setSelection(false);
isolationLevel.setEnabled(false);
defaultSchema.setText("");
}
if (savePasswordCheck != null) {
//savePasswordCheck.setEnabled();
}
long features = wizard.getSelectedDriver().getDataSourceProvider().getFeatures();
for (FilterInfo filterInfo : filters) {
if (DBSCatalog.class.isAssignableFrom(filterInfo.type)) {
enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_CATALOGS) != 0);
} else if (DBSSchema.class.isAssignableFrom(filterInfo.type)) {
enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_SCHEMAS) != 0);
} else {
enableFilter(filterInfo, true);
}
}
filtersGroup.layout();
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class ConnectionWizard method getActiveDataSource.
@NotNull
public DataSourceDescriptor getActiveDataSource() {
DriverDescriptor driver = getSelectedDriver();
DataSourceDescriptor info = infoMap.get(driver);
if (info == null) {
DBPConnectionConfiguration connectionInfo = new DBPConnectionConfiguration();
info = new DataSourceDescriptor(getDataSourceRegistry(), DataSourceDescriptor.generateNewId(getSelectedDriver()), getSelectedDriver(), connectionInfo);
info.getConnectionConfiguration().setClientHomeId(driver.getDefaultClientHomeId());
infoMap.put(driver, info);
}
return info;
}
Aggregations