diff options
author | jmisinco | 2011-06-20 20:31:31 +0000 |
---|---|---|
committer | Ryan D. Brooks | 2011-06-20 20:31:31 +0000 |
commit | 3f1e3da1d487f062ed470aef975c09253edfa29e (patch) | |
tree | 3f50631729a649a4f306be16a2ad18915fed74da /plugins/org.eclipse.osee.framework.branch.management | |
parent | 0150e261ca7b0e465ebeb80ee5cb1c783c0b2ce6 (diff) | |
download | org.eclipse.osee-3f1e3da1d487f062ed470aef975c09253edfa29e.tar.gz org.eclipse.osee-3f1e3da1d487f062ed470aef975c09253edfa29e.tar.xz org.eclipse.osee-3f1e3da1d487f062ed470aef975c09253edfa29e.zip |
refinement[bgz_349970]: Replace RecursiveBranchProvider with MultiBranchProvider
Diffstat (limited to 'plugins/org.eclipse.osee.framework.branch.management')
-rw-r--r-- | plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/internal/OseeBranchService.java | 5 | ||||
-rw-r--r-- | plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java (renamed from plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/RecursiveBranchProvider.java) | 37 |
2 files changed, 29 insertions, 13 deletions
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 7cd28cdd44d..25370b98251 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 @@ -11,6 +11,7 @@ package org.eclipse.osee.framework.branch.management.internal; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.osee.framework.branch.management.IOseeBranchService; @@ -22,8 +23,8 @@ import org.eclipse.osee.framework.branch.management.creation.CreateBranchOperati import org.eclipse.osee.framework.branch.management.purge.BranchOperation; import org.eclipse.osee.framework.branch.management.purge.IBranchOperationFactory; import org.eclipse.osee.framework.branch.management.purge.IBranchesProvider; +import org.eclipse.osee.framework.branch.management.purge.MultiBranchProvider; import org.eclipse.osee.framework.branch.management.purge.PurgeBranchOperationFactory; -import org.eclipse.osee.framework.branch.management.purge.RecursiveBranchProvider; import org.eclipse.osee.framework.branch.management.purge.SingleBranchProvider; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.BranchState; @@ -158,7 +159,7 @@ public class OseeBranchService implements IOseeBranchService { IBranchesProvider provider; if (request.isRecursive()) { - provider = new RecursiveBranchProvider(branch, new BranchFilter()); + provider = new MultiBranchProvider(true, Collections.singleton(branch), new BranchFilter()); } else { provider = new SingleBranchProvider(branch); } diff --git a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/RecursiveBranchProvider.java b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java index 41308ca27ea..8892474ae93 100644 --- a/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/RecursiveBranchProvider.java +++ b/plugins/org.eclipse.osee.framework.branch.management/src/org/eclipse/osee/framework/branch/management/purge/MultiBranchProvider.java @@ -21,24 +21,39 @@ import org.eclipse.osee.framework.core.util.Conditions; /** * @author John Misinco */ -public final class RecursiveBranchProvider implements IBranchesProvider { - private final Branch parentBranch; +public class MultiBranchProvider implements IBranchesProvider { + + private final boolean recursive; + private final Set<Branch> branches; private final BranchFilter filter; - public RecursiveBranchProvider(Branch parentBranch, BranchFilter filter) { - this.parentBranch = parentBranch; + public MultiBranchProvider(boolean recursive, Set<Branch> branches, BranchFilter filter) { + this.recursive = recursive; + this.branches = branches; this.filter = filter; } - @Override - public Collection<Branch> getBranches() throws OseeCoreException { - Conditions.checkNotNull(parentBranch, "seed"); + private Collection<Branch> getChildBranches(Branch branch) throws OseeCoreException { Set<Branch> children = new HashSet<Branch>(); - parentBranch.getChildBranches(children, true, filter); - if (filter.matches(parentBranch)) { - children.add(parentBranch); + branch.getChildBranches(children, true, filter); + if (filter.matches(branch)) { + children.add(branch); } return children; } -}
\ No newline at end of file + + @Override + public Collection<Branch> getBranches() throws OseeCoreException { + Conditions.checkNotNull(branches, "seeds"); + Set<Branch> result = branches; + if (recursive) { + result = new HashSet<Branch>(branches); + for (Branch b : branches) { + result.addAll(getChildBranches(b)); + } + } + return result; + } + +} |