public void forgetClearTopDepByContTblIdx(long TenantId, long ContTableId) {
    if (indexByContTblIdx == null) {
      return;
    }
    CFBamClearTopDepByContTblIdxKey key =
        schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
    key.setRequiredTenantId(TenantId);
    key.setRequiredContTableId(ContTableId);
    if (indexByContTblIdx.containsKey(key)) {
      Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx = indexByContTblIdx.get(key);
      if (mapContTblIdx != null) {
        List<ICFBamClearTopDepObj> toForget = new LinkedList<ICFBamClearTopDepObj>();
        ICFBamClearTopDepObj cur = null;
        Iterator<ICFBamClearTopDepObj> iter = mapContTblIdx.values().iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          toForget.add(cur);
        }
        iter = toForget.iterator();
        while (iter.hasNext()) {
          cur = iter.next();
          cur.forget(true);
        }
      }

      indexByContTblIdx.remove(key);
    }
  }
 public void deleteClearTopDepByContTblIdx(long TenantId, long ContTableId) {
   CFBamClearTopDepByContTblIdxKey key =
       schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContTableId(ContTableId);
   if (indexByContTblIdx == null) {
     indexByContTblIdx =
         new HashMap<CFBamClearTopDepByContTblIdxKey, Map<CFBamScopePKey, ICFBamClearTopDepObj>>();
   }
   if (indexByContTblIdx.containsKey(key)) {
     Map<CFBamScopePKey, ICFBamClearTopDepObj> dict = indexByContTblIdx.get(key);
     schema
         .getBackingStore()
         .getTableClearTopDep()
         .deleteClearTopDepByContTblIdx(schema.getAuthorization(), TenantId, ContTableId);
     Iterator<ICFBamClearTopDepObj> iter = dict.values().iterator();
     ICFBamClearTopDepObj obj;
     List<ICFBamClearTopDepObj> toForget = new LinkedList<ICFBamClearTopDepObj>();
     while (iter.hasNext()) {
       obj = iter.next();
       toForget.add(obj);
     }
     iter = toForget.iterator();
     while (iter.hasNext()) {
       obj = iter.next();
       obj.forget(true);
     }
     indexByContTblIdx.remove(key);
   } else {
     schema
         .getBackingStore()
         .getTableClearTopDep()
         .deleteClearTopDepByContTblIdx(schema.getAuthorization(), TenantId, ContTableId);
   }
 }
 public List<ICFBamClearTopDepObj> readClearTopDepByContTblIdx(
     long TenantId, long ContTableId, boolean forceRead) {
   final String S_ProcName = "readClearTopDepByContTblIdx";
   CFBamClearTopDepByContTblIdxKey key =
       schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
   key.setRequiredTenantId(TenantId);
   key.setRequiredContTableId(ContTableId);
   Map<CFBamScopePKey, ICFBamClearTopDepObj> dict;
   if (indexByContTblIdx == null) {
     indexByContTblIdx =
         new HashMap<CFBamClearTopDepByContTblIdxKey, Map<CFBamScopePKey, ICFBamClearTopDepObj>>();
   }
   if ((!forceRead) && indexByContTblIdx.containsKey(key)) {
     dict = indexByContTblIdx.get(key);
   } else {
     dict = new HashMap<CFBamScopePKey, ICFBamClearTopDepObj>();
     // Allow other threads to dirty-read while we're loading
     indexByContTblIdx.put(key, dict);
     ICFBamClearTopDepObj obj;
     CFBamClearTopDepBuff[] buffList =
         schema
             .getBackingStore()
             .getTableClearTopDep()
             .readDerivedByContTblIdx(schema.getAuthorization(), TenantId, ContTableId);
     CFBamClearTopDepBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj =
           (ICFBamClearTopDepObj)
               schema.getScopeTableObj().constructByClassCode(buff.getClassCode());
       obj.setPKey(schema.getBackingStore().getFactoryScope().newPKey());
       obj.setBuff(buff);
       ICFBamClearTopDepObj realized = (ICFBamClearTopDepObj) obj.realize();
     }
   }
   Comparator<ICFBamClearTopDepObj> cmp =
       new Comparator<ICFBamClearTopDepObj>() {
         public int compare(ICFBamClearTopDepObj lhs, ICFBamClearTopDepObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFBamScopePKey lhsPKey = lhs.getPKey();
             CFBamScopePKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFBamClearTopDepObj arr[] = new ICFBamClearTopDepObj[len];
   Iterator<ICFBamClearTopDepObj> 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<ICFBamClearTopDepObj> arrayList = new ArrayList<ICFBamClearTopDepObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFBamClearTopDepObj> sortedList = arrayList;
   return (sortedList);
 }
  public void forgetClearTopDep(ICFBamClearTopDepObj Obj, boolean forgetSubObjects) {
    ICFBamClearTopDepObj obj = Obj;
    CFBamScopePKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFBamClearTopDepObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          indexByTenantIdx.remove(keyTenantIdx);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          indexByTableIdx.remove(keyTableIdx);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

      if (allClearTopDep != null) {
        allClearTopDep.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {
        schema
            .getClearSubDep1TableObj()
            .forgetClearSubDep1ByContClearTopIdx(
                keepObj.getRequiredTenantId(), keepObj.getRequiredId());
      }
    }
    schema.getClearDepTableObj().forgetClearDep(obj);
  }
  public ICFBamClearTopDepObj realizeClearTopDep(ICFBamClearTopDepObj Obj) {
    ICFBamClearTopDepObj obj = Obj;
    CFBamScopePKey pkey = obj.getPKey();
    ICFBamClearTopDepObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFBamClearTopDepObj 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 (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          indexByTenantIdx.remove(keyTenantIdx);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          indexByTableIdx.remove(keyTableIdx);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.remove(keyUNameIdx);
      }
      // Keep passing the new object because it's the one with the buffer
      // that the base table needs to copy to the existing object from
      // the cache.
      keepObj = (ICFBamClearTopDepObj) schema.getClearDepTableObj().realizeClearDep(Obj);

      // Attach new object to alternate and duplicate indexes -- PKey stay stable

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          mapTableIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allClearTopDep != null) {
        allClearTopDep.put(keepObj.getPKey(), keepObj);
      }
    } else {
      keepObj = obj;
      keepObj = (ICFBamClearTopDepObj) schema.getClearDepTableObj().realizeClearDep(keepObj);
      // Attach new object to PKey, all, alternate, and duplicate indexes
      members.put(keepObj.getPKey(), keepObj);
      if (allClearTopDep != null) {
        allClearTopDep.put(keepObj.getPKey(), keepObj);
      }

      if (indexByTenantIdx != null) {
        CFBamScopeByTenantIdxKey keyTenantIdx =
            schema.getBackingStore().getFactoryScope().newTenantIdxKey();
        keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx);
        if (mapTenantIdx != null) {
          mapTenantIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByTableIdx != null) {
        CFBamClearDepByTableIdxKey keyTableIdx =
            schema.getBackingStore().getFactoryClearDep().newTableIdxKey();
        keyTableIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyTableIdx.setRequiredRelationId(keepObj.getRequiredRelationId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapTableIdx = indexByTableIdx.get(keyTableIdx);
        if (mapTableIdx != null) {
          mapTableIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByContTblIdx != null) {
        CFBamClearTopDepByContTblIdxKey keyContTblIdx =
            schema.getBackingStore().getFactoryClearTopDep().newContTblIdxKey();
        keyContTblIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyContTblIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        Map<CFBamScopePKey, ICFBamClearTopDepObj> mapContTblIdx =
            indexByContTblIdx.get(keyContTblIdx);
        if (mapContTblIdx != null) {
          mapContTblIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFBamClearTopDepByUNameIdxKey keyUNameIdx =
            schema.getBackingStore().getFactoryClearTopDep().newUNameIdxKey();
        keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId());
        keyUNameIdx.setRequiredContTableId(keepObj.getRequiredContTableId());
        keyUNameIdx.setRequiredName(keepObj.getRequiredName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }