From ff5ff4a4cbd7c278c35b24213a42d9fcc8041c27 Mon Sep 17 00:00:00 2001 From: rescobar Date: Tue, 7 Dec 2010 15:02:46 -0700 Subject: refinement: Improve Transaction and Branch Cache loading --- .../core/message/BranchCacheUpdateUtil.java | 25 +++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'plugins/org.eclipse.osee.framework.core.message/src/org/eclipse') diff --git a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchCacheUpdateUtil.java b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchCacheUpdateUtil.java index a5fcac0c0cc..22399d096f9 100644 --- a/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchCacheUpdateUtil.java +++ b/plugins/org.eclipse.osee.framework.core.message/src/org/eclipse/osee/framework/core/message/BranchCacheUpdateUtil.java @@ -12,9 +12,11 @@ package org.eclipse.osee.framework.core.message; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.osee.framework.core.exception.OseeCoreException; import org.eclipse.osee.framework.core.model.Branch; import org.eclipse.osee.framework.core.model.BranchFactory; @@ -55,6 +57,8 @@ public final class BranchCacheUpdateUtil { Map branchToAssocArt = cacheMessage.getBranchToAssocArt(); + preLoadTransactions(cacheMessage); + for (BranchRow srcItem : cacheMessage.getBranchRows()) { int branchId = srcItem.getBranchId(); Branch updated = @@ -63,13 +67,13 @@ public final class BranchCacheUpdateUtil { srcItem.getBranchArchived().isArchived()); updatedItems.add(updated); - updated.setBaseTransaction(getTx(cacheMessage.getBranchToBaseTx(), branchId)); - updated.setSourceTransaction(getTx(cacheMessage.getBranchToSourceTx(), branchId)); - Integer artifactId = branchToAssocArt.get(branchId); if (artifactId != null) { updated.setAssociatedArtifactId(artifactId); } + + updated.setBaseTransaction(getTx(cacheMessage.getBranchToBaseTx(), branchId)); + updated.setSourceTransaction(getTx(cacheMessage.getBranchToSourceTx(), branchId)); } for (Entry entry : cacheMessage.getChildToParent().entrySet()) { @@ -91,6 +95,21 @@ public final class BranchCacheUpdateUtil { return updatedItems; } + private void preLoadTransactions(AbstractBranchCacheMessage cacheMessage) throws OseeCoreException { + Set txIdsToLoad = new HashSet(); + addValidTxIds(cacheMessage.getBranchToBaseTx().values(), txIdsToLoad); + addValidTxIds(cacheMessage.getBranchToSourceTx().values(), txIdsToLoad); + txCache.loadTransactions(txIdsToLoad); + } + + private void addValidTxIds(Collection source, Collection destination) { + for (Integer txId : source) { + if (txId != null && txId > 0) { + destination.add(txId); + } + } + } + private TransactionRecord getTx(Map branchToTx, Integer branchId) throws OseeCoreException { TransactionRecord tx = null; Integer txId = branchToTx.get(branchId); -- cgit v1.2.3