public CFSecurityHostNodeBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
   final String S_ProcName = "lockBuff";
   CFSecurityHostNodeBuff buff = readDerived(Authorization, PKey);
   if ((buff != null) && (!buff.getClassCode().equals("HSND"))) {
     buff = null;
   }
   return (buff);
 }
 public CFSecurityHostNodeBuff readBuffByHostNameIdx(
     CFSecurityAuthorization Authorization, long ClusterId, String HostName) {
   final String S_ProcName = "CFAccRamHostNode.readBuffByHostNameIdx() ";
   CFSecurityHostNodeBuff buff = readDerivedByHostNameIdx(Authorization, ClusterId, HostName);
   if ((buff != null) && buff.getClassCode().equals("HSND")) {
     return ((CFSecurityHostNodeBuff) buff);
   } else {
     return (null);
   }
 }
 public CFSecurityHostNodeBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "CFAccRamHostNode.readAllBuff";
   CFSecurityHostNodeBuff buff;
   ArrayList<CFSecurityHostNodeBuff> filteredList = new ArrayList<CFSecurityHostNodeBuff>();
   CFSecurityHostNodeBuff[] buffList = readAllDerived(Authorization);
   for (int idx = 0; idx < buffList.length; idx++) {
     buff = buffList[idx];
     if ((buff != null) && buff.getClassCode().equals("HSND")) {
       filteredList.add(buff);
     }
   }
   return (filteredList.toArray(new CFSecurityHostNodeBuff[0]));
 }
 public CFSecurityHostNodeBuff[] readBuffByClusterIdx(
     CFSecurityAuthorization Authorization, long ClusterId) {
   final String S_ProcName = "CFBamRamHostNode.readBuffByClusterIdx() ";
   CFSecurityHostNodeBuff buff;
   ArrayList<CFSecurityHostNodeBuff> filteredList = new ArrayList<CFSecurityHostNodeBuff>();
   CFSecurityHostNodeBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId);
   for (int idx = 0; idx < buffList.length; idx++) {
     buff = buffList[idx];
     if ((buff != null) && buff.getClassCode().equals("HSND")) {
       filteredList.add((CFSecurityHostNodeBuff) buff);
     }
   }
   return (filteredList.toArray(new CFSecurityHostNodeBuff[0]));
 }
 public CFDbTestHostNodeEditObj(ICFSecurityHostNodeObj argOrig) {
   orig = argOrig;
   getBuff();
   CFSecurityHostNodeBuff origBuff = orig.getBuff();
   buff.set(origBuff);
   requiredContainerCluster = null;
 }
  public void deleteHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "deleteHostNode";
    try {
      Connection cnx = schema.getCnx();
      long ClusterId = Buff.getRequiredClusterId();
      long HostNodeId = Buff.getRequiredHostNodeId();

      String sql = "exec sp_delete_hostnode ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, ClusterId);
      stmtDeleteByPKey.setLong(argIdx++, HostNodeId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      Object stuff = null;
      boolean moreResults = stmtDeleteByPKey.execute();
      while (stuff == null) {
        try {
          moreResults = stmtDeleteByPKey.getMoreResults();
        } catch (SQLException e) {
          throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
        if (moreResults) {
          try {
            stuff = stmtDeleteByPKey.getResultSet();
          } catch (SQLException e) {
          }
        } else if (-1 == stmtDeleteByPKey.getUpdateCount()) {
          break;
        }
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
  }
 public CFSecurityHostNodeBuff getBuff() {
   if (buff == null) {
     buff =
         ((ICFDbTestSchema) getOrigAsHostNode().getSchema().getBackingStore())
             .getFactoryHostNode()
             .newBuff();
     buff.set(orig.getBuff());
   }
   return (buff);
 }
 public boolean equals(Object obj) {
   if (obj == null) {
     return (false);
   } else if (obj instanceof CFSecurityHostNodeByClusterIdxKey) {
     CFSecurityHostNodeByClusterIdxKey rhs = (CFSecurityHostNodeByClusterIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityHostNodeBuff) {
     CFSecurityHostNodeBuff rhs = (CFSecurityHostNodeBuff) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     return (true);
   } else {
     return (false);
   }
 }
 public int compareTo(Object obj) {
   if (obj == null) {
     return (1);
   } else if (obj instanceof CFSecurityHostNodeByClusterIdxKey) {
     CFSecurityHostNodeByClusterIdxKey rhs = (CFSecurityHostNodeByClusterIdxKey) obj;
     if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
       return (-1);
     } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
       return (1);
     }
     return (0);
   } else if (obj instanceof CFSecurityHostNodeBuff) {
     CFSecurityHostNodeBuff rhs = (CFSecurityHostNodeBuff) obj;
     if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
       return (-1);
     } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
       return (1);
     }
     return (0);
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newUnsupportedClassException(getClass(), "compareTo", "obj", obj, null);
   }
 }
  public void updateHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      throw CFLib.getDefaultExceptionFactory()
          .newStaleCacheDetectedException(
              getClass(), "updateHostNode", "Existing record not found", "HostNode", pkey);
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "updateHostNode", pkey);
    }
    Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
    CFSecurityHostNodeByClusterIdxKey existingKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecurityHostNodeByClusterIdxKey newKeyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey existingKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    existingKeyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFSecurityHostNodeByUDescrIdxKey newKeyUDescrIdx =
        schema.getFactoryHostNode().newUDescrIdxKey();
    newKeyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey existingKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    existingKeyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    existingKeyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

    CFSecurityHostNodeByHostNameIdxKey newKeyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    newKeyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    newKeyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

    // Check unique indexes

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

    if (!existingKeyHostNameIdx.equals(newKeyHostNameIdx)) {
      if (dictByHostNameIdx.containsKey(newKeyHostNameIdx)) {
        throw CFLib.getDefaultExceptionFactory()
            .newUniqueIndexViolationException(
                getClass(), "updateHostNode", "HostNodeUHostNameIdx", newKeyHostNameIdx);
      }
    }

    // Validate foreign keys

    {
      boolean allNull = true;

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

    // Update is valid

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

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

    dictByHostNameIdx.remove(existingKeyHostNameIdx);
    dictByHostNameIdx.put(newKeyHostNameIdx, Buff);
  }
  public void deleteHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "deleteHostNode";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      long ClusterId = Buff.getRequiredClusterId();
      long HostNodeId = Buff.getRequiredHostNodeId();

      String sql =
          "SELECT "
              + schema.getLowerDbSchemaName()
              + ".sp_delete_hostnode( ?, ?, ?, ?, ?"
              + ", "
              + "?"
              + ", "
              + "?"
              + ", "
              + "?"
              + " ) as DeletedFlag";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, ClusterId);
      stmtDeleteByPKey.setLong(argIdx++, HostNodeId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      resultSet = stmtDeleteByPKey.executeQuery();
      if (resultSet.next()) {
        boolean deleteFlag = resultSet.getBoolean(1);
        if (resultSet.next()) {
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
        }
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newRuntimeException(
                getClass(),
                S_ProcName,
                "Expected 1 record result set to be returned by delete, not 0 rows");
      }
    } 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 updateHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
   final String S_ProcName = "updateHostNode";
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     long HostNodeId = Buff.getRequiredHostNodeId();
     String Description = Buff.getRequiredDescription();
     String HostName = Buff.getRequiredHostName();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql =
         "exec sp_update_hostnode ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?";
     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++, "HSND");
     stmtUpdateByPKey.setLong(argIdx++, ClusterId);
     stmtUpdateByPKey.setLong(argIdx++, HostNodeId);
     stmtUpdateByPKey.setString(argIdx++, Description);
     stmtUpdateByPKey.setString(argIdx++, HostName);
     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()) {
       CFSecurityHostNodeBuff updatedBuff = unpackHostNodeResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
       Buff.setRequiredHostName(updatedBuff.getRequiredHostName());
       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 startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    try {
      // Common XML Attributes
      String attrId = null;
      String attrRevision = null;
      // HostNode Attributes
      String attrClusterId = null;
      String attrHostNodeId = null;
      String attrDescription = null;
      String attrHostName = null;
      String attrCreatedAt = null;
      String attrCreatedBy = null;
      String attrUpdatedAt = null;
      String attrUpdatedBy = null;
      // Attribute Extraction
      String attrLocalName;
      int numAttrs;
      int idxAttr;
      final String S_ProcName = "startElement";
      final String S_LocalName = "LocalName";

      assert qName.equals("RspnHostNodeCreated");

      CFBamXMsgRspnHandler xmsgRspnHandler = (CFBamXMsgRspnHandler) getParser();
      if (xmsgRspnHandler == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser()");
      }

      ICFBamSchemaObj schemaObj = xmsgRspnHandler.getSchemaObj();
      if (schemaObj == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()");
      }

      // Extract Attributes
      numAttrs = attrs.getLength();
      for (idxAttr = 0; idxAttr < numAttrs; idxAttr++) {
        attrLocalName = attrs.getLocalName(idxAttr);
        if (attrLocalName.equals("Id")) {
          if (attrId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("Revision")) {
          if (attrRevision != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrRevision = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("CreatedAt")) {
          if (attrCreatedAt != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrCreatedAt = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("CreatedBy")) {
          if (attrCreatedBy != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrCreatedBy = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("UpdatedAt")) {
          if (attrUpdatedAt != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrUpdatedAt = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("UpdatedBy")) {
          if (attrUpdatedBy != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrUpdatedBy = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("ClusterId")) {
          if (attrClusterId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrClusterId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("HostNodeId")) {
          if (attrHostNodeId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrHostNodeId = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("Description")) {
          if (attrDescription != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrDescription = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("HostName")) {
          if (attrHostName != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrHostName = attrs.getValue(idxAttr);
        } else if (attrLocalName.equals("schemaLocation")) {
          // ignored
        } else {
          throw CFLib.getDefaultExceptionFactory()
              .newUnrecognizedAttributeException(
                  getClass(), S_ProcName, getParser().getLocationInfo(), attrLocalName);
        }
      }

      // Ensure that required attributes have values
      if ((attrClusterId == null) || (attrClusterId.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "ClusterId");
      }
      if ((attrHostNodeId == null) || (attrHostNodeId.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "HostNodeId");
      }
      if (attrDescription == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "Description");
      }
      if (attrHostName == null) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "HostName");
      }
      if ((attrRevision == null) || (attrRevision.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "Revision");
      }

      // Save named attributes to context
      CFLibXmlCoreContext curContext = getParser().getCurContext();

      // Convert string attributes to native Java types

      long natClusterId = Long.parseLong(attrClusterId);

      long natHostNodeId = Long.parseLong(attrHostNodeId);

      String natDescription = attrDescription;

      String natHostName = attrHostName;

      int natRevision = Integer.parseInt(attrRevision);
      UUID createdBy = null;
      if (attrCreatedBy != null) {
        createdBy = UUID.fromString(attrCreatedBy);
      }
      Calendar createdAt = null;
      if (attrCreatedAt != null) {
        createdAt = CFLibXmlUtil.parseTimestamp(attrCreatedAt);
      }
      UUID updatedBy = null;
      if (attrUpdatedBy != null) {
        updatedBy = UUID.fromString(attrUpdatedBy);
      }
      Calendar updatedAt = null;
      if (attrUpdatedAt != null) {
        updatedAt = CFLibXmlUtil.parseTimestamp(attrUpdatedAt);
      }
      // Instantiate a buffer for the parsed information
      ICFBamHostNodeObj obj = (ICFBamHostNodeObj) schemaObj.getHostNodeTableObj().newInstance();
      CFSecurityHostNodeBuff dataBuff = obj.getHostNodeBuff();
      dataBuff.setRequiredClusterId(natClusterId);
      dataBuff.setRequiredHostNodeId(natHostNodeId);
      dataBuff.setRequiredDescription(natDescription);
      dataBuff.setRequiredHostName(natHostName);
      dataBuff.setRequiredRevision(natRevision);
      if (createdBy != null) {
        dataBuff.setCreatedByUserId(createdBy);
      }
      if (createdAt != null) {
        dataBuff.setCreatedAt(createdAt);
      }
      if (updatedBy != null) {
        dataBuff.setUpdatedByUserId(updatedBy);
      }
      if (updatedAt != null) {
        dataBuff.setUpdatedAt(updatedAt);
      }
      obj.copyBuffToPKey();
      ICFBamHostNodeObj realized = (ICFBamHostNodeObj) obj.realize();
      xmsgRspnHandler.setLastObjectProcessed(realized);
    } catch (RuntimeException e) {
      throw new RuntimeException(
          "Near "
              + getParser().getLocationInfo()
              + ": Caught and rethrew "
              + e.getClass().getName()
              + " - "
              + e.getMessage(),
          e);
    } catch (Error e) {
      throw new Error(
          "Near "
              + getParser().getLocationInfo()
              + ": Caught and rethrew "
              + e.getClass().getName()
              + " - "
              + e.getMessage(),
          e);
    }
  }
 public void copyPKeyToBuff() {
   buff.setRequiredClusterId(getPKey().getRequiredClusterId());
   buff.setRequiredHostNodeId(getPKey().getRequiredHostNodeId());
 }
  public void deleteHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "CFAccRamHostNodeTable.deleteHostNode() ";
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
    CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
    if (existing == null) {
      return;
    }
    if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
      throw CFLib.getDefaultExceptionFactory()
          .newCollisionDetectedException(getClass(), "deleteHostNode", pkey);
    }
    CFSecurityHostNodeByClusterIdxKey keyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
    keyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    keyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
    keyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

    // Validate reverse foreign keys

    // Delete is valid

    schema
        .getTableService()
        .deleteServiceByHostIdx(
            Authorization, Buff.getRequiredClusterId(), Buff.getRequiredHostNodeId());
    Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdict;

    dictByPKey.remove(pkey);

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

    dictByUDescrIdx.remove(keyUDescrIdx);

    dictByHostNameIdx.remove(keyHostNameIdx);
  }
  public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
    final String S_ProcName = "createHostNode";
    CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
    pkey.setRequiredClusterId(Buff.getRequiredClusterId());
    pkey.setRequiredHostNodeId(
        ((CFAccRamClusterTable) schema.getTableCluster())
            .nextHostNodeIdGen(Authorization, Buff.getRequiredClusterId()));
    Buff.setRequiredClusterId(pkey.getRequiredClusterId());
    Buff.setRequiredHostNodeId(pkey.getRequiredHostNodeId());
    CFSecurityHostNodeByClusterIdxKey keyClusterIdx =
        schema.getFactoryHostNode().newClusterIdxKey();
    keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

    CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
    keyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

    CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx =
        schema.getFactoryHostNode().newHostNameIdxKey();
    keyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
    keyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

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

    if (dictByHostNameIdx.containsKey(keyHostNameIdx)) {
      throw CFLib.getDefaultExceptionFactory()
          .newUniqueIndexViolationException(
              getClass(), S_ProcName, "HostNodeUHostNameIdx", keyHostNameIdx);
    }

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

    // Proceed with adding the new record

    dictByPKey.put(pkey, Buff);

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

    dictByUDescrIdx.put(keyUDescrIdx, Buff);

    dictByHostNameIdx.put(keyHostNameIdx, Buff);
  }
 public void copyBuffToPKey() {
   getPKey().setRequiredClusterId(buff.getRequiredClusterId());
   getPKey().setRequiredHostNodeId(buff.getRequiredHostNodeId());
 }
  protected CFSecurityHostNodeBuff unpackHostNodeResultSetToBuff(ResultSet resultSet)
      throws SQLException {
    final String S_ProcName = "unpackHostNodeResultSetToBuff";
    int idxcol = 1;
    CFSecurityHostNodeBuff buff = schema.getFactoryHostNode().newBuff();
    {
      String colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedByUserId(null);
      } else {
        buff.setCreatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setCreatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setCreatedAt(null);
      } else {
        buff.setCreatedAt(CFDbTestMSSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedByUserId(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedByUserId(null);
      } else {
        buff.setUpdatedByUserId(UUID.fromString(colString));
      }
      idxcol++;

      colString = resultSet.getString(idxcol);
      if (resultSet.wasNull()) {
        buff.setUpdatedAt(null);
      } else if ((colString == null) || (colString.length() <= 0)) {
        buff.setUpdatedAt(null);
      } else {
        buff.setUpdatedAt(CFDbTestMSSqlSchema.convertTimestampString(colString));
      }
      idxcol++;
    }
    buff.setRequiredClusterId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredHostNodeId(resultSet.getLong(idxcol));
    idxcol++;
    buff.setRequiredDescription(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredHostName(resultSet.getString(idxcol));
    idxcol++;
    buff.setRequiredRevision(resultSet.getInt(idxcol));
    return (buff);
  }
 public void copyBuffToOrig() {
   CFSecurityHostNodeBuff origBuff = getOrigAsHostNode().getHostNodeBuff();
   CFSecurityHostNodeBuff myBuff = getHostNodeBuff();
   origBuff.set(myBuff);
 }
 public void copyOrigToBuff() {
   CFSecurityHostNodeBuff origBuff = getOrigAsHostNode().getHostNodeBuff();
   CFSecurityHostNodeBuff myBuff = getHostNodeBuff();
   myBuff.set(origBuff);
 }
 public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
   final String S_ProcName = "createHostNode";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     long ClusterId = Buff.getRequiredClusterId();
     String Description = Buff.getRequiredDescription();
     String HostName = Buff.getRequiredHostName();
     Connection cnx = schema.getCnx();
     String sql =
         "select * from "
             + schema.getLowerDbSchemaName()
             + ".sp_create_hostnode( ?, ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     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++, "HSND");
     stmtCreateByPKey.setLong(argIdx++, ClusterId);
     stmtCreateByPKey.setString(argIdx++, Description);
     stmtCreateByPKey.setString(argIdx++, HostName);
     resultSet = stmtCreateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityHostNodeBuff createdBuff = unpackHostNodeResultSetToBuff(resultSet);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
       Buff.setRequiredClusterId(createdBuff.getRequiredClusterId());
       Buff.setRequiredHostNodeId(createdBuff.getRequiredHostNodeId());
       Buff.setRequiredDescription(createdBuff.getRequiredDescription());
       Buff.setRequiredHostName(createdBuff.getRequiredHostName());
       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;
     }
   }
 }