public CFSecuritySecGroupFormBuff[] readDerivedByFormIdx(
      CFSecurityAuthorization Authorization, long ClusterId, int SecFormId) {
    final String S_ProcName = "CFInternetRamSecGroupForm.readDerivedByFormIdx";
    CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecFormId(SecFormId);

    CFSecuritySecGroupFormBuff[] recArray;
    if (dictByFormIdx.containsKey(key)) {
      Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx =
          dictByFormIdx.get(key);
      recArray = new CFSecuritySecGroupFormBuff[subdictFormIdx.size()];
      Iterator<CFSecuritySecGroupFormBuff> iter = subdictFormIdx.values().iterator();
      int idx = 0;
      while (iter.hasNext()) {
        recArray[idx++] = iter.next();
      }
    } else {
      Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx =
          new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
      dictByFormIdx.put(key, subdictFormIdx);
      recArray = new CFSecuritySecGroupFormBuff[0];
    }
    return (recArray);
  }
 public void deleteSecGroupFormByFormIdx(
     CFSecurityAuthorization Authorization, long argClusterId, int argSecFormId) {
   CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
   key.setRequiredClusterId(argClusterId);
   key.setRequiredSecFormId(argSecFormId);
   deleteSecGroupFormByFormIdx(Authorization, key);
 }
  public void deleteSecGroupForm(
      CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
    final String S_ProcName = "CFInternetRamSecGroupFormTable.deleteSecGroupForm() ";
    CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
    CFSecuritySecGroupFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteSecGroupForm", pkey);
    }
    CFSecuritySecGroupFormByClusterIdxKey keyClusterIdx =
        schema.getFactorySecGroupForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

    // Validate reverse foreign keys

    // Delete is valid

    Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdict;

    dictByPKey.remove(pkey);

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

    subdict = dictByGroupIdx.get(keyGroupIdx);
    subdict.remove(pkey);

    subdict = dictByAppIdx.get(keyAppIdx);
    subdict.remove(pkey);

    subdict = dictByFormIdx.get(keyFormIdx);
    subdict.remove(pkey);

    dictByUFormIdx.remove(keyUFormIdx);
  }
 public CFSecuritySecGroupFormBuff lockDerived(
     CFSecurityAuthorization Authorization, CFSecuritySecGroupFormPKey PKey) {
   final String S_ProcName = "CFInternetRamSecGroupForm.readDerived";
   CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
   key.setRequiredClusterId(PKey.getRequiredClusterId());
   key.setRequiredSecGroupFormId(PKey.getRequiredSecGroupFormId());
   CFSecuritySecGroupFormBuff buff;
   if (dictByPKey.containsKey(key)) {
     buff = dictByPKey.get(key);
   } else {
     buff = null;
   }
   return (buff);
 }
  public CFSecuritySecGroupFormBuff readDerivedByUFormIdx(
      CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId, int SecFormId) {
    final String S_ProcName = "CFInternetRamSecGroupForm.readDerivedByUFormIdx";
    CFSecuritySecGroupFormByUFormIdxKey key = schema.getFactorySecGroupForm().newUFormIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecGroupId(SecGroupId);
    key.setRequiredSecFormId(SecFormId);

    CFSecuritySecGroupFormBuff buff;
    if (dictByUFormIdx.containsKey(key)) {
      buff = dictByUFormIdx.get(key);
    } else {
      buff = null;
    }
    return (buff);
  }
  public CFSecurityCursor openSecGroupFormCursorByFormIdx(
      CFSecurityAuthorization Authorization, long ClusterId, int SecFormId) {
    CFSecurityCursor cursor;
    CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
    key.setRequiredClusterId(ClusterId);
    key.setRequiredSecFormId(SecFormId);

    if (dictByFormIdx.containsKey(key)) {
      Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx =
          dictByFormIdx.get(key);
      cursor = new CFInternetRamSecGroupFormCursor(Authorization, schema, subdictFormIdx.values());
    } else {
      cursor =
          new CFInternetRamSecGroupFormCursor(
              Authorization, schema, new ArrayList<CFSecuritySecGroupFormBuff>());
    }
    return (cursor);
  }
  public static void main(String args[]) {
    final String S_ProcName = "CFInternetSaxMySqlLoaderCLI.main() ";
    initConsoleLog();
    int numArgs = args.length;
    if (numArgs >= 2) {
      String homeDirName = System.getProperty("HOME");
      if (homeDirName == null) {
        homeDirName = System.getProperty("user.home");
        if (homeDirName == null) {
          log.message(S_ProcName + "ERROR: Home directory not set");
          return;
        }
      }
      File homeDir = new File(homeDirName);
      if (!homeDir.exists()) {
        log.message(S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" does not exist");
        return;
      }
      if (!homeDir.isDirectory()) {
        log.message(
            S_ProcName + "ERROR: Home directory \"" + homeDirName + "\" is not a directory");
        return;
      }
      CFInternetConfigurationFile cFInternetConfig = new CFInternetConfigurationFile();
      String cFInternetConfigFileName = homeDir.getPath() + File.separator + ".cfinternetmysqlrc";
      cFInternetConfig.setFileName(cFInternetConfigFileName);
      File cFInternetConfigFile = new File(cFInternetConfigFileName);
      if (!cFInternetConfigFile.exists()) {
        cFInternetConfig.setDbServer("127.0.0.1");
        cFInternetConfig.setDbPort(3306);
        cFInternetConfig.setDbDatabase("CFINet24");
        cFInternetConfig.setDbUserName("root");
        cFInternetConfig.setDbPassword("edit-me-please");
        cFInternetConfig.save();
        log.message(
            S_ProcName
                + "INFO: Created configuration file "
                + cFInternetConfigFileName
                + ", please edit configuration and restart.");
        return;
      }
      if (!cFInternetConfigFile.isFile()) {
        log.message(
            S_ProcName
                + "ERROR: Proposed configuration file "
                + cFInternetConfigFileName
                + " is not a file.");
        return;
      }
      if (!cFInternetConfigFile.canRead()) {
        log.message(
            S_ProcName
                + "ERROR: Permission denied attempting to read configuration file "
                + cFInternetConfigFileName);
        return;
      }
      cFInternetConfig.load();
      boolean fastExit = false;
      CFInternetClientConfigurationFile cFDbTestClientConfig =
          new CFInternetClientConfigurationFile();
      String cFDbTestClientConfigFileName =
          homeDir.getPath() + File.separator + ".cfdbtestclientrc";
      cFDbTestClientConfig.setFileName(cFDbTestClientConfigFileName);
      File cFDbTestClientConfigFile = new File(cFDbTestClientConfigFileName);
      if (!cFDbTestClientConfigFile.exists()) {
        String cFDbTestKeyStoreFileName = homeDir.getPath() + File.separator + ".msscfjceks";
        cFDbTestClientConfig.setKeyStore(cFDbTestKeyStoreFileName);
        InetAddress localHost;
        try {
          localHost = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
          localHost = null;
        }
        if (localHost == null) {
          log.message(S_ProcName + "ERROR: LocalHost is null");
          return;
        }
        String hostName = localHost.getHostName();
        if ((hostName == null) || (hostName.length() <= 0)) {
          log.message("ERROR: LocalHost.HostName is null or empty");
          return;
        }
        String userName = System.getProperty("user.name");
        if ((userName == null) || (userName.length() <= 0)) {
          log.message("ERROR: user.name is null or empty");
          return;
        }
        String deviceName =
            hostName.replaceAll("[^\\w]", "_").toLowerCase()
                + "-"
                + userName.replaceAll("[^\\w]", "_").toLowerCase();
        cFDbTestClientConfig.setDeviceName(deviceName);
        cFDbTestClientConfig.save();
        log.message(
            S_ProcName
                + "INFO: Created CFInternet client configuration file "
                + cFDbTestClientConfigFileName);
        fastExit = true;
      }
      if (!cFDbTestClientConfigFile.isFile()) {
        log.message(
            S_ProcName
                + "ERROR: Proposed client configuration file "
                + cFDbTestClientConfigFileName
                + " is not a file.");
        fastExit = true;
      }
      if (!cFDbTestClientConfigFile.canRead()) {
        log.message(
            S_ProcName
                + "ERROR: Permission denied attempting to read client configuration file "
                + cFDbTestClientConfigFileName);
        fastExit = true;
      }
      cFDbTestClientConfig.load();

      if (fastExit) {
        return;
      }

      // Configure logging
      Properties sysProps = System.getProperties();
      sysProps.setProperty("log4j.rootCategory", "WARN");
      sysProps.setProperty(
          "org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Log4JLogger");

      Logger httpLogger = Logger.getLogger("org.apache.http");
      httpLogger.setLevel(Level.WARN);

      ICFInternetSchema cFInternetSchema = new CFInternetMySqlSchema();
      cFInternetSchema.setConfigurationFile(cFInternetConfig);
      ICFInternetSchemaObj cFInternetSchemaObj = new CFInternetSchemaObj();
      cFInternetSchemaObj.setBackingStore(cFInternetSchema);
      CFInternetSaxLoaderCLI cli = new CFInternetSaxMySqlLoaderCLI();
      CFInternetSaxLoader loader = cli.getSaxLoader();
      loader.setSchemaObj(cFInternetSchemaObj);
      cFInternetSchema.connect();
      String url = args[1];
      if (numArgs >= 5) {
        cli.setClusterName(args[2]);
        cli.setTenantName(args[3]);
        cli.setSecUserName(args[4]);
      } else {
        cli.setClusterName("default");
        cli.setTenantName("system");
        cli.setSecUserName("system");
      }
      loader.setUseCluster(cli.getClusterObj());
      loader.setUseTenant(cli.getTenantObj());
      try {
        cFInternetSchema.beginTransaction();
        cFInternetSchemaObj.setSecCluster(cli.getClusterObj());
        cFInternetSchemaObj.setSecTenant(cli.getTenantObj());
        cFInternetSchemaObj.setSecUser(cli.getSecUserObj());
        cFInternetSchemaObj.setSecSession(cli.getSecSessionObj());
        CFSecurityAuthorization auth = new CFSecurityAuthorization();
        auth.setSecCluster(cFInternetSchemaObj.getSecCluster());
        auth.setSecTenant(cFInternetSchemaObj.getSecTenant());
        auth.setSecSession(cFInternetSchemaObj.getSecSession());
        cFInternetSchemaObj.setAuthorization(auth);
        applyLoaderOptions(loader, args[0]);
        if (numArgs >= 5) {
          cli.evaluateRemainingArgs(args, 5);
        } else {
          cli.evaluateRemainingArgs(args, 2);
        }
        loader.parseFile(url);
        cFInternetSchema.commit();
        cFInternetSchema.disconnect(true);
      } catch (Exception e) {
        log.message(
            S_ProcName + "EXCEPTION: Could not parse XML file \"" + url + "\": " + e.getMessage());
        e.printStackTrace(System.out);
      } catch (Error e) {
        log.message(
            S_ProcName + "ERROR: Could not parse XML file \"" + url + "\": " + e.getMessage());
        e.printStackTrace(System.out);
      } finally {
        if (cFInternetSchema.isConnected()) {
          cFInternetSchema.rollback();
          cFInternetSchema.disconnect(false);
        }
      }
    } else {
      log.message(
          S_ProcName
              + "ERROR: Expected at least two argument specifying the loader options and the name of the XML file to parse.  The first argument may be empty.");
    }
  }
  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);
  }