summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid W. Miller2012-06-21 19:46:49 (EDT)
committerRoberto E. Escobar2012-06-21 19:46:49 (EDT)
commitc325cb8d02e65960d45ba576b941c8d4e1c2130a (patch)
treec89c211d1c1c3f49c8ce8c6be161dee3d45a4a90
parent6db5818fb8a61705ad53a3d9b7fe95cfcf7d8b55 (diff)
downloadorg.eclipse.osee-c325cb8d02e65960d45ba576b941c8d4e1c2130a.zip
org.eclipse.osee-c325cb8d02e65960d45ba576b941c8d4e1c2130a.tar.gz
org.eclipse.osee-c325cb8d02e65960d45ba576b941c8d4e1c2130a.tar.bz2
refinement: Allow reload artifacts to handle multiple branches
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index f5cf1c1..cb70ff5 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -14,11 +14,13 @@ import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED
import static org.eclipse.osee.framework.core.enums.DeletionFlag.INCLUDE_DELETED;
import static org.eclipse.osee.framework.core.enums.LoadLevel.FULL;
import static org.eclipse.osee.framework.skynet.core.artifact.LoadType.INCLUDE_CACHE;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.core.data.IArtifactType;
@@ -31,7 +33,6 @@ import org.eclipse.osee.framework.core.enums.LoadLevel;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.MultipleArtifactsExist;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.message.SearchOptions;
import org.eclipse.osee.framework.core.message.SearchRequest;
@@ -39,6 +40,7 @@ import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.type.ArtifactType;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactLoader;
@@ -518,23 +520,28 @@ public class ArtifactQuery {
}
public static Collection<? extends Artifact> reloadArtifacts(Collection<? extends Artifact> artifacts) throws OseeCoreException {
+ Collection<Artifact> reloadedArts = new ArrayList<Artifact>(artifacts.size());
+ HashCollection<IOseeBranch, Artifact> branchMap = new HashCollection<IOseeBranch, Artifact>();
if (artifacts.isEmpty()) {
return artifacts;
}
- Set<Integer> artIds = new HashSet<Integer>();
- IOseeBranch branch = null;
for (Artifact artifact : artifacts) {
- if (branch == null) {
- branch = artifact.getBranch();
- } else if (!branch.equals(artifact.getBranch())) {
- throw new OseeArgumentException("Reloading artifacts of different branches not supported");
- }
- artIds.add(artifact.getArtId());
+ // separate/group artifacts by branch since ArtifactQueryBuilder only supports a single branch
+ branchMap.put(artifact.getBranch(), artifact);
}
- ArtifactQueryBuilder query = new ArtifactQueryBuilder(artIds, branch, INCLUDE_DELETED, FULL);
+ Set<Integer> artIds = new HashSet<Integer>();
+ for (Entry<IOseeBranch, Collection<Artifact>> entrySet : branchMap.entrySet()) {
- Collection<Artifact> reloadedArts = query.reloadArtifacts(artifacts.size());
- OseeEventManager.kickLocalArtifactReloadEvent(query, reloadedArts);
+ for (Artifact artifact : entrySet.getValue()) {
+ artIds.add(artifact.getArtId());
+ }
+
+ ArtifactQueryBuilder query = new ArtifactQueryBuilder(artIds, entrySet.getKey(), INCLUDE_DELETED, FULL);
+
+ reloadedArts.addAll(query.reloadArtifacts(artIds.size()));
+ OseeEventManager.kickLocalArtifactReloadEvent(query, reloadedArts);
+ artIds.clear();
+ }
return reloadedArts;
}