use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase in project dbeaver by dbeaver.
the class PostgreFDWConfigTool method execute.
@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
for (DBSObject object : objects) {
PostgreDatabase database;
if (object instanceof PostgreObject) {
database = ((PostgreObject) object).getDatabase();
} else {
continue;
}
ActiveWizardDialog dialog = new ActiveWizardDialog(window, new PostgreFDWConfigWizard(database));
dialog.setFinishButtonLabel("Install");
dialog.open();
}
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase in project dbeaver by serge-rider.
the class PostgreDatabaseBackupSettings method fillExportObjectsFromInput.
public void fillExportObjectsFromInput() {
Map<PostgreDatabase, PostgreDatabaseBackupInfo> objMap = new LinkedHashMap<>();
for (DBSObject object : getDatabaseObjects()) {
PostgreDatabase database = null;
PostgreSchema schema = null;
if (object instanceof PostgreDatabase) {
database = (PostgreDatabase) object;
} else if (object instanceof PostgreSchema) {
database = ((PostgreSchema) object).getDatabase();
schema = (PostgreSchema) object;
} else if (object instanceof PostgreTableBase) {
database = ((PostgreTableBase) object).getDatabase();
schema = ((PostgreTableBase) object).getSchema();
}
if (database == null) {
continue;
}
PostgreDatabaseBackupInfo info = objMap.computeIfAbsent(database, db -> new PostgreDatabaseBackupInfo(db, null, null));
if (schema != null) {
List<PostgreSchema> schemas = info.getSchemas();
if (schemas == null) {
schemas = new ArrayList<>();
info.setSchemas(schemas);
}
if (!schemas.contains(schema)) {
schemas.add(schema);
}
}
if (object instanceof PostgreTableBase) {
List<PostgreTableBase> tables = info.getTables();
if (tables == null) {
tables = new ArrayList<>();
info.setTables(tables);
}
tables.add((PostgreTableBase) object);
}
}
getExportObjects().addAll(objMap.values());
updateDataSourceContainer();
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase in project dbeaver by serge-rider.
the class PostgreDatabaseManager method generateAlterActions.
private void generateAlterActions(DBRProgressMonitor monitor, List<DBEPersistAction> actionList, ObjectChangeCommand command) throws DBException {
final PostgreDatabase database = command.getObject();
final String alterPrefix = "ALTER DATABASE " + DBUtils.getQuotedIdentifier(command.getObject()) + " ";
if (command.hasProperty("defaultTablespace")) {
actionList.add(new SQLDatabasePersistAction(alterPrefix + "SET TABLESPACE " + DBUtils.getQuotedIdentifier(database.getDefaultTablespace(monitor))));
}
if (command.hasProperty("defaultEncoding")) {
actionList.add(new SQLDatabasePersistAction(alterPrefix + "SET ENCODING " + DBUtils.getQuotedIdentifier(database.getDefaultEncoding(monitor))));
}
if (command.hasProperty("dBA")) {
actionList.add(new SQLDatabasePersistAction(alterPrefix + "OWNER TO " + DBUtils.getQuotedIdentifier(database.getDBA(monitor))));
}
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase in project dbeaver by serge-rider.
the class PostgreToolScript method execute.
@Override
public void execute(IWorkbenchWindow window, IWorkbenchPart activePart, Collection<DBSObject> objects) throws DBException {
for (DBSObject object : objects) {
if (object instanceof PostgreDatabase) {
NativeToolWizardDialog dialog = new NativeToolWizardDialog(window, new PostgreScriptExecuteWizard((PostgreDatabase) object));
dialog.open();
}
}
}
use of org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase in project dbeaver by dbeaver.
the class PostgreResolver method resolveContext.
@Override
public Map<String, Object> resolveContext(DBSObject databaseObject) {
HashMap<String, Object> context = new HashMap<String, Object>();
if (databaseObject instanceof PostgreProcedure) {
PostgreProcedure procedure = (PostgreProcedure) databaseObject;
context.put(DBGController.PROCEDURE_OID, procedure.getObjectId());
context.put(DBGController.PROCEDURE_NAME, procedure.getName());
PostgreSchema schema = procedure.getContainer();
if (schema != null) {
context.put(DBGController.SCHEMA_NAME, schema.getName());
}
PostgreDatabase database = procedure.getDatabase();
if (database != null) {
context.put(DBGController.DATABASE_NAME, database.getName());
}
}
return context;
}
Aggregations