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);
}
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);
}
}
}
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);
}
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);
}
}
}
Aggregations