mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
CB-1240 Object rename fix
This commit is contained in:
+11
-6
@@ -227,11 +227,7 @@ public class WebServiceNavigator implements DBWServiceNavigator {
|
||||
Map<String, Object> options = new LinkedHashMap<>();
|
||||
for (Map.Entry<DBNDatabaseNode, DBEObjectMaker> ne : nodes.entrySet()) {
|
||||
DBSObject object = ne.getKey().getObject();
|
||||
DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true);
|
||||
if (executionContext == null) {
|
||||
// It may happen in case of lazy context initialization
|
||||
executionContext = DBUtils.getDefaultContext(object.getDataSource(), true);
|
||||
}
|
||||
DBCExecutionContext executionContext = getCommandExecutionContext(object);
|
||||
DBECommandContext commandContext = new WebCommandContext(executionContext, false);
|
||||
ne.getValue().deleteObject(commandContext, object, options);
|
||||
commandContext.saveChanges(session.getProgressMonitor(), options);
|
||||
@@ -250,7 +246,7 @@ public class WebServiceNavigator implements DBWServiceNavigator {
|
||||
DBEObjectRenamer objectRenamer = DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(
|
||||
object.getClass(), DBEObjectRenamer.class);
|
||||
if (objectRenamer != null) {
|
||||
DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true);
|
||||
DBCExecutionContext executionContext = getCommandExecutionContext(object);
|
||||
Map<String, Object> options = new LinkedHashMap<>();
|
||||
DBECommandContext commandContext = new WebCommandContext(executionContext, false);
|
||||
objectRenamer.renameObject(commandContext, object, options, newName);
|
||||
@@ -262,4 +258,13 @@ public class WebServiceNavigator implements DBWServiceNavigator {
|
||||
throw new DBException("Node " + node.getNodeItemPath() + " rename is not supported");
|
||||
}
|
||||
|
||||
public DBCExecutionContext getCommandExecutionContext(DBSObject object) {
|
||||
DBCExecutionContext executionContext = DBUtils.getDefaultContext(object, true);
|
||||
if (executionContext == null) {
|
||||
// It may happen in case of lazy context initialization
|
||||
executionContext = DBUtils.getDefaultContext(object.getDataSource(), true);
|
||||
}
|
||||
return executionContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user