public static void loadFromCache(AbstractBranchCacheMessage message, Collection<Branch> types)
     throws OseeCoreException {
   for (Branch br : types) {
     Integer branchId = br.getId();
     message
         .getBranchRows()
         .add(
             new BranchRow(
                 br.getId(),
                 br.getGuid(),
                 br.getName(),
                 br.getBranchType(),
                 br.getBranchState(),
                 br.getArchiveState(),
                 br.getStorageState()));
     if (br.hasParentBranch()) {
       message.getChildToParent().put(branchId, br.getParentBranch().getId());
     }
     addTxRecord(message.getBranchToBaseTx(), branchId, br.getBaseTransaction());
     addTxRecord(message.getBranchToSourceTx(), branchId, br.getSourceTransaction());
     addAssocArtifact(message.getBranchToAssocArt(), branchId, br.getAssociatedArtifactId());
     if (br.getBranchType().isMergeBranch()) {
       addMergeBranches(message.getMergeBranches(), (MergeBranch) br);
     }
   }
 }
  private void loadAttributeWasValues(
      Branch sourceBranch,
      TransactionRecord transactionId,
      Set<Integer> artIds,
      IProgressMonitor monitor,
      Map<Integer, ChangeBuilder> attributesWasValueCache,
      boolean hasBranch)
      throws OseeCoreException, OseeDataStoreException {
    if (!artIds.isEmpty()) {
      int sqlParamter; // Will either be a branch id or transaction id
      Branch wasValueBranch;
      String sql;

      if (hasBranch) {
        wasValueBranch = sourceBranch;
        sql = ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_WAS);
        sqlParamter = wasValueBranch.getId();
      } else {
        wasValueBranch = transactionId.getBranch();
        sql = ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_WAS);
        sqlParamter = transactionId.getId();
      }

      int queryId = ArtifactLoader.getNewQueryId();
      Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
      List<Object[]> datas = new LinkedList<Object[]>();
      IOseeStatement chStmt = ConnectionHandler.getStatement();

      try {
        // insert into the artifact_join_table
        for (int artId : artIds) {
          datas.add(
              new Object[] {
                queryId, insertTime, artId, wasValueBranch.getId(), SQL3DataType.INTEGER
              });
        }
        ArtifactLoader.insertIntoArtifactJoin(datas);
        chStmt.runPreparedQuery(sql, sqlParamter, queryId);
        int previousAttrId = -1;

        while (chStmt.next()) {
          int attrId = chStmt.getInt("attr_id");

          if (previousAttrId != attrId) {
            String wasValue = chStmt.getString("was_value");
            if (attributesWasValueCache.containsKey(attrId)
                && attributesWasValueCache.get(attrId) instanceof AttributeChangeBuilder) {
              AttributeChangeBuilder changeBuilder =
                  (AttributeChangeBuilder) attributesWasValueCache.get(attrId);

              if (changeBuilder.getArtModType() != ModificationType.NEW) {
                if (changeBuilder.getModType() != ModificationType.DELETED
                    && changeBuilder.getModType() != ModificationType.ARTIFACT_DELETED) {
                  changeBuilder.setModType(ModificationType.MODIFIED);
                }
                changeBuilder.setWasValue(wasValue);
              }
            }
            previousAttrId = attrId;
          }
        }
      } finally {
        ArtifactLoader.clearQuery(queryId);
        chStmt.close();
      }
      if (getMonitor() != null) {
        monitor.worked(12);
      }
    }
  }