summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjmisinco2011-04-07 18:03:55 (EDT)
committer Ryan D. Brooks2011-04-07 18:03:55 (EDT)
commit22d8d7ca6eb8fa01acca19461d1c48bbc8250e60 (patch)
treee26ba3fff91ffa038bd322d9f1f395b32b301a4d
parent0f8b4b6e602fb7ceafebfc3de8c0d995b5838161 (diff)
downloadorg.eclipse.osee-22d8d7ca6eb8fa01acca19461d1c48bbc8250e60.zip
org.eclipse.osee-22d8d7ca6eb8fa01acca19461d1c48bbc8250e60.tar.gz
org.eclipse.osee-22d8d7ca6eb8fa01acca19461d1c48bbc8250e60.tar.bz2
feature[ats_5N7KL]: Add purge branch recursive
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF6
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java2
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java23
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java66
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java55
5 files changed, 151 insertions, 1 deletions
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
index 685c85f..3e2c622 100644
--- a/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/META-INF/MANIFEST.MF
@@ -8,5 +8,9 @@ Fragment-Host: org.eclipse.osee.framework.branch.management;bundle-version="0.4.
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit
Import-Package: org.eclipse.osee.framework.core.message.test.mocks,
- org.eclipse.osee.framework.core.test.mocks
+ org.eclipse.osee.framework.core.test.mocks,
+ org.eclipse.osee.framework.skynet.core,
+ org.eclipse.osee.framework.skynet.core.artifact,
+ org.eclipse.osee.framework.skynet.core.transaction,
+ org.eclipse.osee.support.test.util
Export-Package: org.eclipse.osee.framework.branch.management.test
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
index 2649718..35e6436 100644
--- a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/BranchManagementTestSuite.java
@@ -13,6 +13,7 @@ package org.eclipse.osee.framework.branch.management.test;
import org.eclipse.osee.framework.branch.management.test.change.ChangeTestSuite;
import org.eclipse.osee.framework.branch.management.test.commit.CommitTestSuite;
import org.eclipse.osee.framework.branch.management.test.exchange.ExchangeTestSuite;
+import org.eclipse.osee.framework.branch.management.test.purge.PurgeTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -21,6 +22,7 @@ import org.junit.runners.Suite;
ChangeTestSuite.class, //
CommitTestSuite.class, //
ExchangeTestSuite.class,//
+ PurgeTestSuite.class,//
})
/**
* @author Roberto E. Escobar
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java
new file mode 100644
index 0000000..5632ca1
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/PurgeTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.test.purge;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({TestPurgeBranchRecursive.class})
+/**
+ * @author John Misinco
+ */
+public class PurgeTestSuite {
+ // test provided above
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java
new file mode 100644
index 0000000..323fe2c
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management.test/src/org/eclipse/osee/framework/branch/management/test/purge/TestPurgeBranchRecursive.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.test.purge;
+
+import static org.junit.Assert.assertFalse;
+import junit.framework.Assert;
+import org.eclipse.osee.framework.branch.management.purge.PurgeBranchRecursive;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.support.test.util.TestUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestPurgeBranchRecursive {
+
+ @Before
+ public void checkTestDb() throws OseeCoreException {
+ assertFalse(TestUtil.isProductionDb());
+ }
+
+ @Test
+ public void testPurgeBranchRecursive() throws OseeCoreException {
+ //create a root branch
+ Branch root = BranchManager.createTopLevelBranch("root");
+ //add a child to root (parent)
+ Branch parent = BranchManager.createWorkingBranch(root, "parent", UserManager.getUser());
+
+ //add children branches to parent
+ Branch child1 = BranchManager.createWorkingBranch(parent, "child1", UserManager.getUser());
+ Branch child2 = BranchManager.createWorkingBranch(parent, "child2", UserManager.getUser());
+ Branch child3 = BranchManager.createWorkingBranch(parent, "child3", UserManager.getUser());
+ //make one a merge branch
+ child3.setBranchType(BranchType.MERGE);
+
+ Branch grandChild1 = BranchManager.createWorkingBranch(child1, "grandChild1", UserManager.getUser());
+ grandChild1.setBranchType(BranchType.MERGE);
+ Branch grandChild2 = BranchManager.createWorkingBranch(child2, "grandChild1", UserManager.getUser());
+ Branch grandChild3 = BranchManager.createWorkingBranch(child3, "grandChild1", UserManager.getUser());
+
+ //count how many children of root there are
+ Assert.assertEquals(7, root.getAllChildBranches(true).size());
+ //call purgeBranch recursive
+ OperationLogger ol = new OperationLogger() {
+ @Override
+ public void log(String... row) {
+ //do nothing
+ }
+ };
+
+ PurgeBranchRecursive purge = new PurgeBranchRecursive(ol, parent, null, null);
+ //count how many children branches are in root (should be 0)
+ Assert.assertEquals(7, root.getAllChildBranches(true).size());
+ }
+}
diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java
new file mode 100644
index 0000000..0d8da87
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchRecursive.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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 java.util.Collection;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osee.framework.branch.management.internal.Activator;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.core.operation.AbstractOperation;
+import org.eclipse.osee.framework.core.operation.OperationLogger;
+import org.eclipse.osee.framework.core.services.IOseeCachingService;
+import org.eclipse.osee.framework.database.IOseeDatabaseService;
+
+/**
+ * @author John Misinco
+ */
+
+public class PurgeBranchRecursive extends AbstractOperation {
+
+ private final IOseeCachingService cachingService;
+ private final IOseeDatabaseService databaseService;
+ private final Branch toDelete;
+
+ public PurgeBranchRecursive(OperationLogger logger, Branch toDelete, IOseeCachingService cachingService, IOseeDatabaseService databaseService) {
+ super("Purge Branch Recursive", Activator.PLUGIN_ID, logger);
+ this.cachingService = cachingService;
+ this.databaseService = databaseService;
+ this.toDelete = toDelete;
+ }
+
+ @Override
+ protected void doWork(IProgressMonitor monitor) throws OseeCoreException {
+ Collection<Branch> children = toDelete.getAllChildBranches(true);
+ //add parent so it gets deleted last
+ children.add(toDelete);
+ logf("Found %s branches to purge.", children.size());
+ for (Branch branch : children) {
+ logf("Purging %s.", branch);
+ try {
+ doSubWork(new PurgeBranchOperation(getLogger(), branch, cachingService, databaseService), monitor, 0);
+ } catch (OseeCoreException ex) {
+ log(ex);
+ }
+ }
+ }
+}