Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrbrooks2010-09-24 12:39:16 -0400
committerRyan D. Brooks2010-09-24 12:39:16 -0400
commit9c77a3d397edd7ce707e0299a892b521c09ebc2d (patch)
tree3fb5e0f70858d6d129602aee36db0211cc862749 /plugins
parent8885710c96fd5a85058b3103cfd081169dfeea76 (diff)
downloadorg.eclipse.osee-9c77a3d397edd7ce707e0299a892b521c09ebc2d.tar.gz
org.eclipse.osee-9c77a3d397edd7ce707e0299a892b521c09ebc2d.tar.xz
org.eclipse.osee-9c77a3d397edd7ce707e0299a892b521c09ebc2d.zip
feature: Add server command for purging deleted branches
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java4
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java50
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeDeletedBranches.java46
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java9
-rw-r--r--plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/branch/BranchCommands.java9
7 files changed, 74 insertions, 48 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.branch.management/META-INF/MANIFEST.MF
index 607d0eda63..f6f1646f3b 100644
--- a/plugins/org.eclipse.osee.framework.branch.management/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.branch.management/META-INF/MANIFEST.MF
@@ -39,7 +39,8 @@ Import-Package: org.eclipse.core.runtime,
org.osgi.util.tracker
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.osee.framework.branch.management,
- org.eclipse.osee.framework.branch.management.commit
+ org.eclipse.osee.framework.branch.management.commit,
+ org.eclipse.osee.framework.branch.management.purge
Service-Component: OSGI-INF/exchange.provider.xml,
OSGI-INF/locator.provider.exchange.xml
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
index 556f00c020..1c0ebd2605 100644
--- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java
@@ -146,8 +146,8 @@ public class OseeBranchService implements IOseeBranchService {
@Override
public IOperation purge(IProgressMonitor monitor, PurgeBranchRequest request) throws OseeCoreException {
BranchCache branchCache = cachingService.getOseeCachingService().getBranchCache();
- return new PurgeBranchOperation(branchCache.getById(request.getBranchId()), cachingService,
- oseeDatabaseProvider.getOseeDatabaseService());
+ return new PurgeBranchOperation(branchCache.getById(request.getBranchId()),
+ cachingService.getOseeCachingService(), oseeDatabaseProvider.getOseeDatabaseService());
}
@Override
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java
index 267fb70a67..c32fbfb72a 100644
--- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java
@@ -20,7 +20,7 @@ import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.services.IOseeCachingServiceProvider;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.eclipse.osee.framework.database.core.AbstractDbTxOperation;
import org.eclipse.osee.framework.database.core.IOseeStatement;
@@ -34,36 +34,26 @@ import org.eclipse.osee.framework.database.core.OseeConnection;
*/
public class PurgeBranchOperation extends AbstractDbTxOperation {
private static final String COUNT_CHILD_BRANCHES = "select count(1) from osee_branch WHERE parent_branch_id = ?";
-
private static final String SELECT_DELETABLE_GAMMAS =
"select txs1.gamma_id from %s txs1 where txs1.branch_id = ? AND txs1.transaction_id <> ? AND NOT EXISTS (SELECT 1 FROM osee_txs txs2 WHERE txs1.gamma_id = txs2.gamma_id AND txs1.branch_id <> txs2.branch_id) AND NOT EXISTS (SELECT 1 FROM osee_txs_archived txs3 WHERE txs1.gamma_id = txs3.gamma_id AND txs1.branch_id <> txs3.branch_id)";
-
private static final String SELECT_DELETABLE_TXS_REMOVED_GAMMAS =
"select txs1.rem_gamma_id from osee_removed_txs txs1, osee_tx_details txd1 where txd1.branch_id = ? AND txs1.transaction_id <> ? AND txs1.transaction_id = txd1.transaction_id AND NOT EXISTS (SELECT 1 FROM osee_txs txs2 WHERE txs1.rem_gamma_id = txs2.gamma_id AND txd1.branch_id <> txs2.branch_id) AND NOT EXISTS (SELECT 1 FROM osee_txs_archived txs3 WHERE txs1.rem_gamma_id = txs3.gamma_id AND txd1.branch_id <> txs3.branch_id)";
-
- public static final String TEST_TXS = "select count(1) from osee_txs where transaction_id = ?";
- public static final String TEST_MERGE =
- "select count(1) from osee_merge where merge_branch_id = ? and source_branch_id=?";
private static final String PURGE_GAMMAS = "delete from %s where gamma_id = ?";
-
private static final String DELETE_FROM_BRANCH_TABLE = "delete from osee_branch where branch_id = ?";
private static final String DELETE_FROM_MERGE =
"delete from osee_merge where merge_branch_id = ? and source_branch_id=?";
private static final String DELETE_FROM_CONFLICT = "delete from osee_conflict where merge_branch_id = ?";
private static final String DELETE_FROM_TX_DETAILS = "delete from osee_tx_details where branch_id = ?";
- public static final String SELECT_ADDRESSING_BY_BRANCH =
- "select transaction_id, gamma_id from %s where branch_id = ?";
-
private final Branch branch;
private final List<Object[]> deleteableGammas = new ArrayList<Object[]>();
private OseeConnection connection;
private IProgressMonitor monitor;
- private String sourceTableName;
- private final IOseeCachingServiceProvider cachingService;
+ private final String sourceTableName;
+ private final IOseeCachingService cachingService;
private final IOseeDatabaseService databaseService;
- public PurgeBranchOperation(Branch branch, IOseeCachingServiceProvider cachingService, IOseeDatabaseService databaseService) {
+ public PurgeBranchOperation(Branch branch, IOseeCachingService cachingService, IOseeDatabaseService databaseService) {
super(databaseService, String.format("Purge Branch: [(%s)-%s]", branch.getId(), branch.getShortName()),
Activator.PLUGIN_ID);
this.branch = branch;
@@ -81,13 +71,6 @@ public class PurgeBranchOperation extends AbstractDbTxOperation {
throw new OseeArgumentException("Unable to purge a branch containing children: branchId[%s]", branch.getId());
}
- boolean isAddressingArchived =
- databaseService.runPreparedQueryFetchObject(0, TEST_TXS, branch.getBaseTransaction().getId()) == 0;
- if (isAddressingArchived) {
- sourceTableName = "osee_txs_archived";
- } else {
- sourceTableName = "osee_txs";
- }
monitor.worked(calculateWork(0.05));
findDeleteableGammas(SELECT_DELETABLE_TXS_REMOVED_GAMMAS, 0.10);
@@ -97,13 +80,14 @@ public class PurgeBranchOperation extends AbstractDbTxOperation {
purgeGammas("osee_attribute", 0.10);
purgeGammas("osee_relation_link", 0.10);
- purgeAddressing(0.20);
+ String sql = String.format("delete from %s where branch_id = ?", sourceTableName);
+ purgeFromTable(sourceTableName, sql, 0.20, branch.getId());
purgeFromTable("Tx Details", DELETE_FROM_TX_DETAILS, 0.09, branch.getId());
purgeFromTable("Conflict", DELETE_FROM_CONFLICT, 0.01, branch.getId());
purgeFromTable("Merge", DELETE_FROM_MERGE, 0.01, branch.getId(), branch.getParentBranch().getId());
purgeFromTable("Branch", DELETE_FROM_BRANCH_TABLE, 0.01, branch.getId());
- BranchCache branchCache = cachingService.getOseeCachingService().getBranchCache();
+ BranchCache branchCache = cachingService.getBranchCache();
branch.setStorageState(StorageState.PURGED);
branchCache.storeItems(branch);
branchCache.decache(branch);
@@ -138,24 +122,4 @@ public class PurgeBranchOperation extends AbstractDbTxOperation {
monitor.worked(calculateWork(percentage));
}
}
-
- private void purgeAddressing(double percentage) throws OseeCoreException {
- monitor.setTaskName("Purge txs addressing");
- IOseeStatement chStmt = databaseService.getStatement(connection);
- List<Object[]> addressing = new ArrayList<Object[]>();
- String sql = String.format(SELECT_ADDRESSING_BY_BRANCH, sourceTableName);
-
- try {
- chStmt.runPreparedQuery(10000, sql, branch.getId());
- while (chStmt.next()) {
- addressing.add(new Object[] {chStmt.getInt("transaction_id"), chStmt.getLong("gamma_id")});
- }
- } finally {
- chStmt.close();
- }
-
- sql = String.format("delete from %s where transaction_id = ? and gamma_id = ?", sourceTableName);
- databaseService.runBatchUpdate(connection, sql, addressing);
- monitor.worked(calculateWork(percentage));
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeDeletedBranches.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeDeletedBranches.java
new file mode 100644
index 0000000000..a4e72da21b
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeDeletedBranches.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.branch.management.purge;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.branch.management.internal.Activator;
+import org.eclipse.osee.framework.core.enums.BranchArchivedState;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.model.cache.BranchCache;
+import org.eclipse.osee.framework.core.model.cache.BranchFilter;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+
+public class PurgeDeletedBranches extends AbstractOperation {
+ private final IOseeCachingService cachingService;
+ private final IOseeDatabaseService databaseService;
+
+ public PurgeDeletedBranches(IOseeCachingService cachingService, IOseeDatabaseService databaseService) {
+ super("Purge Deleted Branches", Activator.PLUGIN_ID);
+ this.cachingService = cachingService;
+ this.databaseService = databaseService;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws Exception {
+ BranchFilter branchFilter = new BranchFilter(BranchArchivedState.ARCHIVED, BranchType.WORKING);
+ branchFilter.setBranchStates(BranchState.DELETED);
+ BranchCache branchCache = cachingService.getBranchCache();
+
+ for (Branch branch : branchCache.getBranches(branchFilter)) {
+ Operations.executeWork(new PurgeBranchOperation(branch, cachingService, databaseService), monitor);
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.server.admin/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.server.admin/META-INF/MANIFEST.MF
index a2fb185af7..f07c2aaca4 100644
--- a/plugins/org.eclipse.osee.framework.server.admin/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.server.admin/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Import-Package: org.eclipse.core.runtime,
org.eclipse.core.runtime.jobs,
org.eclipse.equinox.app,
org.eclipse.osee.framework.branch.management,
+ org.eclipse.osee.framework.branch.management.purge,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.datastore,
org.eclipse.osee.framework.core.enums,
diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java
index 99eca51973..30f7435a56 100644
--- a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java
+++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/BranchManagementCommandProvider.java
@@ -49,6 +49,10 @@ public class BranchManagementCommandProvider implements CommandProvider {
branchCmds.stopBranchIntegrityCheck(ci);
}
+ public void _purge_deleted_branches(CommandInterpreter ci) {
+ branchCmds.purgeDeletedBranches(ci);
+ }
+
@Override
public String getHelp() {
StringBuilder sb = new StringBuilder();
@@ -58,7 +62,8 @@ public class BranchManagementCommandProvider implements CommandProvider {
sb.append(" import_branch <exchangeFilePath> [-exclude_baseline_txs] [-allAsRootBranches] [-minTx <value>] [-maxTx <value>] [-clean] [<branchId>]+ - import a specific set of branches from an exchange zip file.\n");
sb.append(" check_exchange <exchangeFilePath> - checks an exchange file to ensure data integrity\n");
sb.append(" check_exchange_stop - stop exchange integrity check\n");
+ sb.append(" purge_deleted_branches - permenatly remove all branches that are both archived and deleted \n");
+
return sb.toString();
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/branch/BranchCommands.java b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/branch/BranchCommands.java
index 3bfad998c2..dfd50d8865 100644
--- a/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/branch/BranchCommands.java
+++ b/plugins/org.eclipse.osee.framework.server.admin/src/org/eclipse/osee/framework/server/admin/branch/BranchCommands.java
@@ -10,7 +10,10 @@
*******************************************************************************/
package org.eclipse.osee.framework.server.admin.branch;
+import org.eclipse.osee.framework.branch.management.purge.PurgeDeletedBranches;
+import org.eclipse.osee.framework.core.operation.IOperation;
import org.eclipse.osee.framework.core.operation.Operations;
+import org.eclipse.osee.framework.server.admin.internal.Activator;
import org.eclipse.osgi.framework.console.CommandInterpreter;
/**
@@ -110,4 +113,10 @@ public class BranchCommands {
ci.println("Branch Integrity Check is not running.");
}
}
+
+ public void purgeDeletedBranches(CommandInterpreter ci) {
+ IOperation operation =
+ new PurgeDeletedBranches(Activator.getOseeCachingService(), Activator.getOseeDatabaseService());
+ Operations.executeAsJob(operation, false);
+ }
}

Back to the top