public void deleteSecDeviceByUserIdx(UUID SecUserId) {
   CFSecuritySecDeviceByUserIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
   key.setRequiredSecUserId(SecUserId);
   if (indexByUserIdx == null) {
     indexByUserIdx =
         new HashMap<
             CFSecuritySecDeviceByUserIdxKey,
             Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>>();
   }
   if (indexByUserIdx.containsKey(key)) {
     Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> dict = indexByUserIdx.get(key);
     ((ICFSecuritySchema) schema.getBackingStore())
         .getTableSecDevice()
         .deleteSecDeviceByUserIdx(schema.getAuthorization(), SecUserId);
     Iterator<ICFSecuritySecDeviceObj> iter = dict.values().iterator();
     ICFSecuritySecDeviceObj obj;
     List<ICFSecuritySecDeviceObj> toForget = new LinkedList<ICFSecuritySecDeviceObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexByUserIdx.remove(key);
   } else {
     ((ICFSecuritySchema) schema.getBackingStore())
         .getTableSecDevice()
         .deleteSecDeviceByUserIdx(schema.getAuthorization(), SecUserId);
   }
 }
 public void deleteSecDevice(ICFSecuritySecDeviceObj Obj) {
   ICFSecuritySecDeviceObj obj = Obj;
   ((ICFSecuritySchema) schema.getBackingStore())
       .getTableSecDevice()
       .deleteSecDevice(schema.getAuthorization(), obj.getSecDeviceBuff());
   obj.forget(true);
 }
 public void deleteSecDeviceByIdIdx(UUID SecUserId, String DevName) {
   CFSecuritySecDevicePKey pkey =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey();
   pkey.setRequiredSecUserId(SecUserId);
   pkey.setRequiredDevName(DevName);
   ICFSecuritySecDeviceObj obj = readSecDevice(pkey);
   if (obj != null) {
     ICFSecuritySecDeviceEditObj editObj = (ICFSecuritySecDeviceEditObj) obj.getEdit();
     boolean editStarted;
     if (editObj == null) {
       editObj = (ICFSecuritySecDeviceEditObj) obj.beginEdit();
       if (editObj != null) {
         editStarted = true;
       } else {
         editStarted = false;
       }
     } else {
       editStarted = false;
     }
     if (editObj != null) {
       editObj.delete();
       if (editStarted) {
         editObj.endEdit();
       }
     }
     obj.forget(true);
   }
 }
  public void forgetSecDeviceByUserIdx(UUID SecUserId) {
    if (indexByUserIdx == null) {
      return;
    }
    CFSecuritySecDeviceByUserIdxKey key =
        ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
    key.setRequiredSecUserId(SecUserId);
    if (indexByUserIdx.containsKey(key)) {
      Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx = indexByUserIdx.get(key);
      if (mapUserIdx != null) {
        List<ICFSecuritySecDeviceObj> toForget = new LinkedList<ICFSecuritySecDeviceObj>();
        ICFSecuritySecDeviceObj cur = null;
        Iterator<ICFSecuritySecDeviceObj> iter = mapUserIdx.values().iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          toForget.add(cur);
        }
        iter = toForget.iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          cur.forget(true);
        }
      }

      indexByUserIdx.remove(key);
    }
  }
 public ICFSecuritySecDeviceObj updateSecDevice(ICFSecuritySecDeviceObj Obj) {
   ICFSecuritySecDeviceObj obj = Obj;
   ((ICFSecuritySchema) schema.getBackingStore())
       .getTableSecDevice()
       .updateSecDevice(schema.getAuthorization(), Obj.getSecDeviceBuff());
   obj = (ICFSecuritySecDeviceObj) Obj.realize();
   return (obj);
 }
 public ICFSecuritySecDeviceObj createSecDevice(ICFSecuritySecDeviceObj Obj) {
   ICFSecuritySecDeviceObj obj = Obj;
   CFSecuritySecDeviceBuff buff = obj.getSecDeviceBuff();
   ((ICFSecuritySchema) schema.getBackingStore())
       .getTableSecDevice()
       .createSecDevice(schema.getAuthorization(), buff);
   obj.copyBuffToPKey();
   obj = obj.realize();
   return (obj);
 }
 public void forgetSecDeviceByIdIdx(UUID SecUserId, String DevName) {
   if (members == null) {
     return;
   }
   CFSecuritySecDevicePKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey();
   key.setRequiredSecUserId(SecUserId);
   key.setRequiredDevName(DevName);
   if (members.containsKey(key)) {
     ICFSecuritySecDeviceObj probed = members.get(key);
     if (probed != null) {
       probed.forget(true);
     }
   }
 }
 public void minimizeMemory() {
   allSecDevice = null;
   indexByUserIdx = null;
   List<ICFSecuritySecDeviceObj> toForget = new LinkedList<ICFSecuritySecDeviceObj>();
   ICFSecuritySecDeviceObj cur = null;
   Iterator<ICFSecuritySecDeviceObj> iter = members.values().iterator();
   while (iter.hasNext()) {
     cur = iter.next();
     toForget.add(cur);
   }
   iter = toForget.iterator();
   while (iter.hasNext()) {
     cur = iter.next();
     cur.forget();
   }
 }
 public ICFSecuritySecDeviceObj lockSecDevice(CFSecuritySecDevicePKey pkey) {
   ICFSecuritySecDeviceObj locked = null;
   CFSecuritySecDeviceBuff lockBuff =
       ((ICFSecuritySchema) schema.getBackingStore())
           .getTableSecDevice()
           .lockDerived(schema.getAuthorization(), pkey);
   if (lockBuff != null) {
     locked = schema.getSecDeviceTableObj().newInstance();
     locked.setPKey(
         ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey());
     locked.setBuff(lockBuff);
     locked = (ICFSecuritySecDeviceObj) locked.realize();
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newCollisionDetectedException(getClass(), "lockSecDevice", pkey);
   }
   return (locked);
 }
  public void forgetSecDevice(ICFSecuritySecDeviceObj Obj, boolean forgetSubObjects) {
    ICFSecuritySecDeviceObj obj = Obj;
    CFSecuritySecDevicePKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecuritySecDeviceObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByUserIdx != null) {
        CFSecuritySecDeviceByUserIdxKey keyUserIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.remove(keepObj.getPKey());
        }
      }

      if (allSecDevice != null) {
        allSecDevice.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {}
    }
  }
 public ICFSecuritySecDeviceObj readSecDevice(CFSecuritySecDevicePKey pkey, boolean forceRead) {
   ICFSecuritySecDeviceObj obj = null;
   if ((!forceRead) && members.containsKey(pkey)) {
     obj = members.get(pkey);
   } else {
     CFSecuritySecDeviceBuff readBuff =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecDevice()
             .readDerivedByIdIdx(
                 schema.getAuthorization(),
                 pkey.getRequiredSecUserId(),
                 pkey.getRequiredDevName());
     if (readBuff != null) {
       obj = schema.getSecDeviceTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey());
       obj.setBuff(readBuff);
       obj = (ICFSecuritySecDeviceObj) obj.realize();
     } else if (schema.getCacheMisses()) {
       members.put(pkey, null);
     }
   }
   return (obj);
 }
 public List<ICFSecuritySecDeviceObj> readSecDeviceByUserIdx(UUID SecUserId, boolean forceRead) {
   final String S_ProcName = "readSecDeviceByUserIdx";
   CFSecuritySecDeviceByUserIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
   key.setRequiredSecUserId(SecUserId);
   Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> dict;
   if (indexByUserIdx == null) {
     indexByUserIdx =
         new HashMap<
             CFSecuritySecDeviceByUserIdxKey,
             Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>>();
   }
   if ((!forceRead) && indexByUserIdx.containsKey(key)) {
     dict = indexByUserIdx.get(key);
   } else {
     dict = new HashMap<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>();
     // Allow other threads to dirty-read while we're loading
     indexByUserIdx.put(key, dict);
     ICFSecuritySecDeviceObj obj;
     CFSecuritySecDeviceBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecDevice()
             .readDerivedByUserIdx(schema.getAuthorization(), SecUserId);
     CFSecuritySecDeviceBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getSecDeviceTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey());
       obj.setBuff(buff);
       ICFSecuritySecDeviceObj realized = (ICFSecuritySecDeviceObj) obj.realize();
     }
   }
   Comparator<ICFSecuritySecDeviceObj> cmp =
       new Comparator<ICFSecuritySecDeviceObj>() {
         public int compare(ICFSecuritySecDeviceObj lhs, ICFSecuritySecDeviceObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecuritySecDevicePKey lhsPKey = lhs.getPKey();
             CFSecuritySecDevicePKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFSecuritySecDeviceObj arr[] = new ICFSecuritySecDeviceObj[len];
   Iterator<ICFSecuritySecDeviceObj> valIter = dict.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFSecuritySecDeviceObj> arrayList = new ArrayList<ICFSecuritySecDeviceObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecuritySecDeviceObj> sortedList = arrayList;
   return (sortedList);
 }
 public List<ICFSecuritySecDeviceObj> readAllSecDevice(boolean forceRead) {
   final String S_ProcName = "readAllSecDevice";
   if ((allSecDevice == null) || forceRead) {
     Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> map =
         new HashMap<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>();
     allSecDevice = map;
     CFSecuritySecDeviceBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecDevice()
             .readAllDerived(schema.getAuthorization());
     CFSecuritySecDeviceBuff buff;
     ICFSecuritySecDeviceObj obj;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newPKey());
       obj.setBuff(buff);
       ICFSecuritySecDeviceObj realized = (ICFSecuritySecDeviceObj) obj.realize();
     }
   }
   Comparator<ICFSecuritySecDeviceObj> cmp =
       new Comparator<ICFSecuritySecDeviceObj>() {
         public int compare(ICFSecuritySecDeviceObj lhs, ICFSecuritySecDeviceObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecuritySecDevicePKey lhsPKey = lhs.getPKey();
             CFSecuritySecDevicePKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = allSecDevice.size();
   ICFSecuritySecDeviceObj arr[] = new ICFSecuritySecDeviceObj[len];
   Iterator<ICFSecuritySecDeviceObj> valIter = allSecDevice.values().iterator();
   int idx = 0;
   while ((idx < len) && valIter.hasNext()) {
     arr[idx++] = valIter.next();
   }
   if (idx < len) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   } else if (valIter.hasNext()) {
     throw CFLib.getDefaultExceptionFactory()
         .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len);
   }
   Arrays.sort(arr, cmp);
   ArrayList<ICFSecuritySecDeviceObj> arrayList = new ArrayList<ICFSecuritySecDeviceObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecuritySecDeviceObj> sortedList = arrayList;
   return (sortedList);
 }
  public ICFSecuritySecDeviceObj realizeSecDevice(ICFSecuritySecDeviceObj Obj) {
    ICFSecuritySecDeviceObj obj = Obj;
    CFSecuritySecDevicePKey pkey = obj.getPKey();
    ICFSecuritySecDeviceObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecuritySecDeviceObj existingObj = members.get(pkey);
      keepObj = existingObj;

      /*
       *	We always rebind the data because if we're being called, some index has
       *	been updated and is refreshing it's data, which may or may not have changed
       */

      // Detach object from alternate and duplicate indexes, leave PKey alone

      if (indexByUserIdx != null) {
        CFSecuritySecDeviceByUserIdxKey keyUserIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.remove(keepObj.getPKey());
        }
      }

      keepObj.setBuff(Obj.getBuff());
      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByUserIdx != null) {
        CFSecuritySecDeviceByUserIdxKey keyUserIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.put(keepObj.getPKey(), keepObj);
        }
      }
      if (allSecDevice != null) {
        allSecDevice.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj.setIsNew(false);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allSecDevice != null) {
        allSecDevice.put(keepObj.getPKey(), keepObj);
      }

      if (indexByUserIdx != null) {
        CFSecuritySecDeviceByUserIdxKey keyUserIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(keepObj.getRequiredSecUserId());
        Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> mapUserIdx =
            indexByUserIdx.get(keyUserIdx);
        if (mapUserIdx != null) {
          mapUserIdx.put(keepObj.getPKey(), keepObj);
        }
      }
    }
    return (keepObj);
  }
  public void startElement(String uri, String localName, String qName, Attributes attrs)
      throws SAXException {
    CFDbTestXMsgSchemaMessageFormatter schemaFormatter = null;
    try {
      // Common XML Attributes
      String attrId = null;
      String attrSecUserId = null;
      // Attribute Extraction
      String attrLocalName;
      int numAttrs;
      int idxAttr;
      final String S_ProcName = "startElement";
      final String S_LocalName = "LocalName";

      assert qName.equals("RqstSecDeviceReadByUserIdx");

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

      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();

      ICFDbTestSchemaObj schemaObj = xmsgRqstHandler.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("SecUserId")) {
          if (attrSecUserId != null) {
            throw CFLib.getDefaultExceptionFactory()
                .newUniqueIndexViolationException(
                    getClass(), S_ProcName, S_LocalName, attrLocalName);
          }
          attrSecUserId = 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 ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory()
            .newNullArgumentException(getClass(), S_ProcName, 0, "SecUserId");
      }

      // Save named attributes to context
      CFLibXmlCoreContext curContext = getParser().getCurContext();
      // Convert string attributes to native Java types
      // and apply the converted attributes to the editBuff.

      UUID natSecUserId;
      if ((attrSecUserId == null) || (attrSecUserId.length() <= 0)) {
        natSecUserId = null;
      } else {
        natSecUserId = UUID.fromString(attrSecUserId);
      }

      // Read the objects
      List<ICFSecuritySecDeviceObj> list =
          schemaObj.getSecDeviceTableObj().readSecDeviceByUserIdx(natSecUserId);
      String responseOpening =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFDbTestXMsgSecDeviceMessageFormatter.formatSecDeviceRspnListOpenTag();
      xmsgRqstHandler.appendResponse(responseOpening);
      Iterator<ICFSecuritySecDeviceObj> iter = list.iterator();
      ICFSecuritySecDeviceObj cur;
      String subxml;
      while (iter.hasNext()) {
        cur = iter.next();
        subxml =
            CFDbTestXMsgSecDeviceMessageFormatter.formatSecDeviceRspnDerivedRec(
                "\n\t\t", cur.getSecDeviceBuff());
        xmsgRqstHandler.appendResponse(subxml);
      }
      String responseClosing =
          "\n"
              + "\t"
              + CFDbTestXMsgSecDeviceMessageFormatter.formatSecDeviceRspnListCloseTag()
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.appendResponse(responseClosing);
    } catch (RuntimeException e) {
      CFDbTestXMsgRqstHandler xmsgRqstHandler = ((CFDbTestXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFDbTestXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    } catch (Error e) {
      CFDbTestXMsgRqstHandler xmsgRqstHandler = ((CFDbTestXMsgRqstHandler) getParser());
      schemaFormatter = xmsgRqstHandler.getSchemaMessageFormatter();
      String response =
          schemaFormatter.formatRspnXmlPreamble()
              + "\n"
              + "\t"
              + CFDbTestXMsgSchemaMessageFormatter.formatRspnException("\n\t\t\t", e)
              + "\n"
              + schemaFormatter.formatRspnXmlPostamble();
      xmsgRqstHandler.resetResponse();
      xmsgRqstHandler.appendResponse(response);
      xmsgRqstHandler.setCaughtException(true);
    }
  }