public static String formatSecFormBuffAttributes(String separator, CFSecuritySecFormBuff buff) {
   String retval =
       CFDbTestXMsgSecFormMessageFormatter.formatSecFormPKeyAttributes(separator, buff)
           + CFLibXmlUtil.formatRequiredInt32(separator, "Revision", buff.getRequiredRevision())
           + CFLibXmlUtil.formatOptionalUuid(separator, "CreatedBy", buff.getCreatedByUserId())
           + CFLibXmlUtil.formatOptionalTimestamp(separator, "CreatedAt", buff.getCreatedAt())
           + CFLibXmlUtil.formatOptionalUuid(separator, "UpdatedBy", buff.getUpdatedByUserId())
           + CFLibXmlUtil.formatOptionalTimestamp(separator, "UpdatedAt", buff.getUpdatedAt())
           + CFLibXmlUtil.formatRequiredInt32(separator, "SecAppId", buff.getRequiredSecAppId())
           + CFLibXmlUtil.formatRequiredXmlString(
               separator, "JEEServletMapName", buff.getRequiredJEEServletMapName());
   return (retval);
 }
  public void deleteSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    final String S_ProcName = "CFInternetRamSecFormTable.deleteSecForm() ";
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
    CFSecuritySecFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteSecForm", pkey);
    }
    CFSecuritySecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    keySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey keyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    keyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
    keyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

    // Validate reverse foreign keys

    // Delete is valid

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdict;

    dictByPKey.remove(pkey);

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

    subdict = dictBySecAppIdx.get(keySecAppIdx);
    subdict.remove(pkey);

    dictByUJEEServletIdx.remove(keyUJEEServletIdx);
  }
 public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
   final String S_ProcName = "updateSecForm";
   if ("SFRM".equals(Buff.getClassCode())
       && (!schema.isClusterUser(Authorization, Buff.getRequiredClusterId(), "UpdateSecForm"))) {
     throw CFLib.getDefaultExceptionFactory()
         .newRuntimeException(
             getClass(),
             S_ProcName,
             "Permission denied -- User not part of SecGroup UpdateSecForm");
   }
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     int SecFormId = Buff.getRequiredSecFormId();
     int SecAppId = Buff.getRequiredSecAppId();
     String JEEServletMapName = Buff.getRequiredJEEServletMapName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_update_secform( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "SFRM");
     stmtUpdateByPKey.setLong(argIdx++, ClusterId);
     stmtUpdateByPKey.setInt(argIdx++, SecFormId);
     stmtUpdateByPKey.setInt(argIdx++, SecAppId);
     stmtUpdateByPKey.setString(argIdx++, JEEServletMapName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecFormBuff updatedBuff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredSecAppId(updatedBuff.getRequiredSecAppId());
       Buff.setRequiredJEEServletMapName(updatedBuff.getRequiredJEEServletMapName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public void createSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    final String S_ProcName = "createSecForm";
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(
        ((CFInternetRamClusterTable) schema.getTableCluster())
            .nextSecFormIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredSecFormId(pkey.getRequiredSecFormId());
    CFSecuritySecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey keyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    keyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
    keyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

    // Validate unique indexes

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

    if (dictByUJEEServletIdx.containsKey(keyUJEEServletIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "SecFormUJEEServletIdx", keyUJEEServletIdx);
    }

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

    {
      boolean allNull = true;
      allNull = false;
      allNull = false;
      if (!allNull) {
        if (null
            == schema
                .getTableSecApp()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecAppId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), S_ProcName, "Container", "SecFormApplication", "SecApp", null);
        }
      }
    }

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

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

    Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdictSecAppIdx;
    if (dictBySecAppIdx.containsKey(keySecAppIdx)) {
      subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx);
    } else {
      subdictSecAppIdx = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx);
    }
    subdictSecAppIdx.put(pkey, Buff);

    dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff);
  }
  public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
    CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
    CFSecuritySecFormBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateSecForm", "Existing record not found", "SecForm", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateSecForm", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecuritySecFormByClusterIdxKey existingKeyClusterIdx =
        schema.getFactorySecForm().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecuritySecFormByClusterIdxKey newKeyClusterIdx =
        schema.getFactorySecForm().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecuritySecFormBySecAppIdxKey existingKeySecAppIdx =
        schema.getFactorySecForm().newSecAppIdxKey();
    existingKeySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

    CFSecuritySecFormBySecAppIdxKey newKeySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
    newKeySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

    CFSecuritySecFormByUJEEServletIdxKey existingKeyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    existingKeyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
    existingKeyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

    CFSecuritySecFormByUJEEServletIdxKey newKeyUJEEServletIdx =
        schema.getFactorySecForm().newUJEEServletIdxKey();
    newKeyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
    newKeyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

    // Check unique indexes

    if (!existingKeyUJEEServletIdx.equals(newKeyUJEEServletIdx)) {
      if (dictByUJEEServletIdx.containsKey(newKeyUJEEServletIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateSecForm", "SecFormUJEEServletIdx", newKeyUJEEServletIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

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

    {
      boolean allNull = true;

      if (allNull) {
        if (null
            == schema
                .getTableSecApp()
                .readDerivedByIdIdx(
                    Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecAppId())) {
          throw CFLib.getDefaultExceptionFactory()
              .newUnresolvedRelationException(
                  getClass(), "updateSecForm", "Container", "SecFormApplication", "SecApp", null);
        }
      }
    }

    // Update is valid

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

    subdict = dictBySecAppIdx.get(existingKeySecAppIdx);
    if (subdict != null) {
      subdict.remove(pkey);
    }
    if (dictBySecAppIdx.containsKey(newKeySecAppIdx)) {
      subdict = dictBySecAppIdx.get(newKeySecAppIdx);
    } else {
      subdict = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
      dictBySecAppIdx.put(newKeySecAppIdx, subdict);
    }
    subdict.put(pkey, Buff);

    dictByUJEEServletIdx.remove(existingKeyUJEEServletIdx);
    dictByUJEEServletIdx.put(newKeyUJEEServletIdx, Buff);
  }
 public void createSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
   final String S_ProcName = "createSecForm";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     int SecAppId = Buff.getRequiredSecAppId();
     String JEEServletMapName = Buff.getRequiredJEEServletMapName();
     Connection cnx = schema.getCnx();
     String sql = "exec sp_create_secform ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?";
     if (stmtCreateByPKey == null) {
       stmtCreateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtCreateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtCreateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtCreateByPKey.setString(argIdx++, "SFRM");
     stmtCreateByPKey.setLong(argIdx++, ClusterId);
     stmtCreateByPKey.setInt(argIdx++, SecAppId);
     stmtCreateByPKey.setString(argIdx++, JEEServletMapName);
     resultSet = stmtCreateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecuritySecFormBuff createdBuff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredClusterId(createdBuff.getRequiredClusterId());
       Buff.setRequiredSecFormId(createdBuff.getRequiredSecFormId());
       Buff.setRequiredSecAppId(createdBuff.getRequiredSecAppId());
       Buff.setRequiredJEEServletMapName(createdBuff.getRequiredJEEServletMapName());
       Buff.setRequiredRevision(createdBuff.getRequiredRevision());
       Buff.setCreatedByUserId(createdBuff.getCreatedByUserId());
       Buff.setCreatedAt(createdBuff.getCreatedAt());
       Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId());
       Buff.setUpdatedAt(createdBuff.getUpdatedAt());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
   final String S_ProcName = "updateSecForm";
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     int SecFormId = Buff.getRequiredSecFormId();
     int SecAppId = Buff.getRequiredSecAppId();
     String JEEServletMapName = Buff.getRequiredJEEServletMapName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "exec sp_update_secform ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "SFRM");
     stmtUpdateByPKey.setLong(argIdx++, ClusterId);
     stmtUpdateByPKey.setInt(argIdx++, SecFormId);
     stmtUpdateByPKey.setInt(argIdx++, SecAppId);
     stmtUpdateByPKey.setString(argIdx++, JEEServletMapName);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     stmtUpdateByPKey.execute();
     boolean moreResults = true;
     resultSet = null;
     while (resultSet == null) {
       try {
         moreResults = stmtUpdateByPKey.getMoreResults();
       } catch (SQLException e) {
         throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
       }
       if (moreResults) {
         try {
           resultSet = stmtUpdateByPKey.getResultSet();
         } catch (SQLException e) {
         }
       } else if (-1 == stmtUpdateByPKey.getUpdateCount()) {
         break;
       }
     }
     if (resultSet == null) {
       throw CFLib.getDefaultExceptionFactory()
           .newNullArgumentException(getClass(), S_ProcName, 0, "resultSet");
     }
     if (resultSet.next()) {
       CFSecuritySecFormBuff updatedBuff = unpackSecFormResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredSecAppId(updatedBuff.getRequiredSecAppId());
       Buff.setRequiredJEEServletMapName(updatedBuff.getRequiredJEEServletMapName());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }