private void determineAffectedAddressing() throws OseeCoreException {
    gammaJoin.store();

    try {
      console.writeln("counter: [%s]", counter);
      console.writeln("query id: [%s]", gammaJoin.getQueryId());
      chStmt.runPreparedQuery(10000, SELECT_RELATION_ADDRESSING, gammaJoin.getQueryId());

      while (chStmt.next()) {
        long obsoleteGammaId = chStmt.getLong("gamma_id");
        int transactionId = chStmt.getInt("transaction_id");
        long netGammaId = chStmt.getLong("net_gamma_id");
        int modType = chStmt.getInt("mod_type");
        TxChange txCurrent = TxChange.getChangeType(chStmt.getInt("tx_current"));

        if (isNextAddressing(netGammaId, transactionId)) {
          if (updateAddressing) {
            updateAddressingData.add(
                new Object[] {
                  previousNetGammaId,
                  netModType.getValue(),
                  netTxCurrent.getValue(),
                  previousTransactionId,
                  previousObsoleteGammaId
                });
          }
          updateAddressing = obsoleteGammaId != netGammaId;
          previousNetGammaId = netGammaId;
          previousObsoleteGammaId = obsoleteGammaId;
          previousTransactionId = transactionId;
          netModType = ModificationType.getMod(modType);
          netTxCurrent = txCurrent;
        } else {
          addressingToDelete.add(
              new Object[] {chStmt.getInt("branch_id"), transactionId, obsoleteGammaId});
          computeNetAddressing(ModificationType.getMod(modType), txCurrent);
        }

        writeAddressingBackup(obsoleteGammaId, transactionId, netGammaId, modType, txCurrent);
      }
    } finally {
      chStmt.close();
    }
    gammaJoin.delete();
  }
 private boolean netTxCurrentNeedsUpdate(TxChange txCurrent) {
   if (txCurrent == netTxCurrent) {
     return false;
   }
   boolean needsUpdate = txCurrent == TxChange.NOT_CURRENT;
   needsUpdate |= txCurrent == TxChange.CURRENT && netTxCurrent.isDeleted();
   return needsUpdate
       || netTxCurrent == TxChange.DELETED && txCurrent == TxChange.ARTIFACT_DELETED;
 }
  private void writeAddressingBackup(
      long obsoleteGammaId, int transactionId, long netGammaId, int modType, TxChange txCurrent) {
    StringBuilder strB = new StringBuilder(30);

    strB.append(obsoleteGammaId);
    strB.append(",");
    strB.append(transactionId);
    strB.append(",");
    strB.append(netGammaId);
    strB.append(",");
    strB.append(modType);
    strB.append(",");
    strB.append(txCurrent.getValue());
    strB.append("\n");
    console.writeln(strB.toString());
  }
Exemplo n.º 4
0
  private void fixAddressing(Collection<Address> addresses) throws OseeStateException {
    Iterator<Address> iterator = addresses.iterator();

    Address previousAddress = iterator.next();
    if (previousAddress.getModType() == ModificationType.MODIFIED) {
      previousAddress.setModType(ModificationType.NEW);
    }

    while (iterator.hasNext()) {
      previousAddress.setCorrectedTxCurrent(TxChange.NOT_CURRENT);
      Address address = iterator.next();
      ModificationType[] nextValidStates = getNextPossibleStates(previousAddress.getModType());
      if (!address.getModType().matches(nextValidStates)) {
        iterator.remove();
      }
      previousAddress = address;
    }
    previousAddress.setCorrectedTxCurrent(TxChange.getCurrent(previousAddress.getModType()));
  }
  private void addTxs(SqlOrderEnum key, OrcsData orcsData) {
    VersionData data = orcsData.getVersion();
    ModificationType modType = orcsData.getModType();

    addRow(
        SqlOrderEnum.TXS,
        data.getTransactionId(),
        data.getGammaId(),
        modType.getValue(),
        TxChange.getCurrent(modType).getValue(),
        data.getBranchId());

    if (key.hasTxNotCurrentQuery()) {
      ArtifactJoinQuery join = txNotCurrentsJoin.get(key);
      if (join == null) {
        join = createJoin();
        txNotCurrentsJoin.put(key, join);
      }
      join.add(orcsData.getLocalId(), data.getBranchId(), RelationalConstants.TRANSACTION_SENTINEL);
    }
  }