public ICFSecurityTSecGroupMemberObj readTSecGroupMemberByUUserIdx(
     long TenantId, int TSecGroupId, UUID SecUserId, boolean forceRead) {
   if (indexByUUserIdx == null) {
     indexByUUserIdx =
         new HashMap<CFSecurityTSecGroupMemberByUUserIdxKey, ICFSecurityTSecGroupMemberObj>();
   }
   CFSecurityTSecGroupMemberByUUserIdxKey key =
       ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredTSecGroupId(TSecGroupId);
   key.setRequiredSecUserId(SecUserId);
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && indexByUUserIdx.containsKey(key)) {
     obj = indexByUUserIdx.get(key);
   } else {
     CFSecurityTSecGroupMemberBuff buff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByUUserIdx(schema.getAuthorization(), TenantId, TSecGroupId, SecUserId);
     if (buff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(buff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       indexByUUserIdx.put(key, null);
     }
   }
   return (obj);
 }
 public ICFSecurityISOCountryCurrencyObj readISOCountryCurrency(
     CFSecurityISOCountryCurrencyPKey pkey, boolean forceRead) {
   ICFSecurityISOCountryCurrencyObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityISOCountryCurrencyBuff readBuff =
         ((ICFInternetSchema) schema.getBackingStore())
             .getTableISOCountryCurrency()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredISOCountryId(),
                 pkey.getRequiredISOCurrencyId());
     if (readBuff != null) {
       obj = schema.getISOCountryCurrencyTableObj().newInstance();
       obj.setPKey(
           ((ICFInternetSchema) schema.getBackingStore())
               .getFactoryISOCountryCurrency()
               .newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityISOCountryCurrencyObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 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 ICFSecurityTSecGroupMemberObj readTSecGroupMember(
     CFSecurityTSecGroupMemberPKey pkey, boolean forceRead) {
   ICFSecurityTSecGroupMemberObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecurityTSecGroupMemberBuff readBuff =
         ((ICFBamSchema) schema.getBackingStore())
             .getTableTSecGroupMember()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredTenantId(),
                 pkey.getRequiredTSecGroupMemberId());
     if (readBuff != null) {
       obj = schema.getTSecGroupMemberTableObj().newInstance();
       obj.setPKey(
           ((ICFBamSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecurityTSecGroupMemberObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 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 updateNumberDef(CFSecurityAuthorization Authorization, CFDbTestNumberDefBuff Buff) {
    schema.getTableAtom().updateAtom(Authorization, Buff);
    CFDbTestValuePKey pkey = schema.getFactoryValue().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestNumberDefBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateNumberDef", "Existing record not found", "NumberDef", pkey);
    }
    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableAtom()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateNumberDef", "Superclass", "SuperClass", "Atom", null);
        }
      }
    }

    // Update is valid

    Map<CFDbTestValuePKey, CFDbTestNumberDefBuff> subdict;

    dictByPKey.remove(pkey);
    dictByPKey.put(pkey, Buff);
  }
  public void createNumberDef(CFSecurityAuthorization Authorization, CFDbTestNumberDefBuff Buff) {
    final String S_ProcName = "createNumberDef";
    schema.getTableAtom().createAtom(Authorization, Buff);
    CFDbTestValuePKey pkey = schema.getFactoryValue().newPKey();
    pkey.setClassCode(Buff.getClassCode());
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    // 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
                .getTableAtom()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Superclass", "SuperClass", "Atom", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);
  }
  public void createReqMinMaxValue(
      CFSecurityAuthorization Authorization, CFDbTestReqMinMaxValueBuff Buff) {
    final String S_ProcName = "createReqMinMaxValue";
    CFDbTestReqMinMaxValuePKey pkey = schema.getFactoryReqMinMaxValue().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(
        ((CFDbTestRamTenantTable) schema.getTableTenant())
            .nextReqMinMaxValueIdGen(Authorization, Buff.getRequiredTenantId()));
    Buff.setRequiredTenantId(pkey.getRequiredTenantId());
    Buff.setRequiredId(pkey.getRequiredId());
    CFDbTestReqMinMaxValueByUDescrIdxKey keyUDescrIdx =
        schema.getFactoryReqMinMaxValue().newUDescrIdxKey();
    keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFDbTestReqMinMaxValueByTenantIdxKey keyTenantIdx =
        schema.getFactoryReqMinMaxValue().newTenantIdxKey();
    keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    // 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, "ReqMinMaxValueUDescrIdx", keyUDescrIdx);
    }

    // Validate foreign keys

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

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdictTenantIdx;
    if (dictByTenantIdx.containsKey(keyTenantIdx)) {
      subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx);
    } else {
      subdictTenantIdx = new HashMap<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff>();
      dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx);
    }
    subdictTenantIdx.put(pkey, Buff);
  }
  public void updateReqMinMaxValue(
      CFSecurityAuthorization Authorization, CFDbTestReqMinMaxValueBuff Buff) {
    CFDbTestReqMinMaxValuePKey pkey = schema.getFactoryReqMinMaxValue().newPKey();
    pkey.setRequiredTenantId(Buff.getRequiredTenantId());
    pkey.setRequiredId(Buff.getRequiredId());
    CFDbTestReqMinMaxValueBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(),
              "updateReqMinMaxValue",
              "Existing record not found",
              "ReqMinMaxValue",
              pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateReqMinMaxValue", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFDbTestReqMinMaxValueByUDescrIdxKey existingKeyUDescrIdx =
        schema.getFactoryReqMinMaxValue().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFDbTestReqMinMaxValueByUDescrIdxKey newKeyUDescrIdx =
        schema.getFactoryReqMinMaxValue().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFDbTestReqMinMaxValueByTenantIdxKey existingKeyTenantIdx =
        schema.getFactoryReqMinMaxValue().newTenantIdxKey();
    existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId());

    CFDbTestReqMinMaxValueByTenantIdxKey newKeyTenantIdx =
        schema.getFactoryReqMinMaxValue().newTenantIdxKey();
    newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId());

    // Check unique indexes

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

    // Validate foreign keys

    {
      boolean allNull = true;

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

    // Update is valid

    Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdict;

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

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

    subdict = dictByTenantIdx.get(existingKeyTenantIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByTenantIdx.containsKey(newKeyTenantIdx)) {
      subdict = dictByTenantIdx.get(newKeyTenantIdx);
    } else {
      subdict = new HashMap<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff>();
      dictByTenantIdx.put(newKeyTenantIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }
  public ICFSecurityISOCountryCurrencyObj realizeISOCountryCurrency(
      ICFSecurityISOCountryCurrencyObj Obj) {
    ICFSecurityISOCountryCurrencyObj obj = Obj;
    CFSecurityISOCountryCurrencyPKey pkey = obj.getPKey();
    ICFSecurityISOCountryCurrencyObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecurityISOCountryCurrencyObj 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 (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.remove(keepObj.getPKey());
        }
      }

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

      if (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.put(keepObj.getPKey(), keepObj);
        }
      }
      if (allISOCountryCurrency != null) {
        allISOCountryCurrency.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 (allISOCountryCurrency != null) {
        allISOCountryCurrency.put(keepObj.getPKey(), keepObj);
      }

      if (indexByCountryIdx != null) {
        CFSecurityISOCountryCurrencyByCountryIdxKey keyCountryIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(keepObj.getRequiredISOCountryId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCountryIdx =
            indexByCountryIdx.get(keyCountryIdx);
        if (mapCountryIdx != null) {
          mapCountryIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByCurrencyIdx != null) {
        CFSecurityISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx =
            ((ICFInternetSchema) schema.getBackingStore())
                .getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(keepObj.getRequiredISOCurrencyId());
        Map<CFSecurityISOCountryCurrencyPKey, ICFSecurityISOCountryCurrencyObj> mapCurrencyIdx =
            indexByCurrencyIdx.get(keyCurrencyIdx);
        if (mapCurrencyIdx != null) {
          mapCurrencyIdx.put(keepObj.getPKey(), keepObj);
        }
      }
    }
    return (keepObj);
  }
  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);
  }
  public void createSecGroupForm(
      CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
    final String S_ProcName = "createSecGroupForm";
    CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(
        ((CFInternetRamClusterTable) schema.getTableCluster())
            .nextSecGroupFormIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecGroupFormId(pkey.getRequiredSecGroupFormId());
    CFSecuritySecGroupFormByClusterIdxKey keyClusterIdx =
        schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecGroupFormByGroupIdxKey keyGroupIdx =
        schema.getFactorySecGroupForm().newGroupIdxKey();
    keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFSecuritySecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    keyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
    keyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    CFSecuritySecGroupFormByUFormIdxKey keyUFormIdx =
        schema.getFactorySecGroupForm().newUFormIdxKey();
    keyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    keyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Validate unique indexes

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

    if (dictByUFormIdx.containsKey(keyUFormIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "SecGroupFormUFormIdx", keyUFormIdx);
    }

    // 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, "Owner", "SecGroupFormCluster", "Cluster", null);
        }
      }
    }

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

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

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

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictGroupIdx;
    if (dictByGroupIdx.containsKey(keyGroupIdx)) {
      subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx);
    } else {
      subdictGroupIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx);
    }
    subdictGroupIdx.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictAppIdx;
    if (dictByAppIdx.containsKey(keyAppIdx)) {
      subdictAppIdx = dictByAppIdx.get(keyAppIdx);
    } else {
      subdictAppIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByAppIdx.put(keyAppIdx, subdictAppIdx);
    }
    subdictAppIdx.put(pkey, Buff);

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx;
    if (dictByFormIdx.containsKey(keyFormIdx)) {
      subdictFormIdx = dictByFormIdx.get(keyFormIdx);
    } else {
      subdictFormIdx = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByFormIdx.put(keyFormIdx, subdictFormIdx);
    }
    subdictFormIdx.put(pkey, Buff);

    dictByUFormIdx.put(keyUFormIdx, Buff);
  }
  public void updateSecGroupForm(
      CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
    CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFSecuritySecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecGroupForm", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecGroupFormByClusterIdxKey existingKeyClusterIdx =
        schema.getFactorySecGroupForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecuritySecGroupFormByClusterIdxKey newKeyClusterIdx =
        schema.getFactorySecGroupForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecGroupFormByGroupIdxKey existingKeyGroupIdx =
        schema.getFactorySecGroupForm().newGroupIdxKey();
    existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

    CFSecuritySecGroupFormByGroupIdxKey newKeyGroupIdx =
        schema.getFactorySecGroupForm().newGroupIdxKey();
    newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

    CFSecuritySecGroupFormByAppIdxKey existingKeyAppIdx =
        schema.getFactorySecGroupForm().newAppIdxKey();
    existingKeyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFSecuritySecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
    newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecGroupFormByFormIdxKey existingKeyFormIdx =
        schema.getFactorySecGroupForm().newFormIdxKey();
    existingKeyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    CFSecuritySecGroupFormByFormIdxKey newKeyFormIdx =
        schema.getFactorySecGroupForm().newFormIdxKey();
    newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    CFSecuritySecGroupFormByUFormIdxKey existingKeyUFormIdx =
        schema.getFactorySecGroupForm().newUFormIdxKey();
    existingKeyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
    existingKeyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

    CFSecuritySecGroupFormByUFormIdxKey newKeyUFormIdx =
        schema.getFactorySecGroupForm().newUFormIdxKey();
    newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
    newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

    // Check unique indexes

    if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) {
      if (dictByUFormIdx.containsKey(newKeyUFormIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

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

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableSecGroup()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(),
                  "updateSecGroupForm",
                  "Container",
                  "SecGroupFormGroup",
                  "SecGroup",
                  null);
        }
      }
    }

    // Update is valid

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> 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<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByClusterIdx.put(newKeyClusterIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByGroupIdx.get(existingKeyGroupIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
      subdict = dictByGroupIdx.get(newKeyGroupIdx);
    } else {
      subdict = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByGroupIdx.put(newKeyGroupIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByAppIdx.get(existingKeyAppIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByAppIdx.containsKey(newKeyAppIdx)) {
      subdict = dictByAppIdx.get(newKeyAppIdx);
    } else {
      subdict = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByAppIdx.put(newKeyAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    subdict = dictByFormIdx.get(existingKeyFormIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByFormIdx.containsKey(newKeyFormIdx)) {
      subdict = dictByFormIdx.get(newKeyFormIdx);
    } else {
      subdict = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByFormIdx.put(newKeyFormIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUFormIdx.remove(existingKeyUFormIdx);
    dictByUFormIdx.put(newKeyUFormIdx, Buff);
  }