public CFSecuritySecDeviceBuff[] readAllDerived(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "CFAsteriskRamSecDevice.readAllDerived";
   CFSecuritySecDeviceBuff[] retList = new CFSecuritySecDeviceBuff[dictByPKey.values().size()];
   Iterator<CFSecuritySecDeviceBuff> iter = dictByPKey.values().iterator();
   int idx = 0;
   while (iter.hasNext()) {
     retList[idx++] = iter.next();
   }
   return (retList);
 }
  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 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 void deleteSecDeviceByUserIdx(
     CFSecurityAuthorization Authorization, CFSecuritySecDeviceByUserIdxKey argKey) {
   CFSecuritySecDeviceBuff cur;
   LinkedList<CFSecuritySecDeviceBuff> matchSet = new LinkedList<CFSecuritySecDeviceBuff>();
   Iterator<CFSecuritySecDeviceBuff> values = dictByPKey.values().iterator();
   while (values.hasNext()) {
     cur = values.next();
     if (argKey.equals(cur)) {
       matchSet.add(cur);
     }
   }
   Iterator<CFSecuritySecDeviceBuff> iterMatch = matchSet.iterator();
   while (iterMatch.hasNext()) {
     cur = iterMatch.next();
     deleteSecDevice(Authorization, cur);
   }
 }
  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[] 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 CFSecurityCursor openSecDeviceCursorAll(CFSecurityAuthorization Authorization) {
   CFSecurityCursor cursor =
       new CFAsteriskRamSecDeviceCursor(Authorization, schema, dictByPKey.values());
   return (cursor);
 }
  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);
  }