public void deleteMemoByMemoContactIdx(long TenantId, long ContactId) {
   CFCrmMemoByMemoContactIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   if (indexByMemoContactIdx == null) {
     indexByMemoContactIdx =
         new HashMap<CFCrmMemoByMemoContactIdxKey, Map<CFCrmMemoPKey, ICFCrmMemoObj>>();
   }
   if (indexByMemoContactIdx.containsKey(key)) {
     Map<CFCrmMemoPKey, ICFCrmMemoObj> dict = indexByMemoContactIdx.get(key);
     ((ICFAccSchema) schema.getBackingStore())
         .getTableMemo()
         .deleteMemoByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId);
     Iterator<ICFCrmMemoObj> iter = dict.values().iterator();
     ICFCrmMemoObj obj;
     List<ICFCrmMemoObj> toForget = new LinkedList<ICFCrmMemoObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexByMemoContactIdx.remove(key);
   } else {
     ((ICFAccSchema) schema.getBackingStore())
         .getTableMemo()
         .deleteMemoByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId);
   }
 }
  public void forgetMemoByMemoContactIdx(long TenantId, long ContactId) {
    if (indexByMemoContactIdx == null) {
      return;
    }
    CFCrmMemoByMemoContactIdxKey key =
        ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
    key.setRequiredTenantId(TenantId);
    key.setRequiredContactId(ContactId);
    if (indexByMemoContactIdx.containsKey(key)) {
      Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(key);
      if (mapMemoContactIdx != null) {
        List<ICFCrmMemoObj> toForget = new LinkedList<ICFCrmMemoObj>();
        ICFCrmMemoObj cur = null;
        Iterator<ICFCrmMemoObj> iter = mapMemoContactIdx.values().iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          toForget.add(cur);
        }
        iter = toForget.iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          cur.forget(true);
        }
      }

      indexByMemoContactIdx.remove(key);
    }
  }
 public ICFCrmMemoObj readMemoByUDescrIdx(
     long TenantId, long ContactId, String Description, boolean forceRead) {
   if (indexByUDescrIdx == null) {
     indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>();
   }
   CFCrmMemoByUDescrIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   key.setRequiredDescription(Description);
   ICFCrmMemoObj obj = null;
   if ((!forceRead) && indexByUDescrIdx.containsKey(key)) {
     obj = indexByUDescrIdx.get(key);
   } else {
     CFCrmMemoBuff buff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description);
     if (buff != null) {
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(buff);
       obj = (ICFCrmMemoObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUDescrIdx.put(key, null);
     }
   }
   return (obj);
 }
 public List<ICFCrmMemoObj> readAllMemo(boolean forceRead) {
   final String S_ProcName = "readAllMemo";
   if ((allMemo == null) || forceRead) {
     Map<CFCrmMemoPKey, ICFCrmMemoObj> map = new HashMap<CFCrmMemoPKey, ICFCrmMemoObj>();
     allMemo = map;
     CFCrmMemoBuff[] buffList =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readAllDerived(schema.getAuthorization());
     CFCrmMemoBuff buff;
     ICFCrmMemoObj obj;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(buff);
       ICFCrmMemoObj realized = (ICFCrmMemoObj) obj.realize();
     }
   }
   Comparator<ICFCrmMemoObj> cmp =
       new Comparator<ICFCrmMemoObj>() {
         public int compare(ICFCrmMemoObj lhs, ICFCrmMemoObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFCrmMemoPKey lhsPKey = lhs.getPKey();
             CFCrmMemoPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = allMemo.size();
   ICFCrmMemoObj arr[] = new ICFCrmMemoObj[len];
   Iterator<ICFCrmMemoObj> valIter = allMemo.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFCrmMemoObj> arrayList = new ArrayList<ICFCrmMemoObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFCrmMemoObj> sortedList = arrayList;
   return (sortedList);
 }
 public CFSecurityHostNodeBuff[] readAllDerived(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "CFAccRamHostNode.readAllDerived";
   CFSecurityHostNodeBuff[] retList = new CFSecurityHostNodeBuff[dictByPKey.values().size()];
   Iterator<CFSecurityHostNodeBuff> iter = dictByPKey.values().iterator();
   int idx = 0;
   while (iter.hasNext()) {
     retList[idx++] = iter.next();
   }
   return (retList);
 }
 public CFSecurityHostNodeBuff lockDerived(
     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 void forgetMemoByIdIdx(long TenantId, long MemoId) {
   if (members == null) {
     return;
   }
   CFCrmMemoPKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredMemoId(MemoId);
   if (members.containsKey(key)) {
     ICFCrmMemoObj probed = members.get(key);
     if (probed != null) {
       probed.forget(true);
     }
   }
 }
  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 forgetMemoByUDescrIdx(long TenantId, long ContactId, String Description) {
    if (indexByUDescrIdx == null) {
      return;
    }
    CFCrmMemoByUDescrIdxKey key =
        ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
    key.setRequiredTenantId(TenantId);
    key.setRequiredContactId(ContactId);
    key.setRequiredDescription(Description);
    if (indexByUDescrIdx.containsKey(key)) {
      ICFCrmMemoObj probed = indexByUDescrIdx.get(key);
      if (probed != null) {
        probed.forget(true);
      }

      indexByUDescrIdx.remove(key);
    }
  }
  public void forgetMemo(ICFCrmMemoObj Obj, boolean forgetSubObjects) {
    ICFCrmMemoObj obj = Obj;
    CFCrmMemoPKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFCrmMemoObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.remove(keyUDescrIdx);
      }

      if (allMemo != null) {
        allMemo.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {
        ((ICFCrmSchemaObj) schema)
            .getMemoTagTableObj()
            .forgetMemoTagByMemoIdx(keepObj.getRequiredTenantId(), keepObj.getRequiredMemoId());
      }
    }
  }
 public ICFCrmMemoObj readMemo(CFCrmMemoPKey pkey, boolean forceRead) {
   ICFCrmMemoObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFCrmMemoBuff readBuff =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByIdIdx(
                 schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredMemoId());
     if (readBuff != null) {
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFCrmMemoObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 public void deleteMemoByUDescrIdx(long TenantId, long ContactId, String Description) {
   if (indexByUDescrIdx == null) {
     indexByUDescrIdx = new HashMap<CFCrmMemoByUDescrIdxKey, ICFCrmMemoObj>();
   }
   CFCrmMemoByUDescrIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   key.setRequiredDescription(Description);
   ICFCrmMemoObj obj = null;
   if (indexByUDescrIdx.containsKey(key)) {
     obj = indexByUDescrIdx.get(key);
     ((ICFAccSchema) schema.getBackingStore())
         .getTableMemo()
         .deleteMemoByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description);
     obj.forget(true);
   } else {
     ((ICFAccSchema) schema.getBackingStore())
         .getTableMemo()
         .deleteMemoByUDescrIdx(schema.getAuthorization(), TenantId, ContactId, Description);
   }
 }
  public CFSecurityHostNodeBuff[] readDerivedByClusterIdx(
      CFSecurityAuthorization Authorization, long ClusterId) {
    final String S_ProcName = "CFAccRamHostNode.readDerivedByClusterIdx";
    CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
    key.setRequiredClusterId(ClusterId);

    CFSecurityHostNodeBuff[] recArray;
    if (dictByClusterIdx.containsKey(key)) {
      Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx =
          dictByClusterIdx.get(key);
      recArray = new CFSecurityHostNodeBuff[subdictClusterIdx.size()];
      Iterator<CFSecurityHostNodeBuff> iter = subdictClusterIdx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx =
          new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
      dictByClusterIdx.put(key, subdictClusterIdx);
      recArray = new CFSecurityHostNodeBuff[0];
    }
    return (recArray);
  }
 public void deleteHostNodeByHostNameIdx(
     CFSecurityAuthorization Authorization, CFSecurityHostNodeByHostNameIdxKey argKey) {
   CFSecurityHostNodeBuff cur;
   LinkedList<CFSecurityHostNodeBuff> matchSet = new LinkedList<CFSecurityHostNodeBuff>();
   Iterator<CFSecurityHostNodeBuff> values = dictByPKey.values().iterator();
   while (values.hasNext()) {
     cur = values.next();
     if (argKey.equals(cur)) {
       matchSet.add(cur);
     }
   }
   Iterator<CFSecurityHostNodeBuff> iterMatch = matchSet.iterator();
   while (iterMatch.hasNext()) {
     cur = iterMatch.next();
     deleteHostNode(Authorization, cur);
   }
 }
 public void minimizeMemory() {
   allMemo = null;
   indexByTenantIdx = null;
   indexByMemoContactIdx = null;
   indexByUDescrIdx = null;
   List<ICFCrmMemoObj> toForget = new LinkedList<ICFCrmMemoObj>();
   ICFCrmMemoObj cur = null;
   Iterator<ICFCrmMemoObj> iter = members.values().iterator();
   while (iter.hasNext()) {
     cur = iter.next();
     if (cur.getEdit() == null) {
       toForget.add(cur);
     }
   }
   iter = toForget.iterator();
   while (iter.hasNext()) {
     cur = iter.next();
     cur.forget();
   }
 }
  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 CFSecurityCursor openHostNodeCursorAll(CFSecurityAuthorization Authorization) {
   CFSecurityCursor cursor =
       new CFAccRamHostNodeCursor(Authorization, schema, dictByPKey.values());
   return (cursor);
 }
 public List<ICFCrmMemoObj> readMemoByMemoContactIdx(
     long TenantId, long ContactId, boolean forceRead) {
   final String S_ProcName = "readMemoByMemoContactIdx";
   CFCrmMemoByMemoContactIdxKey key =
       ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContactId(ContactId);
   Map<CFCrmMemoPKey, ICFCrmMemoObj> dict;
   if (indexByMemoContactIdx == null) {
     indexByMemoContactIdx =
         new HashMap<CFCrmMemoByMemoContactIdxKey, Map<CFCrmMemoPKey, ICFCrmMemoObj>>();
   }
   if ((!forceRead) && indexByMemoContactIdx.containsKey(key)) {
     dict = indexByMemoContactIdx.get(key);
   } else {
     dict = new HashMap<CFCrmMemoPKey, ICFCrmMemoObj>();
     // Allow other threads to dirty-read while we're loading
     indexByMemoContactIdx.put(key, dict);
     ICFCrmMemoObj obj;
     CFCrmMemoBuff[] buffList =
         ((ICFAccSchema) schema.getBackingStore())
             .getTableMemo()
             .readDerivedByMemoContactIdx(schema.getAuthorization(), TenantId, ContactId);
     CFCrmMemoBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getMemoTableObj().newInstance();
       obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newPKey());
       obj.setBuff(buff);
       ICFCrmMemoObj realized = (ICFCrmMemoObj) obj.realize();
     }
   }
   Comparator<ICFCrmMemoObj> cmp =
       new Comparator<ICFCrmMemoObj>() {
         public int compare(ICFCrmMemoObj lhs, ICFCrmMemoObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFCrmMemoPKey lhsPKey = lhs.getPKey();
             CFCrmMemoPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFCrmMemoObj arr[] = new ICFCrmMemoObj[len];
   Iterator<ICFCrmMemoObj> valIter = dict.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFCrmMemoObj> arrayList = new ArrayList<ICFCrmMemoObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFCrmMemoObj> sortedList = arrayList;
   return (sortedList);
 }
  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);
  }
  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 ICFCrmMemoObj realizeMemo(ICFCrmMemoObj Obj) {
    ICFCrmMemoObj obj = Obj;
    CFCrmMemoPKey pkey = obj.getPKey();
    ICFCrmMemoObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFCrmMemoObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.remove(keyUDescrIdx);
      }

      keepObj.setBuff(Obj.getBuff());
      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
      if (allMemo != null) {
        allMemo.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj.setIsNew(false);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allMemo != null) {
        allMemo.put(keepObj.getPKey(), keepObj);
      }

      if (indexByTenantIdx != null) {
        CFCrmMemoByTenantIdxKey keyTenantIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByMemoContactIdx != null) {
        CFCrmMemoByMemoContactIdxKey keyMemoContactIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey();
        keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId());
        Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx =
            indexByMemoContactIdx.get(keyMemoContactIdx);
        if (mapMemoContactIdx != null) {
          mapMemoContactIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUDescrIdx != null) {
        CFCrmMemoByUDescrIdxKey keyUDescrIdx =
            ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey();
        keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId());
        keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription());
        indexByUDescrIdx.put(keyUDescrIdx, keepObj);
      }
    }
    return (keepObj);
  }