Search in sources :

Example 1 with PostgreDatabaseBackupInfo

use of org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo in project dbeaver by dbeaver.

the class PostgreBackupWizardPageObjects method saveState.

public void saveState() {
    super.saveState();
    List<PostgreDatabaseBackupInfo> objects = wizard.getSettings().getExportObjects();
    objects.clear();
    List<PostgreSchema> schemas = new ArrayList<>();
    List<PostgreTableBase> tables = new ArrayList<>();
    for (TableItem item : schemasTable.getItems()) {
        if (item.getChecked()) {
            PostgreSchema schema = (PostgreSchema) item.getData();
            Set<PostgreTableBase> checkedTables = checkedObjects.get(schema);
            // All tables checked
            if (!schemas.contains(schema)) {
                schemas.add(schema);
            }
            if (checkedTables != null) {
                // Only a few tables checked
                tables.addAll(checkedTables);
            }
        }
    }
    PostgreDatabaseBackupInfo info = new PostgreDatabaseBackupInfo(dataBase, schemas, tables);
    objects.add(info);
}
Also used : PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) PostgreDatabaseBackupInfo(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Example 2 with PostgreDatabaseBackupInfo

use of org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo in project dbeaver by serge-rider.

the class PostgreBackupWizardPageObjects method loadSettings.

private void loadSettings() {
    checkedObjects.clear();
    schemasTable.removeAll();
    tablesTable.removeAll();
    dataBase = null;
    boolean hasViews = false;
    Set<PostgreSchema> activeSchemas = new LinkedHashSet<>();
    for (PostgreDatabaseBackupInfo info : wizard.getSettings().getExportObjects()) {
        dataBase = info.getDatabase();
        if (!CommonUtils.isEmpty(info.getSchemas())) {
            activeSchemas.addAll(info.getSchemas());
        }
        if (!CommonUtils.isEmpty(info.getTables())) {
            for (PostgreTableBase table : info.getTables()) {
                PostgreTableContainer tableContainer = table.getContainer();
                if (!(tableContainer instanceof PostgreSchema)) {
                    continue;
                }
                PostgreSchema schema = (PostgreSchema) tableContainer;
                activeSchemas.add(schema);
                Set<PostgreTableBase> tables = checkedObjects.computeIfAbsent(schema, k -> new HashSet<>());
                tables.add(table);
                if (table.isView()) {
                    hasViews = true;
                }
            }
        }
    }
    if (hasViews) {
        wizard.getSettings().setShowViews(true);
        exportViewsCheck.setSelection(true);
    }
    if (dataBase != null) {
        boolean tablesLoaded = false;
        try {
            for (PostgreSchema schema : dataBase.getSchemas(new VoidProgressMonitor())) {
                if (schema.isSystem() || schema.isUtility()) {
                    continue;
                }
                TableItem item = new TableItem(schemasTable, SWT.NONE);
                item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
                item.setText(0, schema.getName());
                item.setData(schema);
                if (activeSchemas.contains(schema)) {
                    item.setChecked(true);
                    schemasTable.select(schemasTable.indexOf(item));
                    if (!tablesLoaded) {
                        loadTables(schema);
                        tablesLoaded = true;
                    }
                }
            }
        } catch (DBException e) {
            log.error(e);
        }
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema) PostgreDatabaseBackupInfo(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo) PostgreTableContainer(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableContainer)

Example 3 with PostgreDatabaseBackupInfo

use of org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo in project dbeaver by serge-rider.

the class PostgreBackupWizardPageObjects method saveState.

public void saveState() {
    super.saveState();
    List<PostgreDatabaseBackupInfo> objects = wizard.getSettings().getExportObjects();
    objects.clear();
    List<PostgreSchema> schemas = new ArrayList<>();
    List<PostgreTableBase> tables = new ArrayList<>();
    for (TableItem item : schemasTable.getItems()) {
        if (item.getChecked()) {
            PostgreSchema schema = (PostgreSchema) item.getData();
            Set<PostgreTableBase> checkedTables = checkedObjects.get(schema);
            // All tables checked
            if (!schemas.contains(schema)) {
                schemas.add(schema);
            }
            if (checkedTables != null) {
                // Only a few tables checked
                tables.addAll(checkedTables);
            }
        }
    }
    PostgreDatabaseBackupInfo info = new PostgreDatabaseBackupInfo(dataBase, schemas, tables);
    objects.add(info);
}
Also used : PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) PostgreDatabaseBackupInfo(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)

Example 4 with PostgreDatabaseBackupInfo

use of org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo in project dbeaver by dbeaver.

the class PostgreBackupWizardPageObjects method loadSettings.

private void loadSettings() {
    checkedObjects.clear();
    schemasTable.removeAll();
    tablesTable.removeAll();
    dataBase = null;
    boolean hasViews = false;
    Set<PostgreSchema> activeSchemas = new LinkedHashSet<>();
    for (PostgreDatabaseBackupInfo info : wizard.getSettings().getExportObjects()) {
        dataBase = info.getDatabase();
        if (!CommonUtils.isEmpty(info.getSchemas())) {
            activeSchemas.addAll(info.getSchemas());
        }
        if (!CommonUtils.isEmpty(info.getTables())) {
            for (PostgreTableBase table : info.getTables()) {
                PostgreTableContainer tableContainer = table.getContainer();
                if (!(tableContainer instanceof PostgreSchema)) {
                    continue;
                }
                PostgreSchema schema = (PostgreSchema) tableContainer;
                activeSchemas.add(schema);
                Set<PostgreTableBase> tables = checkedObjects.computeIfAbsent(schema, k -> new HashSet<>());
                tables.add(table);
                if (table.isView()) {
                    hasViews = true;
                }
            }
        }
    }
    if (hasViews) {
        wizard.getSettings().setShowViews(true);
        exportViewsCheck.setSelection(true);
    }
    if (dataBase != null) {
        boolean tablesLoaded = false;
        try {
            for (PostgreSchema schema : dataBase.getSchemas(new VoidProgressMonitor())) {
                if (schema.isSystem() || schema.isUtility()) {
                    continue;
                }
                TableItem item = new TableItem(schemasTable, SWT.NONE);
                item.setImage(DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
                item.setText(0, schema.getName());
                item.setData(schema);
                if (activeSchemas.contains(schema)) {
                    item.setChecked(true);
                    schemasTable.select(schemasTable.indexOf(item));
                    if (!tablesLoaded) {
                        loadTables(schema);
                        tablesLoaded = true;
                    }
                }
            }
        } catch (DBException e) {
            log.error(e);
        }
    }
}
Also used : DBException(org.jkiss.dbeaver.DBException) PostgreTableBase(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) PostgreSchema(org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema) PostgreDatabaseBackupInfo(org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo) PostgreTableContainer(org.jkiss.dbeaver.ext.postgresql.model.PostgreTableContainer)

Aggregations

PostgreSchema (org.jkiss.dbeaver.ext.postgresql.model.PostgreSchema)4 PostgreTableBase (org.jkiss.dbeaver.ext.postgresql.model.PostgreTableBase)4 PostgreDatabaseBackupInfo (org.jkiss.dbeaver.ext.postgresql.tasks.PostgreDatabaseBackupInfo)4 DBException (org.jkiss.dbeaver.DBException)2 PostgreTableContainer (org.jkiss.dbeaver.ext.postgresql.model.PostgreTableContainer)2 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)2