public void deleteSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    final String S_ProcName = "CFAsteriskRamSecDeviceTable.deleteSecDevice() ";
    CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey();
    pkey.setRequiredSecUserId(Buff.getRequiredSecUserId());
    pkey.setRequiredDevName(Buff.getRequiredDevName());
    CFSecuritySecDeviceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteSecDevice", pkey);
    }
    CFSecuritySecDeviceByUserIdxKey keyUserIdx = schema.getFactorySecDevice().newUserIdxKey();
    keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    // Validate reverse foreign keys

    // Delete is valid

    Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdict;

    dictByPKey.remove(pkey);

    subdict = dictByUserIdx.get(keyUserIdx);
    subdict.remove(pkey);
  }
  public void updateSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey();
    pkey.setRequiredSecUserId(Buff.getRequiredSecUserId());
    pkey.setRequiredDevName(Buff.getRequiredDevName());
    CFSecuritySecDeviceBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecDevice", "Existing record not found", "SecDevice", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecDevice", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecDeviceByUserIdxKey existingKeyUserIdx =
        schema.getFactorySecDevice().newUserIdxKey();
    existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

    CFSecuritySecDeviceByUserIdxKey newKeyUserIdx = schema.getFactorySecDevice().newUserIdxKey();
    newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Check unique indexes

    // Validate foreign keys

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableSecUser()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateSecDevice", "Container", "SecDeviceSecUser", "SecUser", null);
        }
      }
    }

    // Update is valid

    Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdict;

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

    subdict = dictByUserIdx.get(existingKeyUserIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictByUserIdx.containsKey(newKeyUserIdx)) {
      subdict = dictByUserIdx.get(newKeyUserIdx);
    } else {
      subdict = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>();
      dictByUserIdx.put(newKeyUserIdx, subdict);
    }
    subdict.put(pkey, Buff);
  }
 public void deleteSecDeviceByIdIdx(
     CFSecurityAuthorization Authorization, UUID argSecUserId, String argDevName) {
   CFSecuritySecDevicePKey key = schema.getFactorySecDevice().newPKey();
   key.setRequiredSecUserId(argSecUserId);
   key.setRequiredDevName(argDevName);
   deleteSecDeviceByIdIdx(Authorization, key);
 }
  public void createSecDevice(CFSecurityAuthorization Authorization, CFSecuritySecDeviceBuff Buff) {
    final String S_ProcName = "createSecDevice";
    CFSecuritySecDevicePKey pkey = schema.getFactorySecDevice().newPKey();
    pkey.setRequiredSecUserId(Buff.getRequiredSecUserId());
    pkey.setRequiredDevName(Buff.getRequiredDevName());
    Buff.setRequiredSecUserId(pkey.getRequiredSecUserId());
    Buff.setRequiredDevName(pkey.getRequiredDevName());
    CFSecuritySecDeviceByUserIdxKey keyUserIdx = schema.getFactorySecDevice().newUserIdxKey();
    keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

    // Validate unique indexes

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

    // Validate foreign keys

    {
      boolean allNull = true;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecUser()
                .readDerivedByIdIdx(Authorization, Buff.getRequiredSecUserId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecDeviceSecUser", "SecUser", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

    Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx;
    if (dictByUserIdx.containsKey(keyUserIdx)) {
      subdictUserIdx = dictByUserIdx.get(keyUserIdx);
    } else {
      subdictUserIdx = new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>();
      dictByUserIdx.put(keyUserIdx, subdictUserIdx);
    }
    subdictUserIdx.put(pkey, Buff);
  }
 public CFSecuritySecDeviceBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecuritySecDevicePKey PKey) {
   final String S_ProcName = "CFAsteriskRamSecDevice.readDerived";
   CFSecuritySecDevicePKey key = schema.getFactorySecDevice().newPKey();
   key.setRequiredSecUserId(PKey.getRequiredSecUserId());
   key.setRequiredDevName(PKey.getRequiredDevName());
   CFSecuritySecDeviceBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public CFSecurityCursor openSecDeviceCursorByUserIdx(
      CFSecurityAuthorization Authorization, UUID SecUserId) {
    CFSecurityCursor cursor;
    CFSecuritySecDeviceByUserIdxKey key = schema.getFactorySecDevice().newUserIdxKey();
    key.setRequiredSecUserId(SecUserId);

    if (dictByUserIdx.containsKey(key)) {
      Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx = dictByUserIdx.get(key);
      cursor = new CFAsteriskRamSecDeviceCursor(Authorization, schema, subdictUserIdx.values());
    } else {
      cursor =
          new CFAsteriskRamSecDeviceCursor(
              Authorization, schema, new ArrayList<CFSecuritySecDeviceBuff>());
    }
    return (cursor);
  }
  public CFSecuritySecDeviceBuff[] readDerivedByUserIdx(
      CFSecurityAuthorization Authorization, UUID SecUserId) {
    final String S_ProcName = "CFAsteriskRamSecDevice.readDerivedByUserIdx";
    CFSecuritySecDeviceByUserIdxKey key = schema.getFactorySecDevice().newUserIdxKey();
    key.setRequiredSecUserId(SecUserId);

    CFSecuritySecDeviceBuff[] recArray;
    if (dictByUserIdx.containsKey(key)) {
      Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx = dictByUserIdx.get(key);
      recArray = new CFSecuritySecDeviceBuff[subdictUserIdx.size()];
      Iterator<CFSecuritySecDeviceBuff> iter = subdictUserIdx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff> subdictUserIdx =
          new HashMap<CFSecuritySecDevicePKey, CFSecuritySecDeviceBuff>();
      dictByUserIdx.put(key, subdictUserIdx);
      recArray = new CFSecuritySecDeviceBuff[0];
    }
    return (recArray);
  }
 public void deleteSecDeviceByUserIdx(CFSecurityAuthorization Authorization, UUID argSecUserId) {
   CFSecuritySecDeviceByUserIdxKey key = schema.getFactorySecDevice().newUserIdxKey();
   key.setRequiredSecUserId(argSecUserId);
   deleteSecDeviceByUserIdx(Authorization, key);
 }