Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjphillips2011-01-20 19:29:46 +0000
committerRyan D. Brooks2011-01-20 19:29:46 +0000
commitf2d904905559bfde3144c7828a91541b7e4ea68d (patch)
treef8309d33b22e67ba66c3186437d0abe2eba4c32d
parente4ecc8e85cf0fab64e9138cb2fd259540903b145 (diff)
downloadorg.eclipse.osee-f2d904905559bfde3144c7828a91541b7e4ea68d.tar.gz
org.eclipse.osee-f2d904905559bfde3144c7828a91541b7e4ea68d.tar.xz
org.eclipse.osee-f2d904905559bfde3144c7828a91541b7e4ea68d.zip
bug: Fix purge branch operations to remove purge branches
-rw-r--r--plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/PurgeBranchOperation.java4
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java34
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/DeleteBranchHandler.java8
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java14
-rw-r--r--plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeBranchHandler.java20
5 files changed, 65 insertions, 15 deletions
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 a2079e5f444..64761eb1e7a 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
@@ -65,7 +65,8 @@ public class PurgeBranchOperation extends AbstractDbTxOperation {
protected void doTxWork(IProgressMonitor monitor, OseeConnection connection) throws OseeCoreException {
this.connection = connection;
this.monitor = monitor;
- if (!branch.getChildBranches().isEmpty()) {
+
+ if (!branch.getAllChildBranches(false).isEmpty()) {
throw new OseeArgumentException("Unable to purge a branch containing children: branchId[%s]", branch.getId());
}
@@ -89,6 +90,7 @@ public class PurgeBranchOperation extends AbstractDbTxOperation {
branch.setStorageState(StorageState.PURGED);
branchCache.storeItems(branch);
branchCache.decache(branch);
+ branch.internalRemovePurgedBranchFromParent();
}
private void purgeGammas(String tableName, double percentage) throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java
index 181c8c11418..01d7ab0261a 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/Branch.java
@@ -14,6 +14,7 @@ package org.eclipse.osee.framework.core.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.eclipse.core.runtime.IAdaptable;
@@ -60,6 +61,21 @@ public class Branch extends AbstractOseeType implements IAdaptable, IOseeBranch
return getFieldValue(BranchField.PARENT_BRANCH);
}
+ public void internalRemovePurgedBranchFromParent() throws OseeCoreException {
+ if (hasParentBranch()) {
+ Branch parentBranch = getParentBranch();
+ Iterator<Branch> siblings = parentBranch.childBranches.iterator();
+
+ while (siblings.hasNext()) {
+ Branch sibling = siblings.next();
+ if (sibling.isPurged() && sibling.equals(this)) {
+ siblings.remove();
+ break;
+ }
+ }
+ }
+ }
+
public boolean hasParentBranch() throws OseeCoreException {
return getParentBranch() != null;
}
@@ -162,16 +178,26 @@ public class Branch extends AbstractOseeType implements IAdaptable, IOseeBranch
public Collection<Branch> getChildBranches(boolean recurse) throws OseeCoreException {
Set<Branch> children = new HashSet<Branch>();
- getChildBranches(this, children, recurse);
+ getChildBranches(this, children, recurse, false);
+ return children;
+ }
+
+ /**
+ * @return - This method returns all child branches. Including archived and merge child branches.
+ * @throws OseeCoreException
+ */
+ public Collection<Branch> getAllChildBranches(boolean recurse) throws OseeCoreException {
+ Set<Branch> children = new HashSet<Branch>();
+ getChildBranches(this, children, recurse, true);
return children;
}
- private void getChildBranches(Branch parentBranch, Collection<Branch> children, boolean recurse) throws OseeCoreException {
+ private void getChildBranches(Branch parentBranch, Collection<Branch> children, boolean recurse, boolean includeAllChildBranches) throws OseeCoreException {
for (Branch branch : parentBranch.getChildren()) {
- if (branch.getArchiveState().isUnArchived() && !branch.getBranchType().isMergeBranch()) {
+ if (includeAllChildBranches || (branch.getArchiveState().isUnArchived() && !branch.getBranchType().isMergeBranch())) {
children.add(branch);
if (recurse) {
- getChildBranches(branch, children, recurse);
+ getChildBranches(branch, children, recurse, includeAllChildBranches);
}
}
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/DeleteBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/DeleteBranchHandler.java
index 5ad21efcfb2..5e1dee993fa 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/DeleteBranchHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/DeleteBranchHandler.java
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.commandHandlers.branch;
+import java.util.List;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
/**
* @author Karol M. Wilk
@@ -20,4 +23,9 @@ public final class DeleteBranchHandler extends GeneralBranchHandler {
public DeleteBranchHandler() {
super(OpTypeEnum.DELETE);
}
+
+ @Override
+ public void performOperation(List<Branch> branches) {
+ BranchManager.deleteBranch(branches);
+ }
}
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
index 3ecacc764e1..b62e7277860 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/GeneralBranchHandler.java
@@ -19,7 +19,6 @@ import org.eclipse.osee.framework.access.AccessControlManager;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
import org.eclipse.osee.framework.ui.plugin.util.AWorkbench;
import org.eclipse.osee.framework.ui.plugin.util.CommandHandler;
import org.eclipse.osee.framework.ui.skynet.commandHandlers.Handlers;
@@ -28,7 +27,7 @@ import org.eclipse.osee.framework.ui.swt.Displays;
/**
* @author Karol M. Wilk
*/
-public class GeneralBranchHandler extends CommandHandler {
+public abstract class GeneralBranchHandler extends CommandHandler {
public enum OpTypeEnum {
DELETE("delete", "Delete Branch"),
PURGE("purge", "Purge Branch");
@@ -47,6 +46,8 @@ public class GeneralBranchHandler extends CommandHandler {
this.type = type;
}
+ public abstract void performOperation(final List<Branch> branches);
+
@Override
public Object executeWithException(ExecutionEvent arg0) {
IStructuredSelection selections =
@@ -61,14 +62,7 @@ public class GeneralBranchHandler extends CommandHandler {
IDialogConstants.NO_LABEL}, 1);
if (dialog.open() == 0) {
- switch (type) {
- case DELETE:
- BranchManager.deleteBranch(selectedBranches);
- break;
- case PURGE:
- BranchManager.purgeBranch(selectedBranches);
- break;
- }
+ performOperation(selectedBranches);
}
return null;
diff --git a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeBranchHandler.java b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeBranchHandler.java
index 64403bacf5b..52970effdf6 100644
--- a/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeBranchHandler.java
+++ b/plugins/org.eclipse.osee.framework.ui.skynet/src/org/eclipse/osee/framework/ui/skynet/commandHandlers/branch/PurgeBranchHandler.java
@@ -10,6 +10,13 @@
*******************************************************************************/
package org.eclipse.osee.framework.ui.skynet.commandHandlers.branch;
+import java.util.List;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.Branch;
+import org.eclipse.osee.framework.logging.OseeLevel;
+import org.eclipse.osee.framework.logging.OseeLog;
+import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
+import org.eclipse.osee.framework.ui.skynet.SkynetGuiPlugin;
/**
* @author Karol M. Wilk
@@ -20,4 +27,17 @@ public final class PurgeBranchHandler extends GeneralBranchHandler {
public PurgeBranchHandler() {
super(OpTypeEnum.PURGE);
}
+
+ @Override
+ public void performOperation(List<Branch> branches) {
+ for (Branch branch : branches) {
+ try {
+ if (branch.getAllChildBranches(false).isEmpty()) {
+ BranchManager.purgeBranch(branch);
+ }
+ } catch (OseeCoreException ex) {
+ OseeLog.log(SkynetGuiPlugin.class, OseeLevel.SEVERE_POPUP, ex);
+ }
+ }
+ }
}

Back to the top