public void deleteSecGroupByClusterIdx(long ClusterId) {
   CFSecuritySecGroupByClusterIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
   key.setRequiredClusterId(ClusterId);
   if (indexByClusterIdx == null) {
     indexByClusterIdx =
         new HashMap<
             CFSecuritySecGroupByClusterIdxKey,
             Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>>();
   }
   if (indexByClusterIdx.containsKey(key)) {
     Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> dict = indexByClusterIdx.get(key);
     ((ICFSecuritySchema) schema.getBackingStore())
         .getTableSecGroup()
         .deleteSecGroupByClusterIdx(schema.getAuthorization(), ClusterId);
     Iterator<ICFSecuritySecGroupObj> iter = dict.values().iterator();
     ICFSecuritySecGroupObj obj;
     List<ICFSecuritySecGroupObj> toForget = new LinkedList<ICFSecuritySecGroupObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexByClusterIdx.remove(key);
   } else {
     ((ICFSecuritySchema) schema.getBackingStore())
         .getTableSecGroup()
         .deleteSecGroupByClusterIdx(schema.getAuthorization(), ClusterId);
   }
 }
  public void forgetSecGroupByClusterIdx(long ClusterId) {
    if (indexByClusterIdx == null) {
      return;
    }
    CFSecuritySecGroupByClusterIdxKey key =
        ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
    key.setRequiredClusterId(ClusterId);
    if (indexByClusterIdx.containsKey(key)) {
      Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
          indexByClusterIdx.get(key);
      if (mapClusterIdx != null) {
        List<ICFSecuritySecGroupObj> toForget = new LinkedList<ICFSecuritySecGroupObj>();
        ICFSecuritySecGroupObj cur = null;
        Iterator<ICFSecuritySecGroupObj> iter = mapClusterIdx.values().iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          toForget.add(cur);
        }
        iter = toForget.iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          cur.forget(true);
        }
      }

      indexByClusterIdx.remove(key);
    }
  }
  public void forgetSecGroup(ICFSecuritySecGroupObj Obj, boolean forgetSubObjects) {
    ICFSecuritySecGroupObj obj = Obj;
    CFSecuritySecGroupPKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecuritySecGroupObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

      if (allSecGroup != null) {
        allSecGroup.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {
        ((ICFSecuritySchemaObj) schema)
            .getSecGroupIncludeTableObj()
            .forgetSecGroupIncludeByGroupIdx(
                keepObj.getRequiredClusterId(), keepObj.getRequiredSecGroupId());
        ((ICFSecuritySchemaObj) schema)
            .getSecGroupMemberTableObj()
            .forgetSecGroupMemberByGroupIdx(
                keepObj.getRequiredClusterId(), keepObj.getRequiredSecGroupId());
        ((ICFSecuritySchemaObj) schema)
            .getSecGroupIncludeTableObj()
            .forgetSecGroupIncludeByIncludeIdx(
                keepObj.getRequiredClusterId(), keepObj.getRequiredSecGroupId());
        ((ICFSecuritySchemaObj) schema)
            .getSecGroupFormTableObj()
            .forgetSecGroupFormByGroupIdx(
                keepObj.getRequiredClusterId(), keepObj.getRequiredSecGroupId());
      }
    }
  }
 public List<ICFSecuritySecGroupObj> readSecGroupByClusterIdx(long ClusterId, boolean forceRead) {
   final String S_ProcName = "readSecGroupByClusterIdx";
   CFSecuritySecGroupByClusterIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
   key.setRequiredClusterId(ClusterId);
   Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> dict;
   if (indexByClusterIdx == null) {
     indexByClusterIdx =
         new HashMap<
             CFSecuritySecGroupByClusterIdxKey,
             Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>>();
   }
   if ((!forceRead) && indexByClusterIdx.containsKey(key)) {
     dict = indexByClusterIdx.get(key);
   } else {
     dict = new HashMap<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj>();
     // Allow other threads to dirty-read while we're loading
     indexByClusterIdx.put(key, dict);
     ICFSecuritySecGroupObj obj;
     CFSecuritySecGroupBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableSecGroup()
             .readDerivedByClusterIdx(schema.getAuthorization(), ClusterId);
     CFSecuritySecGroupBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getSecGroupTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newPKey());
       obj.setBuff(buff);
       ICFSecuritySecGroupObj realized = (ICFSecuritySecGroupObj) obj.realize();
     }
   }
   Comparator<ICFSecuritySecGroupObj> cmp =
       new Comparator<ICFSecuritySecGroupObj>() {
         public int compare(ICFSecuritySecGroupObj lhs, ICFSecuritySecGroupObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecuritySecGroupPKey lhsPKey = lhs.getPKey();
             CFSecuritySecGroupPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFSecuritySecGroupObj arr[] = new ICFSecuritySecGroupObj[len];
   Iterator<ICFSecuritySecGroupObj> 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<ICFSecuritySecGroupObj> arrayList = new ArrayList<ICFSecuritySecGroupObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecuritySecGroupObj> sortedList = arrayList;
   return (sortedList);
 }
  public ICFSecuritySecGroupObj realizeSecGroup(ICFSecuritySecGroupObj Obj) {
    ICFSecuritySecGroupObj obj = Obj;
    CFSecuritySecGroupPKey pkey = obj.getPKey();
    ICFSecuritySecGroupObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecuritySecGroupObj 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 (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

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

      if (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allSecGroup != null) {
        allSecGroup.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 (allSecGroup != null) {
        allSecGroup.put(keepObj.getPKey(), keepObj);
      }

      if (indexByClusterIdx != null) {
        CFSecuritySecGroupByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecuritySecGroupPKey, ICFSecuritySecGroupObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecuritySecGroupByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactorySecGroup().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }