Search in sources :

Example 11 with PostgreDatabase

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();
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) ActiveWizardDialog(org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) PostgreObject(org.jkiss.dbeaver.ext.postgresql.model.PostgreObject)

Example 12 with PostgreDatabase

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();
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with PostgreDatabase

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))));
    }
}
Also used : PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) SQLDatabasePersistAction(org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)

Example 14 with PostgreDatabase

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();
        }
    }
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) NativeToolWizardDialog(org.jkiss.dbeaver.tasks.ui.nativetool.NativeToolWizardDialog)

Example 15 with PostgreDatabase

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;
}
Also used : HashMap(java.util.HashMap) PostgreProcedure(org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure) PostgreDatabase(org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Aggregations

PostgreDatabase (org.jkiss.dbeaver.ext.postgresql.model.PostgreDatabase)25 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)12 PostgreSchema (org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)11 DBException (org.jkiss.dbeaver.DBException)8 PostgreProcedure (org.jkiss.dbeaver.ext.postgresql.model.PostgreProcedure)5 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 PostgreTableBase (org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase)4 NativeToolWizardDialog (org.jkiss.dbeaver.tasks.ui.nativetool.NativeToolWizardDialog)4 PostgreDataSource (org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource)3 LinkedHashMap (java.util.LinkedHashMap)2 PostgreObject (org.jkiss.dbeaver.ext.postgresql.model.PostgreObject)2 DBPPreferenceMap (org.jkiss.dbeaver.model.preferences.DBPPreferenceMap)2 ActiveWizardDialog (org.jkiss.dbeaver.ui.dialogs.ActiveWizardDialog)2 HashMap (java.util.HashMap)1 IContainer (org.eclipse.core.resources.IContainer)1 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)1 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)1 SQLDatabasePersistActionAtomic (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionAtomic)1 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)1