use of org.jkiss.dbeaver.model.struct.DBSObjectFilter in project dbeaver by serge-rider.
the class DataSourceSerializerModern method parseDataSources.
@Override
public void parseDataSources(File configFile, DBPDataSourceConfigurationStorage configurationStorage, boolean refresh, DataSourceRegistry.ParseResults parseResults) throws IOException {
// Read secured creds file
File mdFolder = registry.getProject().getMetadataFolder(false);
if (mdFolder.exists()) {
File credFile = new File(mdFolder, DBPDataSourceRegistry.CREDENTIALS_CONFIG_FILE_PREFIX + configurationStorage.getConfigurationFileSuffix() + DBPDataSourceRegistry.CREDENTIALS_CONFIG_FILE_EXT);
if (credFile.exists()) {
try {
String credJson = loadConfigFile(credFile, true);
Map<String, Map<String, Map<String, String>>> res = CONFIG_GSON.fromJson(credJson, new TypeToken<Map<String, Map<String, Map<String, String>>>>() {
}.getType());
secureProperties.putAll(res);
} catch (Exception e) {
log.error("Error decrypting secure credentials", e);
}
}
}
boolean decryptProject = CommonUtils.toBoolean(registry.getProject().getProjectProperty(DBPProject.PROP_SECURE_PROJECT));
String configJson = loadConfigFile(configFile, decryptProject);
{
Map<String, Object> jsonMap = JSONUtils.parseMap(CONFIG_GSON, new StringReader(configJson));
// Folders
for (Map.Entry<String, Map<String, Object>> folderMap : JSONUtils.getNestedObjects(jsonMap, "folders")) {
String name = folderMap.getKey();
String description = JSONUtils.getObjectProperty(folderMap.getValue(), RegistryConstants.ATTR_DESCRIPTION);
String parentFolder = JSONUtils.getObjectProperty(folderMap.getValue(), RegistryConstants.ATTR_PARENT);
DataSourceFolder parent = parentFolder == null ? null : registry.findFolderByPath(parentFolder, true);
DataSourceFolder folder = parent == null ? registry.findFolderByPath(name, true) : parent.getChild(name);
if (folder == null) {
folder = new DataSourceFolder(registry, parent, name, description);
registry.addDataSourceFolder(folder);
} else {
folder.setDescription(description);
}
}
// Connection types
for (Map.Entry<String, Map<String, Object>> ctMap : JSONUtils.getNestedObjects(jsonMap, "connection-types")) {
String id = ctMap.getKey();
Map<String, Object> ctConfig = ctMap.getValue();
String name = JSONUtils.getObjectProperty(ctConfig, RegistryConstants.ATTR_NAME);
String description = JSONUtils.getObjectProperty(ctConfig, RegistryConstants.ATTR_DESCRIPTION);
String color = JSONUtils.getObjectProperty(ctConfig, RegistryConstants.ATTR_COLOR);
Boolean autoCommit = JSONUtils.getObjectProperty(ctConfig, "auto-commit");
Boolean confirmExecute = JSONUtils.getObjectProperty(ctConfig, "confirm-execute");
Boolean confirmDataChange = JSONUtils.getObjectProperty(ctConfig, "confirm-data-change");
DBPConnectionType ct = DBWorkbench.getPlatform().getDataSourceProviderRegistry().getConnectionType(id, null);
if (ct == null) {
ct = new DBPConnectionType(id, name, color, description, CommonUtils.toBoolean(autoCommit), CommonUtils.toBoolean(confirmExecute), CommonUtils.toBoolean(confirmDataChange));
DBWorkbench.getPlatform().getDataSourceProviderRegistry().addConnectionType(ct);
}
deserializeModifyPermissions(ctConfig, ct);
}
// Drivers
// TODO: add drivers deserialization
// Virtual models
Map<String, DBVModel> modelMap = new LinkedHashMap<>();
for (Map.Entry<String, Map<String, Object>> vmMap : JSONUtils.getNestedObjects(jsonMap, "virtual-models")) {
String id = vmMap.getKey();
DBVModel model = new DBVModel(id, vmMap.getValue());
modelMap.put(id, model);
}
// Network profiles
for (Map.Entry<String, Map<String, Object>> vmMap : JSONUtils.getNestedObjects(jsonMap, "network-profiles")) {
String profileId = vmMap.getKey();
Map<String, Object> profileMap = vmMap.getValue();
DBWNetworkProfile profile = new DBWNetworkProfile();
profile.setProfileName(profileId);
profile.setProfileName(profileId);
profile.setProperties(JSONUtils.deserializeStringMap(profileMap, "properties"));
for (Map.Entry<String, Map<String, Object>> handlerMap : JSONUtils.getNestedObjects(profileMap, "handlers")) {
DBWHandlerConfiguration configuration = parseNetworkHandlerConfig(null, profile, handlerMap);
if (configuration != null) {
profile.updateConfiguration(configuration);
}
}
registry.updateNetworkProfile(profile);
}
// Auth profiles
for (Map.Entry<String, Map<String, Object>> vmMap : JSONUtils.getNestedObjects(jsonMap, "auth-profiles")) {
String profileId = vmMap.getKey();
Map<String, Object> profileMap = vmMap.getValue();
DBAAuthProfile profile = new DBAAuthProfile();
profile.setProfileId(profileId);
profile.setProfileName(JSONUtils.getString(profileMap, RegistryConstants.ATTR_NAME));
profile.setAuthModelId(JSONUtils.getString(profileMap, RegistryConstants.ATTR_AUTH_MODEL));
profile.setSavePassword(JSONUtils.getBoolean(profileMap, RegistryConstants.ATTR_SAVE_PASSWORD));
SecureCredentials authCreds = readSecuredCredentials(null, profile, null);
profile.setUserName(authCreds.getUserName());
profile.setUserPassword(authCreds.getUserPassword());
profile.setProperties(authCreds.getProperties());
registry.updateAuthProfile(profile);
}
// Connections
for (Map.Entry<String, Map<String, Object>> conMap : JSONUtils.getNestedObjects(jsonMap, "connections")) {
Map<String, Object> conObject = conMap.getValue();
// Primary settings
String id = conMap.getKey();
String dsProviderID = CommonUtils.toString(conObject.get(RegistryConstants.ATTR_PROVIDER));
if (CommonUtils.isEmpty(dsProviderID)) {
log.warn("Empty datasource provider for datasource '" + id + "'");
continue;
}
DataSourceProviderDescriptor provider = DataSourceProviderRegistry.getInstance().getDataSourceProvider(dsProviderID);
if (provider == null) {
log.warn("Can't find datasource provider " + dsProviderID + " for datasource '" + id + "'");
provider = (DataSourceProviderDescriptor) DataSourceProviderRegistry.getInstance().makeFakeProvider(dsProviderID);
}
String driverId = CommonUtils.toString(conObject.get(RegistryConstants.ATTR_DRIVER));
DriverDescriptor driver = provider.getDriver(driverId);
if (driver == null) {
log.warn("Can't find driver " + driverId + " in datasource provider " + provider.getId() + " for datasource '" + id + "'. Create new driver");
driver = provider.createDriver(driverId);
driver.setName(driverId);
driver.setDescription("Missing driver " + driverId);
driver.setDriverClassName("java.sql.Driver");
driver.setTemporary(true);
provider.addDriver(driver);
}
DataSourceDescriptor dataSource = registry.getDataSource(id);
boolean newDataSource = (dataSource == null);
if (newDataSource) {
DBPDataSourceOrigin origin;
Map<String, Object> originProperties = JSONUtils.deserializeProperties(conObject, TAG_ORIGIN);
if (CommonUtils.isEmpty(originProperties) || !originProperties.containsKey(ATTR_ORIGIN_TYPE)) {
origin = DataSourceOriginLocal.INSTANCE;
} else {
String originID = CommonUtils.toString(originProperties.remove(ATTR_ORIGIN_TYPE));
origin = new DataSourceOriginLazy(originID, originProperties);
}
dataSource = new DataSourceDescriptor(registry, configurationStorage, origin, id, driver, new DBPConnectionConfiguration());
} else {
// Clean settings - they have to be loaded later by parser
dataSource.getConnectionConfiguration().setProperties(Collections.emptyMap());
dataSource.getConnectionConfiguration().setHandlers(Collections.emptyList());
dataSource.clearFilters();
}
dataSource.setName(JSONUtils.getString(conObject, RegistryConstants.ATTR_NAME));
dataSource.setDescription(JSONUtils.getString(conObject, RegistryConstants.TAG_DESCRIPTION));
dataSource.setSavePassword(JSONUtils.getBoolean(conObject, RegistryConstants.ATTR_SAVE_PASSWORD));
dataSource.setTemplate(JSONUtils.getBoolean(conObject, RegistryConstants.ATTR_TEMPLATE));
DataSourceNavigatorSettings navSettings = dataSource.getNavigatorSettings();
navSettings.setShowSystemObjects(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_SHOW_SYSTEM_OBJECTS));
navSettings.setShowUtilityObjects(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_SHOW_UTIL_OBJECTS));
navSettings.setShowOnlyEntities(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_SHOW_ONLY_ENTITIES));
navSettings.setHideFolders(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_HIDE_FOLDERS));
navSettings.setHideSchemas(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_HIDE_SCHEMAS));
navSettings.setHideVirtualModel(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_HIDE_VIRTUAL));
navSettings.setMergeEntities(JSONUtils.getBoolean(conObject, DataSourceSerializerModern.ATTR_NAVIGATOR_MERGE_ENTITIES));
dataSource.setConnectionReadOnly(JSONUtils.getBoolean(conObject, RegistryConstants.ATTR_READ_ONLY));
final String folderPath = JSONUtils.getString(conObject, RegistryConstants.ATTR_FOLDER);
if (folderPath != null) {
dataSource.setFolder(registry.findFolderByPath(folderPath, true));
}
dataSource.setLockPasswordHash(CommonUtils.toString(conObject.get(RegistryConstants.ATTR_LOCK_PASSWORD)));
// Connection settings
{
Map<String, Object> cfgObject = JSONUtils.getObject(conObject, "configuration");
DBPConnectionConfiguration config = dataSource.getConnectionConfiguration();
config.setHostName(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_HOST));
config.setHostPort(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_PORT));
config.setServerName(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_SERVER));
config.setDatabaseName(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_DATABASE));
config.setUrl(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_URL));
if (!passwordReadCanceled) {
final SecureCredentials creds = readSecuredCredentials(dataSource, null, null);
config.setUserName(creds.getUserName());
if (dataSource.isSavePassword()) {
config.setUserPassword(creds.getUserPassword());
}
}
{
// Still try to read credentials directly from configuration (#6564)
String userName = JSONUtils.getString(cfgObject, RegistryConstants.ATTR_USER);
if (!CommonUtils.isEmpty(userName))
config.setUserName(userName);
String userPassword = JSONUtils.getString(cfgObject, RegistryConstants.ATTR_PASSWORD);
if (!CommonUtils.isEmpty(userPassword))
config.setUserPassword(userPassword);
}
config.setClientHomeId(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_HOME));
config.setConfigProfileName(JSONUtils.getString(cfgObject, "config-profile"));
config.setConnectionType(DataSourceProviderRegistry.getInstance().getConnectionType(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_TYPE), DBPConnectionType.DEFAULT_TYPE));
String colorValue = JSONUtils.getString(cfgObject, RegistryConstants.ATTR_COLOR);
if (!CommonUtils.isEmpty(colorValue)) {
config.setConnectionColor(colorValue);
}
int keepAlive = JSONUtils.getInteger(cfgObject, RegistryConstants.ATTR_KEEP_ALIVE);
if (keepAlive > 0) {
config.setKeepAliveInterval(keepAlive);
}
config.setProperties(JSONUtils.deserializeStringMap(cfgObject, RegistryConstants.TAG_PROPERTIES));
config.setProviderProperties(JSONUtils.deserializeStringMap(cfgObject, RegistryConstants.TAG_PROVIDER_PROPERTIES));
config.setAuthModelId(JSONUtils.getString(cfgObject, RegistryConstants.ATTR_AUTH_MODEL));
config.setAuthProperties(JSONUtils.deserializeStringMapOrNull(cfgObject, "auth-properties"));
// Events
for (Map.Entry<String, Map<String, Object>> eventObject : JSONUtils.getNestedObjects(cfgObject, RegistryConstants.TAG_EVENTS)) {
DBPConnectionEventType eventType = CommonUtils.valueOf(DBPConnectionEventType.class, eventObject.getKey(), DBPConnectionEventType.BEFORE_CONNECT);
Map<String, Object> eventCfg = eventObject.getValue();
DBRShellCommand command = new DBRShellCommand("");
command.setEnabled(JSONUtils.getBoolean(eventCfg, RegistryConstants.ATTR_ENABLED));
command.setShowProcessPanel(JSONUtils.getBoolean(eventCfg, RegistryConstants.ATTR_SHOW_PANEL));
command.setWaitProcessFinish(JSONUtils.getBoolean(eventCfg, RegistryConstants.ATTR_WAIT_PROCESS));
if (command.isWaitProcessFinish()) {
command.setWaitProcessTimeoutMs(JSONUtils.getInteger(eventCfg, RegistryConstants.ATTR_WAIT_PROCESS_TIMEOUT));
}
command.setTerminateAtDisconnect(JSONUtils.getBoolean(eventCfg, RegistryConstants.ATTR_TERMINATE_AT_DISCONNECT));
command.setPauseAfterExecute(JSONUtils.getInteger(eventCfg, RegistryConstants.ATTR_PAUSE_AFTER_EXECUTE));
command.setWorkingDirectory(JSONUtils.getString(eventCfg, RegistryConstants.ATTR_WORKING_DIRECTORY));
command.setCommand(JSONUtils.getString(eventCfg, RegistryConstants.ATTR_COMMAND));
config.setEvent(eventType, command);
}
// Handlers
for (Map.Entry<String, Map<String, Object>> handlerObject : JSONUtils.getNestedObjects(cfgObject, RegistryConstants.TAG_HANDLERS)) {
DBWHandlerConfiguration configuration = parseNetworkHandlerConfig(dataSource, null, handlerObject);
if (configuration != null) {
dataSource.getConnectionConfiguration().updateHandler(configuration);
}
}
// Bootstrap
Map<String, Object> bootstrapCfg = JSONUtils.getObject(cfgObject, RegistryConstants.TAG_BOOTSTRAP);
DBPConnectionBootstrap bootstrap = config.getBootstrap();
if (bootstrapCfg.containsKey(RegistryConstants.ATTR_AUTOCOMMIT)) {
bootstrap.setDefaultAutoCommit(JSONUtils.getBoolean(bootstrapCfg, RegistryConstants.ATTR_AUTOCOMMIT));
}
if (bootstrapCfg.containsKey(RegistryConstants.ATTR_TXN_ISOLATION)) {
bootstrap.setDefaultTransactionIsolation(JSONUtils.getInteger(bootstrapCfg, RegistryConstants.ATTR_TXN_ISOLATION));
}
bootstrap.setDefaultCatalogName(JSONUtils.getString(bootstrapCfg, RegistryConstants.ATTR_DEFAULT_CATALOG));
bootstrap.setDefaultSchemaName(JSONUtils.getString(bootstrapCfg, RegistryConstants.ATTR_DEFAULT_SCHEMA));
String defObjectName = JSONUtils.getString(bootstrapCfg, RegistryConstants.ATTR_DEFAULT_OBJECT);
if (!CommonUtils.isEmpty(defObjectName) && CommonUtils.isEmpty(bootstrap.getDefaultSchemaName())) {
bootstrap.setDefaultSchemaName(JSONUtils.getString(bootstrapCfg, defObjectName));
}
if (bootstrapCfg.containsKey(RegistryConstants.ATTR_IGNORE_ERRORS)) {
bootstrap.setIgnoreErrors(JSONUtils.getBoolean(bootstrapCfg, RegistryConstants.ATTR_IGNORE_ERRORS));
}
bootstrap.setInitQueries(JSONUtils.deserializeStringList(bootstrapCfg, RegistryConstants.TAG_QUERY));
}
// Permissions
{
deserializeModifyPermissions(conObject, dataSource);
}
// Filters
for (Map<String, Object> filterCfg : JSONUtils.getObjectList(conObject, RegistryConstants.TAG_FILTERS)) {
String typeName = JSONUtils.getString(filterCfg, RegistryConstants.ATTR_TYPE);
String objectID = JSONUtils.getString(filterCfg, RegistryConstants.ATTR_ID);
if (!CommonUtils.isEmpty(typeName)) {
DBSObjectFilter filter = readObjectFiler(filterCfg);
dataSource.updateObjectFilter(typeName, objectID, filter);
}
}
// Preferences
dataSource.getPreferenceStore().getProperties().putAll(JSONUtils.deserializeStringMap(conObject, RegistryConstants.TAG_CUSTOM_PROPERTIES));
// Virtual model
String vmID = CommonUtils.toString(conObject.get("virtual-model-id"), id);
DBVModel dbvModel = modelMap.get(vmID);
if (dbvModel != null) {
dataSource.setVirtualModel(dbvModel);
}
// Add to the list
if (newDataSource) {
registry.addDataSourceToList(dataSource);
parseResults.addedDataSources.add(dataSource);
} else {
parseResults.updatedDataSources.add(dataSource);
}
}
// Saved filters
for (Map<String, Object> ctMap : JSONUtils.getObjectList(jsonMap, "saved-filters")) {
DBSObjectFilter filter = readObjectFiler(ctMap);
registry.addSavedFilter(filter);
}
}
}
use of org.jkiss.dbeaver.model.struct.DBSObjectFilter in project dbeaver by serge-rider.
the class EditObjectFilterDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
getShell().setText(NLS.bind(UINavigatorMessages.dialog_filter_title, objectTitle));
// getShell().setImage(DBIcon.EVENT.getImage());
Composite composite = (Composite) super.createDialogArea(parent);
Composite topPanel = UIUtils.createPlaceholder(composite, globalFilter ? 1 : 2);
topPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
enableButton = UIUtils.createCheckbox(topPanel, UIMessages.button_enable, false);
enableButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
filter.setEnabled(enableButton.getSelection());
enableFiltersContent();
}
});
enableButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
enableButton.setSelection(filter.isEnabled());
if (!globalFilter) {
Link globalLink = UIUtils.createLink(topPanel, UINavigatorMessages.dialog_filter_global_link, new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setReturnCode(SHOW_GLOBAL_FILTERS_ID);
close();
}
});
globalLink.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
}
blockControl = UIUtils.createPlaceholder(composite, 1);
blockControl.setLayoutData(new GridData(GridData.FILL_BOTH));
includeTable = StringEditorTable.createEditableList(blockControl, UINavigatorMessages.dialog_filter_list_include, filter.getInclude(), null, null);
excludeTable = StringEditorTable.createEditableList(blockControl, UINavigatorMessages.dialog_filter_list_exclude, filter.getExclude(), null, null);
UIUtils.createInfoLabel(blockControl, UINavigatorMessages.dialog_filter_hint_text);
{
Group sfGroup = UIUtils.createControlGroup(composite, UINavigatorMessages.dialog_filter_save_label, 4, GridData.FILL_HORIZONTAL, 0);
namesCombo = UIUtils.createLabelCombo(sfGroup, UINavigatorMessages.dialog_filter_name_label, SWT.DROP_DOWN);
namesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
namesCombo.add(NULL_FILTER_NAME);
List<String> sfNames = new ArrayList<>();
for (DBSObjectFilter sf : dsRegistry.getSavedFilters()) {
sfNames.add(sf.getName());
}
Collections.sort(sfNames);
for (String sfName : sfNames) {
namesCombo.add(sfName);
}
namesCombo.setText(CommonUtils.notEmpty(filter.getName()));
namesCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
changeSavedFilter();
}
});
Button saveButton = UIUtils.createPushButton(sfGroup, UINavigatorMessages.dialog_filter_save_button, null);
saveButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
namesCombo.add(namesCombo.getText());
saveConfigurations();
}
});
Button removeButton = UIUtils.createPushButton(sfGroup, UINavigatorMessages.dialog_filter_remove_button, null);
removeButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dsRegistry.removeSavedFilter(namesCombo.getText());
namesCombo.remove(namesCombo.getText());
namesCombo.setText(NULL_FILTER_NAME);
}
});
}
enableFiltersContent();
return composite;
}
use of org.jkiss.dbeaver.model.struct.DBSObjectFilter in project dbeaver by serge-rider.
the class NavigatorHandlerFilterClear method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final ISelection selection = HandlerUtil.getCurrentSelection(event);
DBNNode node = NavigatorUtils.getSelectedNode(selection);
if (node instanceof DBNDatabaseItem) {
node = node.getParentNode();
}
if (node instanceof DBNDatabaseFolder) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
folder.setNodeFilter(itemsMeta, new DBSObjectFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singleton(folder));
}
}
return null;
}
use of org.jkiss.dbeaver.model.struct.DBSObjectFilter in project dbeaver by serge-rider.
the class NavigatorHandlerFilterConfig method configureFilters.
public static void configureFilters(Shell shell, DBNNode node) {
final DBNDatabaseFolder folder = (DBNDatabaseFolder) node;
DBXTreeItem itemsMeta = folder.getItemsMeta();
if (itemsMeta != null) {
DBSObjectFilter objectFilter = folder.getNodeFilter(itemsMeta, true);
if (objectFilter == null) {
objectFilter = new DBSObjectFilter();
}
final DBPDataSourceRegistry dsRegistry = folder.getOwnerProject().getDataSourceRegistry();
final boolean globalFilter = folder.getValueObject() instanceof DBPDataSource;
String parentName = "?";
if (folder.getValueObject() instanceof DBSObject) {
parentName = ((DBSObject) folder.getValueObject()).getName();
}
EditObjectFilterDialog dialog = new EditObjectFilterDialog(shell, dsRegistry, globalFilter ? "All " + node.getNodeType() : node.getNodeType() + " of " + parentName, objectFilter, globalFilter);
switch(dialog.open()) {
case IDialogConstants.OK_ID:
folder.setNodeFilter(itemsMeta, dialog.getFilter());
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
break;
case EditObjectFilterDialog.SHOW_GLOBAL_FILTERS_ID:
objectFilter = folder.getDataSource().getContainer().getObjectFilter(folder.getChildrenClass(), null, true);
dialog = new EditObjectFilterDialog(shell, dsRegistry, "All " + node.getNodeType(), objectFilter != null ? objectFilter : new DBSObjectFilter(), true);
if (dialog.open() == IDialogConstants.OK_ID) {
// Set global filter
folder.getDataSource().getContainer().setObjectFilter(folder.getChildrenClass(), null, dialog.getFilter());
folder.getDataSource().getContainer().persistConfiguration();
NavigatorHandlerRefresh.refreshNavigator(Collections.singletonList(folder));
}
break;
}
}
}
use of org.jkiss.dbeaver.model.struct.DBSObjectFilter in project dbeaver by serge-rider.
the class DataSourceSerializerLegacy method saveDataSources.
@Override
public void saveDataSources(DBRProgressMonitor monitor, DBPDataSourceConfigurationStorage configurationStorage, List<DataSourceDescriptor> localDataSources, File configFile) throws IOException {
// Save in temp memory to be safe (any error during direct write will corrupt configuration)
ByteArrayOutputStream tempStream = new ByteArrayOutputStream(10000);
try {
XMLBuilder xml = new XMLBuilder(tempStream, GeneralUtils.UTF8_ENCODING);
xml.setButify(true);
try (XMLBuilder.Element el1 = xml.startElement("data-sources")) {
if (configurationStorage.isDefault()) {
// Folders (only for default storage)
for (DataSourceFolder folder : registry.getAllFolders()) {
saveFolder(xml, folder);
}
}
// Datasources
for (DataSourceDescriptor dataSource : localDataSources) {
// Skip temporary
if (!dataSource.isDetached()) {
saveDataSource(xml, dataSource);
}
}
// Filters
if (configurationStorage.isDefault()) {
try (XMLBuilder.Element ignored = xml.startElement(RegistryConstants.TAG_FILTERS)) {
for (DBSObjectFilter cf : registry.getSavedFilters()) {
if (!cf.isEmpty()) {
saveObjectFiler(xml, null, null, cf);
}
}
}
}
}
xml.flush();
} catch (IOException ex) {
log.error("IO error while saving datasources xml", ex);
}
IOUtils.writeFileFromBuffer(configFile, tempStream.toByteArray());
}
Aggregations