public void deleteFeeByAcctIdx(
     CFSecurityAuthorization Authorization, long argTenantId, long argAccountId) {
   CFAccFeeByAcctIdxKey key = schema.getFactoryFee().newAcctIdxKey();
   key.setRequiredTenantId(argTenantId);
   key.setRequiredAccountId(argAccountId);
   deleteFeeByAcctIdx(Authorization, key);
 }
 public void deleteFeeByLedgerIdx(
     CFSecurityAuthorization Authorization, Long argLedgerTenantId, Long argLedgerId) {
   CFAccFeeByLedgerIdxKey key = schema.getFactoryFee().newLedgerIdxKey();
   key.setOptionalLedgerTenantId(argLedgerTenantId);
   key.setOptionalLedgerId(argLedgerId);
   deleteFeeByLedgerIdx(Authorization, key);
 }
 public void deleteHostNodeByHostNameIdx(
     CFSecurityAuthorization Authorization, long argClusterId, String argHostName) {
   CFSecurityHostNodeByHostNameIdxKey key = schema.getFactoryHostNode().newHostNameIdxKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredHostName(argHostName);
   deleteHostNodeByHostNameIdx(Authorization, key);
 }
 public void deleteHostNodeByUDescrIdx(
     CFSecurityAuthorization Authorization, long argClusterId, String argDescription) {
   CFSecurityHostNodeByUDescrIdxKey key = schema.getFactoryHostNode().newUDescrIdxKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredDescription(argDescription);
   deleteHostNodeByUDescrIdx(Authorization, key);
 }
  public void deleteHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "CFAccRamHostNodeTable.deleteHostNode() ";
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteHostNode", pkey);
    }
    CFSecurityHostNodeByClusterIdxKey keyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
    keyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    keyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableService()
        .deleteServiceByHostIdx(
            Authorization, Buff.getRequiredClusterId(), Buff.getRequiredHostNodeId());
    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByClusterIdx.get(keyClusterIdx);
    subdict.remove(pkey);

    dictByUDescrIdx.remove(keyUDescrIdx);

    dictByHostNameIdx.remove(keyHostNameIdx);
  }
 public CFAccFeeBuff lockDerived(CFSecurityAuthorization Authorization, CFAccFeePKey PKey) {
   final String S_ProcName = "CFAccRamFee.readDerived";
   CFAccFeePKey key = schema.getFactoryFee().newPKey();
   key.setRequiredTenantId(PKey.getRequiredTenantId());
   key.setRequiredFeeId(PKey.getRequiredFeeId());
   CFAccFeeBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public CFSecurityCursor openFeeCursorByTenantIdx(
      CFSecurityAuthorization Authorization, long TenantId) {
    CFSecurityCursor cursor;
    CFAccFeeByTenantIdxKey key = schema.getFactoryFee().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);

    if (dictByTenantIdx.containsKey(key)) {
      Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx = dictByTenantIdx.get(key);
      cursor = new CFAccRamFeeCursor(Authorization, schema, subdictTenantIdx.values());
    } else {
      cursor = new CFAccRamFeeCursor(Authorization, schema, new ArrayList<CFAccFeeBuff>());
    }
    return (cursor);
  }
 public CFSecurityHostNodeBuff readDerived(
     CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
   final String S_ProcName = "CFAccRamHostNode.readDerived";
   CFSecurityHostNodePKey key = schema.getFactoryHostNode().newPKey();
   key.setRequiredClusterId(PKey.getRequiredClusterId());
   key.setRequiredHostNodeId(PKey.getRequiredHostNodeId());
   CFSecurityHostNodeBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public CFSecurityHostNodeBuff readDerivedByHostNameIdx(
      CFSecurityAuthorization Authorization, long ClusterId, String HostName) {
    final String S_ProcName = "CFAccRamHostNode.readDerivedByHostNameIdx";
    CFSecurityHostNodeByHostNameIdxKey key = schema.getFactoryHostNode().newHostNameIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredHostName(HostName);

    CFSecurityHostNodeBuff buff;
    if (dictByHostNameIdx.containsKey(key)) {
      buff = dictByHostNameIdx.get(key);
    } else {
      buff = null;
    }
    return (buff);
  }
  public CFSecurityCursor openHostNodeCursorByClusterIdx(
      CFSecurityAuthorization Authorization, long ClusterId) {
    CFSecurityCursor cursor;
    CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
    key.setRequiredClusterId(ClusterId);

    if (dictByClusterIdx.containsKey(key)) {
      Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx =
          dictByClusterIdx.get(key);
      cursor = new CFAccRamHostNodeCursor(Authorization, schema, subdictClusterIdx.values());
    } else {
      cursor =
          new CFAccRamHostNodeCursor(
              Authorization, schema, new ArrayList<CFSecurityHostNodeBuff>());
    }
    return (cursor);
  }
  public void deleteFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) {
    final String S_ProcName = "CFAccRamFeeTable.deleteFee() ";
    CFAccFeePKey pkey = schema.getFactoryFee().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredFeeId(Buff.getRequiredFeeId());
    CFAccFeeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteFee", pkey);
    }
    CFAccFeeByDateIdxKey keyDateIdx = schema.getFactoryFee().newDateIdxKey();
    keyDateIdx.setRequiredTenantId(existing.getRequiredTenantId());
    keyDateIdx.setRequiredAccountId(existing.getRequiredAccountId());
    keyDateIdx.setRequiredFeeDate(existing.getRequiredFeeDate());

    CFAccFeeByTenantIdxKey keyTenantIdx = schema.getFactoryFee().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccFeeByAcctIdxKey keyAcctIdx = schema.getFactoryFee().newAcctIdxKey();
    keyAcctIdx.setRequiredTenantId(existing.getRequiredTenantId());
    keyAcctIdx.setRequiredAccountId(existing.getRequiredAccountId());

    CFAccFeeByLedgerIdxKey keyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey();
    keyLedgerIdx.setOptionalLedgerTenantId(existing.getOptionalLedgerTenantId());
    keyLedgerIdx.setOptionalLedgerId(existing.getOptionalLedgerId());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableFeeDetail()
        .deleteFeeDetailByFeeIdx(
            Authorization, Buff.getRequiredTenantId(), Buff.getRequiredFeeId());
    Map<CFAccFeePKey, CFAccFeeBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByDateIdx.get(keyDateIdx);
    subdict.remove(pkey);

    subdict = dictByTenantIdx.get(keyTenantIdx);
    subdict.remove(pkey);

    subdict = dictByAcctIdx.get(keyAcctIdx);
    subdict.remove(pkey);

    subdict = dictByLedgerIdx.get(keyLedgerIdx);
    subdict.remove(pkey);
  }
  public CFAccFeeBuff[] readDerivedByTenantIdx(
      CFSecurityAuthorization Authorization, long TenantId) {
    final String S_ProcName = "CFAccRamFee.readDerivedByTenantIdx";
    CFAccFeeByTenantIdxKey key = schema.getFactoryFee().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);

    CFAccFeeBuff[] recArray;
    if (dictByTenantIdx.containsKey(key)) {
      Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx = dictByTenantIdx.get(key);
      recArray = new CFAccFeeBuff[subdictTenantIdx.size()];
      Iterator<CFAccFeeBuff> iter = subdictTenantIdx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByTenantIdx.put(key, subdictTenantIdx);
      recArray = new CFAccFeeBuff[0];
    }
    return (recArray);
  }
  public void createFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) {
    final String S_ProcName = "createFee";
    CFAccFeePKey pkey = schema.getFactoryFee().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredFeeId(
        ((CFAccRamTenantTable) schema.getTableTenant())
            .nextFeeIdGen(Authorization, Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredFeeId(pkey.getRequiredFeeId());
    CFAccFeeByDateIdxKey keyDateIdx = schema.getFactoryFee().newDateIdxKey();
    keyDateIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyDateIdx.setRequiredAccountId(Buff.getRequiredAccountId());
    keyDateIdx.setRequiredFeeDate(Buff.getRequiredFeeDate());

    CFAccFeeByTenantIdxKey keyTenantIdx = schema.getFactoryFee().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccFeeByAcctIdxKey keyAcctIdx = schema.getFactoryFee().newAcctIdxKey();
    keyAcctIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyAcctIdx.setRequiredAccountId(Buff.getRequiredAccountId());

    CFAccFeeByLedgerIdxKey keyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey();
    keyLedgerIdx.setOptionalLedgerTenantId(Buff.getOptionalLedgerTenantId());
    keyLedgerIdx.setOptionalLedgerId(Buff.getOptionalLedgerId());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableAccount()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "Account", "Account", null);
        }
      }
    }

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Owner", "Tenant", "Tenant", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictDateIdx;
    if (dictByDateIdx.containsKey(keyDateIdx)) {
      subdictDateIdx = dictByDateIdx.get(keyDateIdx);
    } else {
      subdictDateIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByDateIdx.put(keyDateIdx, subdictDateIdx);
    }
    subdictDateIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictAcctIdx;
    if (dictByAcctIdx.containsKey(keyAcctIdx)) {
      subdictAcctIdx = dictByAcctIdx.get(keyAcctIdx);
    } else {
      subdictAcctIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByAcctIdx.put(keyAcctIdx, subdictAcctIdx);
    }
    subdictAcctIdx.put(pkey, Buff);

    Map<CFAccFeePKey, CFAccFeeBuff> subdictLedgerIdx;
    if (dictByLedgerIdx.containsKey(keyLedgerIdx)) {
      subdictLedgerIdx = dictByLedgerIdx.get(keyLedgerIdx);
    } else {
      subdictLedgerIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByLedgerIdx.put(keyLedgerIdx, subdictLedgerIdx);
    }
    subdictLedgerIdx.put(pkey, Buff);
  }
  public void updateFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) {
    CFAccFeePKey pkey = schema.getFactoryFee().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredFeeId(Buff.getRequiredFeeId());
    CFAccFeeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateFee", "Existing record not found", "Fee", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateFee", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFAccFeeByDateIdxKey existingKeyDateIdx = schema.getFactoryFee().newDateIdxKey();
    existingKeyDateIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyDateIdx.setRequiredAccountId(existing.getRequiredAccountId());
    existingKeyDateIdx.setRequiredFeeDate(existing.getRequiredFeeDate());

    CFAccFeeByDateIdxKey newKeyDateIdx = schema.getFactoryFee().newDateIdxKey();
    newKeyDateIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyDateIdx.setRequiredAccountId(Buff.getRequiredAccountId());
    newKeyDateIdx.setRequiredFeeDate(Buff.getRequiredFeeDate());

    CFAccFeeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryFee().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFAccFeeByTenantIdxKey newKeyTenantIdx = schema.getFactoryFee().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    CFAccFeeByAcctIdxKey existingKeyAcctIdx = schema.getFactoryFee().newAcctIdxKey();
    existingKeyAcctIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyAcctIdx.setRequiredAccountId(existing.getRequiredAccountId());

    CFAccFeeByAcctIdxKey newKeyAcctIdx = schema.getFactoryFee().newAcctIdxKey();
    newKeyAcctIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyAcctIdx.setRequiredAccountId(Buff.getRequiredAccountId());

    CFAccFeeByLedgerIdxKey existingKeyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey();
    existingKeyLedgerIdx.setOptionalLedgerTenantId(existing.getOptionalLedgerTenantId());
    existingKeyLedgerIdx.setOptionalLedgerId(existing.getOptionalLedgerId());

    CFAccFeeByLedgerIdxKey newKeyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey();
    newKeyLedgerIdx.setOptionalLedgerTenantId(Buff.getOptionalLedgerTenantId());
    newKeyLedgerIdx.setOptionalLedgerId(Buff.getOptionalLedgerId());

    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableAccount()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateFee", "Container", "Account", "Account", null);
        }
      }
    }

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableTenant()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateFee", "Owner", "Tenant", "Tenant", null);
        }
      }
    }

    // Update is valid

    Map<CFAccFeePKey, CFAccFeeBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByDateIdx.get(existingKeyDateIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByDateIdx.containsKey(newKeyDateIdx)) {
      subdict = dictByDateIdx.get(newKeyDateIdx);
    } else {
      subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByDateIdx.put(newKeyDateIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
      subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
      subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAcctIdx.get(existingKeyAcctIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByAcctIdx.containsKey(newKeyAcctIdx)) {
      subdict = dictByAcctIdx.get(newKeyAcctIdx);
    } else {
      subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByAcctIdx.put(newKeyAcctIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByLedgerIdx.get(existingKeyLedgerIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByLedgerIdx.containsKey(newKeyLedgerIdx)) {
      subdict = dictByLedgerIdx.get(newKeyLedgerIdx);
    } else {
      subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>();
      dictByLedgerIdx.put(newKeyLedgerIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }
  public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "createHostNode";
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(
        ((CFAccRamClusterTable) schema.getTableCluster())
            .nextHostNodeIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredHostNodeId(pkey.getRequiredHostNodeId());
    CFSecurityHostNodeByClusterIdxKey keyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
    keyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    keyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

    // Validate unique indexes

    if (dictByPKey.containsKey(pkey)) {
      throw CFLib.getDefaultExceptionFactory()
          .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey);
    }

    if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "HostNodeUDescrIdx", keyUDescrIdx);
    }

    if (dictByHostNameIdx.containsKey(keyHostNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "HostNodeUHostNameIdx", keyHostNameIdx);
    }

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "HostNodeCluster", "Cluster", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx;
    if (dictByClusterIdx.containsKey(keyClusterIdx)) {
      subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
    } else {
      subdictClusterIdx = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
      dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
    }
    subdictClusterIdx.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    dictByHostNameIdx.put(keyHostNameIdx, Buff);
  }
  public void updateHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateHostNode", "Existing record not found", "HostNode", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateHostNode", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityHostNodeByClusterIdxKey existingKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecurityHostNodeByClusterIdxKey newKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey existingKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFSecurityHostNodeByUDescrIdxKey newKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey existingKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    existingKeyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

    CFSecurityHostNodeByHostNameIdxKey newKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    newKeyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

    // Check unique indexes

    if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) {
      if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateHostNode", "HostNodeUDescrIdx", newKeyUDescrIdx);
      }
    }

    if (!existingKeyHostNameIdx.equals(newKeyHostNameIdx)) {
      if (dictByHostNameIdx.containsKey(newKeyHostNameIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateHostNode", "HostNodeUHostNameIdx", newKeyHostNameIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableCluster()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateHostNode", "Container", "HostNodeCluster", "Cluster", null);
        }
      }
    }

    // Update is valid

    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);

    subdict = dictByClusterIdx.get(existingKeyClusterIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
      subdict = dictByClusterIdx.get(newKeyClusterIdx);
    } else {
      subdict = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
      dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUDescrIdx.remove(existingKeyUDescrIdx);
    dictByUDescrIdx.put(newKeyUDescrIdx, Buff);

    dictByHostNameIdx.remove(existingKeyHostNameIdx);
    dictByHostNameIdx.put(newKeyHostNameIdx, Buff);
  }