Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java')
-rw-r--r--plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java130
1 files changed, 65 insertions, 65 deletions
diff --git a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java
index a9869af0c62..d90e8e7aa2a 100644
--- a/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java
+++ b/plugins/org.eclipse.osee.framework.core.datastore/src/org/eclipse/osee/framework/core/datastore/schema/operations/BackupTableDataOperation.java
@@ -19,77 +19,77 @@ import org.eclipse.osee.framework.core.datastore.internal.Activator;
import org.eclipse.osee.framework.core.datastore.schema.data.SchemaData;
import org.eclipse.osee.framework.core.datastore.schema.data.TableElement;
import org.eclipse.osee.framework.core.operation.AbstractOperation;
-import org.eclipse.osee.framework.database.IOseeDatabaseServiceProvider;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
public class BackupTableDataOperation extends AbstractOperation {
- private final File backupDirectory;
- private final Set<String> schemas;
- private final Map<String, SchemaData> userSpecifiedConfig;
- private final Map<String, SchemaData> currentDatabaseConfig;
- private final IOseeDatabaseServiceProvider provider;
+ private final File backupDirectory;
+ private final Set<String> schemas;
+ private final Map<String, SchemaData> userSpecifiedConfig;
+ private final Map<String, SchemaData> currentDatabaseConfig;
+ private final IOseeDatabaseService databaseService;
- public BackupTableDataOperation(IOseeDatabaseServiceProvider provider, String backupDirPath, Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, Map<String, SchemaData> currentDatabaseConfig) {
- super("Backup Table Data", Activator.PLUGIN_ID);
- this.provider = provider;
- this.schemas = schemas;
- this.userSpecifiedConfig = userSpecifiedConfig;
- this.currentDatabaseConfig = currentDatabaseConfig;
- this.backupDirectory = new File("BackupDirectory");
- }
+ public BackupTableDataOperation(IOseeDatabaseService databaseService, String backupDirPath, Set<String> schemas, Map<String, SchemaData> userSpecifiedConfig, Map<String, SchemaData> currentDatabaseConfig) {
+ super("Backup Table Data", Activator.PLUGIN_ID);
+ this.databaseService = databaseService;
+ this.schemas = schemas;
+ this.userSpecifiedConfig = userSpecifiedConfig;
+ this.currentDatabaseConfig = currentDatabaseConfig;
+ this.backupDirectory = new File("BackupDirectory");
+ }
- @Override
- protected void doWork(IProgressMonitor monitor) throws Exception {
- Set<String> dataToBackup = getTablesToBackup();
- if (dataToBackup.size() > 0) {
- System.out.println(dataToBackup.toString().replaceAll(", ", "\n"));
- clearBackupDirectory();
- DatabaseDataExtractor dbDataExtractor = new DatabaseDataExtractor(provider, schemas, backupDirectory);
- Set<String> backupTables = dataToBackup;
- for (String backupTable : backupTables) {
- dbDataExtractor.addTableNameToExtract(backupTable);
- }
- doSubWork(dbDataExtractor, monitor, 0.90);
- dbDataExtractor.waitForWorkerThreads();
- }
- }
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ Set<String> dataToBackup = getTablesToBackup();
+ if (dataToBackup.size() > 0) {
+ System.out.println(dataToBackup.toString().replaceAll(", ", "\n"));
+ clearBackupDirectory();
+ DatabaseDataExtractor dbDataExtractor = new DatabaseDataExtractor(databaseService, schemas, backupDirectory);
+ Set<String> backupTables = dataToBackup;
+ for (String backupTable : backupTables) {
+ dbDataExtractor.addTableNameToExtract(backupTable);
+ }
+ doSubWork(dbDataExtractor, monitor, 0.90);
+ dbDataExtractor.waitForWorkerThreads();
+ }
+ }
- private Set<String> getTablesToBackup() {
- Set<String> backupTables = new TreeSet<String>();
- Set<String> userSchemas = userSpecifiedConfig.keySet();
- for (String key : userSchemas) {
- // Backup data only if data exists in the current database
- if (currentDatabaseConfig.containsKey(key)) {
- SchemaData schemaDataInDb = currentDatabaseConfig.get(key);
- Map<String, TableElement> currentDbTableMap = schemaDataInDb.getTableMap();
- Set<String> currentDbTableNames = currentDbTableMap.keySet();
+ private Set<String> getTablesToBackup() {
+ Set<String> backupTables = new TreeSet<String>();
+ Set<String> userSchemas = userSpecifiedConfig.keySet();
+ for (String key : userSchemas) {
+ // Backup data only if data exists in the current database
+ if (currentDatabaseConfig.containsKey(key)) {
+ SchemaData schemaDataInDb = currentDatabaseConfig.get(key);
+ Map<String, TableElement> currentDbTableMap = schemaDataInDb.getTableMap();
+ Set<String> currentDbTableNames = currentDbTableMap.keySet();
- SchemaData schemaData = userSpecifiedConfig.get(key);
- Set<String> tableNamesToBackup = schemaData.getTablesToBackup();
- for (String tableName : tableNamesToBackup) {
- // Check that table we want to backup exists in the database
- // before we add it to the list
- if (currentDbTableNames.contains(tableName)) {
- backupTables.add(tableName);
- } else {
- System.out.println("Table doesn't exist in Db. Unable to backup [" + tableName + "]");
- }
- }
- } else {
- System.out.println("Schema doesn't exist in Db. Unable to backup tables from schema [" + key + "]");
- }
- }
- return backupTables;
- }
+ SchemaData schemaData = userSpecifiedConfig.get(key);
+ Set<String> tableNamesToBackup = schemaData.getTablesToBackup();
+ for (String tableName : tableNamesToBackup) {
+ // Check that table we want to backup exists in the database
+ // before we add it to the list
+ if (currentDbTableNames.contains(tableName)) {
+ backupTables.add(tableName);
+ } else {
+ System.out.println("Table doesn't exist in Db. Unable to backup [" + tableName + "]");
+ }
+ }
+ } else {
+ System.out.println("Schema doesn't exist in Db. Unable to backup tables from schema [" + key + "]");
+ }
+ }
+ return backupTables;
+ }
- private void clearBackupDirectory() {
- if (backupDirectory != null && backupDirectory.exists() && backupDirectory.canWrite()) {
- File[] fileList = backupDirectory.listFiles();
- for (File fileToDelete : fileList) {
- fileToDelete.delete();
- }
- backupDirectory.delete();
- backupDirectory.mkdirs();
- }
- }
+ private void clearBackupDirectory() {
+ if (backupDirectory != null && backupDirectory.exists() && backupDirectory.canWrite()) {
+ File[] fileList = backupDirectory.listFiles();
+ for (File fileToDelete : fileList) {
+ fileToDelete.delete();
+ }
+ backupDirectory.delete();
+ backupDirectory.mkdirs();
+ }
+ }
} \ No newline at end of file

Back to the top