Skip to content

Commit

Permalink
Merge branch 'devel' into CB-5807-localize-backend-text
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisSinelnikov authored Dec 13, 2024
2 parents f5eec50 + 522620e commit 3d212a3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@

public class WebDataSourceRegistryProxy implements DBPDataSourceRegistry, DataSourcePersistentRegistry, DBPDataSourceRegistryCache {
private final DataSourceFilter dataSourceFilter;
private final DataSourceRegistry dataSourceRegistry;
private final DataSourceRegistry<?> dataSourceRegistry;

public WebDataSourceRegistryProxy(DataSourceRegistry dataSourceRegistry, DataSourceFilter filter) {
public WebDataSourceRegistryProxy(DataSourceRegistry<?> dataSourceRegistry, DataSourceFilter filter) {
this.dataSourceRegistry = dataSourceRegistry;
this.dataSourceFilter = filter;
}
Expand Down Expand Up @@ -113,6 +113,26 @@ public DBPDataSourceContainer createDataSource(@NotNull DBPDriver driver, @NotNu
return dataSourceRegistry.createDataSource(driver, connConfig);
}

@Override
public DBPDataSourceContainer createDataSource(
@NotNull String id,
@NotNull DBPDriver driver,
@NotNull DBPConnectionConfiguration connConfig
) {
return dataSourceRegistry.createDataSource(id, driver, connConfig);
}

@Override
public DBPDataSourceContainer createDataSource(
@NotNull DBPDataSourceConfigurationStorage dataSourceStorage,
@NotNull DBPDataSourceOrigin origin,
@NotNull String id,
@NotNull DBPDriver driver,
@NotNull DBPConnectionConfiguration configuration
) {
return dataSourceRegistry.createDataSource(dataSourceStorage, origin, id, driver, configuration);
}

@NotNull
@Override
public DBPDataSourceContainer createDataSource(@NotNull DBPDataSourceContainer source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jkiss.dbeaver.model.rm.RMController;
import org.jkiss.dbeaver.model.rm.RMProject;
import org.jkiss.dbeaver.model.task.DBTTaskManager;
import org.jkiss.dbeaver.registry.DataSourceRegistry;
import org.jkiss.dbeaver.registry.rm.DataSourceRegistryRM;
import org.jkiss.dbeaver.runtime.DBWorkbench;

Expand Down Expand Up @@ -84,11 +85,15 @@ public DBTTaskManager getTaskManager() {
@Override
protected DBPDataSourceRegistry createDataSourceRegistry() {
return new WebDataSourceRegistryProxy(
new DataSourceRegistryRM(this, getResourceController(), preferenceStore),
createRMRegistry(),
getDataSourceFilter()
);
}

protected DataSourceRegistry<?> createRMRegistry() {
return new DataSourceRegistryRM<>(this, getResourceController(), preferenceStore);
}

@NotNull
public DataSourceFilter getDataSourceFilter() {
return (ds) -> true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.nio.file.Path;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

public class WebSessionProjectImpl extends WebProjectImpl {
Expand Down Expand Up @@ -199,8 +200,8 @@ public synchronized boolean updateProjectDataSources(@NotNull List<String> dataS
.filter(Objects::nonNull)
.collect(Collectors.toMap(
DBPDataSourceContainer::getId,
ds -> new DataSourceDescriptor((DataSourceDescriptor) ds, ds.getRegistry())
));
Function.identity())
);
if (type == WSEventType.DATASOURCE_CREATED || type == WSEventType.DATASOURCE_UPDATED) {
registry.refreshConfig(dataSourceIds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private WebSessionProjectImpl createWebProject(RMProject project) throws DBExcep
if (project.isGlobal()) {
sessionProject = createGlobalProject(project);
} else {
sessionProject = new WebSessionProjectImpl(this, project, getProjectPath(project));
sessionProject = createSessionProject(project);
}
// do not load data sources for anonymous project
if (project.getType() == RMProjectType.USER && userContext.getUser() == null) {
Expand All @@ -329,6 +329,10 @@ private WebSessionProjectImpl createWebProject(RMProject project) throws DBExcep
return sessionProject;
}

protected WebSessionProjectImpl createSessionProject(@NotNull RMProject project) throws DBException {
return new WebSessionProjectImpl(this, project, getProjectPath(project));
}

@NotNull
protected Path getProjectPath(@NotNull RMProject project) throws DBException {
return RMUtils.getProjectPath(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ public boolean isUseSecretStorage() {
@NotNull
@Override
protected DBPDataSourceRegistry createDataSourceRegistry() {
return new DataSourceRegistry(this);
return new DataSourceRegistry<>(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,9 @@ public WebConnectionInfo updateConnection(
WebConnectionInfo connectionInfo = WebDataSourceUtils.getWebConnectionInfo(webSession, projectId, config.getConnectionId());
DBPDataSourceContainer dataSource = connectionInfo.getDataSourceContainer();
webSession.addInfoMessage("Update connection - " + WebServiceUtils.getConnectionContainerInfo(dataSource));
var oldDataSource = new DataSourceDescriptor((DataSourceDescriptor) dataSource, dataSource.getRegistry());

DataSourceDescriptor oldDataSource;
oldDataSource = dataSource.getRegistry().createDataSource(dataSource);
oldDataSource.setId(dataSource.getId());
if (!CommonUtils.isEmpty(config.getName())) {
dataSource.setName(config.getName());
}
Expand Down

0 comments on commit 3d212a3

Please sign in to comment.