public Collection<Branch> updateCache(
      AbstractBranchCacheMessage cacheMessage, IOseeCache<String, Branch> cache)
      throws OseeCoreException {
    List<Branch> updatedItems = new ArrayList<Branch>();

    Map<Integer, Integer> branchToAssocArt = cacheMessage.getBranchToAssocArt();

    preLoadTransactions(cacheMessage);

    for (BranchRow srcItem : cacheMessage.getBranchRows()) {
      int branchId = srcItem.getBranchId();
      Branch updated =
          factory.createOrUpdate(
              cache,
              srcItem.getBranchId(),
              srcItem.getStorageState(),
              srcItem.getBranchGuid(),
              srcItem.getBranchName(),
              srcItem.getBranchType(),
              srcItem.getBranchState(),
              srcItem.getBranchArchived().isArchived());
      updatedItems.add(updated);

      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<Integer, Integer> entry : cacheMessage.getChildToParent().entrySet()) {
      Branch parent = cache.getById(entry.getValue());
      if (parent != null) {
        Branch child = cache.getById(entry.getKey());
        if (child != null) {
          child.setParentBranch(parent);
        }
      }
    }
    for (Triplet<String, String, String> entry : cacheMessage.getMergeBranches()) {
      IOseeBranch sourceBranch =
          Strings.isValid(entry.getFirst()) ? cache.getByGuid(entry.getFirst()) : null;
      IOseeBranch destinationBranch =
          Strings.isValid(entry.getSecond()) ? cache.getByGuid(entry.getSecond()) : null;

      Branch branch = cache.getByGuid(entry.getThird());
      MergeBranch mergeBranch = null;
      try {
        mergeBranch = (MergeBranch) branch;
        mergeBranch.setSourceBranch(sourceBranch);
        mergeBranch.setDestinationBranch(destinationBranch);
      } catch (ClassCastException ex) {
        throw new OseeCoreException(
            ex,
            "Problem casting branch [%s] to MergeBranch, source: [%s], dest: [%s]",
            branch,
            sourceBranch,
            destinationBranch);
      }
    }
    return updatedItems;
  }