public int compareTo(Object obj) {
   if (obj == null) {
     return (1);
   } else if (obj instanceof CFBamClearTopDepByContTblIdxKey) {
     CFBamClearTopDepByContTblIdxKey rhs = (CFBamClearTopDepByContTblIdxKey) obj;
     if (getRequiredTenantId() < rhs.getRequiredTenantId()) {
       return (-1);
     } else if (getRequiredTenantId() > rhs.getRequiredTenantId()) {
       return (1);
     }
     if (getRequiredContTableId() < rhs.getRequiredContTableId()) {
       return (-1);
     } else if (getRequiredContTableId() > rhs.getRequiredContTableId()) {
       return (1);
     }
     return (0);
   } else if (obj instanceof CFBamClearTopDepBuff) {
     CFBamClearTopDepBuff rhs = (CFBamClearTopDepBuff) obj;
     if (getRequiredTenantId() < rhs.getRequiredTenantId()) {
       return (-1);
     } else if (getRequiredTenantId() > rhs.getRequiredTenantId()) {
       return (1);
     }
     if (getRequiredContTableId() < rhs.getRequiredContTableId()) {
       return (-1);
     } else if (getRequiredContTableId() > rhs.getRequiredContTableId()) {
       return (1);
     }
     return (0);
   } else {
     throw CFLib.getDefaultExceptionFactory()
         .newUnsupportedClassException(getClass(), "compareTo", "obj", obj, null);
   }
 }
  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 boolean equals(Object obj) {
   if (obj == null) {
     return (false);
   } else if (obj instanceof CFBamClearTopDepByContTblIdxKey) {
     CFBamClearTopDepByContTblIdxKey rhs = (CFBamClearTopDepByContTblIdxKey) obj;
     if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
       return (false);
     }
     if (getRequiredContTableId() != rhs.getRequiredContTableId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFBamClearTopDepBuff) {
     CFBamClearTopDepBuff rhs = (CFBamClearTopDepBuff) obj;
     if (getRequiredTenantId() != rhs.getRequiredTenantId()) {
       return (false);
     }
     if (getRequiredContTableId() != rhs.getRequiredContTableId()) {
       return (false);
     }
     return (true);
   } else {
     return (false);
   }
 }
 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 int compareTo(Object obj) {
    if (obj == null) {
      return (-1);
    } else if (obj instanceof CFBamClearTopDepBuff) {
      CFBamClearTopDepBuff rhs = (CFBamClearTopDepBuff) obj;
      int retval = super.compareTo(rhs);
      if (retval != 0) {
        return (retval);
      }
      return (0);
    } else if (obj instanceof CFBamClearTopDepByContTblIdxKey) {
      CFBamClearTopDepByContTblIdxKey rhs = (CFBamClearTopDepByContTblIdxKey) obj;

      if (getRequiredTenantId() < rhs.getRequiredTenantId()) {
        return (-1);
      } else if (getRequiredTenantId() > rhs.getRequiredTenantId()) {
        return (1);
      }
      if (getRequiredContTableId() < rhs.getRequiredContTableId()) {
        return (-1);
      } else if (getRequiredContTableId() > rhs.getRequiredContTableId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFBamClearTopDepByUNameIdxKey) {
      CFBamClearTopDepByUNameIdxKey rhs = (CFBamClearTopDepByUNameIdxKey) obj;

      if (getRequiredTenantId() < rhs.getRequiredTenantId()) {
        return (-1);
      } else if (getRequiredTenantId() > rhs.getRequiredTenantId()) {
        return (1);
      }
      if (getRequiredContTableId() < rhs.getRequiredContTableId()) {
        return (-1);
      } else if (getRequiredContTableId() > rhs.getRequiredContTableId()) {
        return (1);
      }
      {
        int cmp = getRequiredName().compareTo(rhs.getRequiredName());
        if (cmp != 0) {
          return (cmp);
        }
      }
      return (0);
    } else if (obj instanceof CFBamClearTopDepHBuff) {
      CFBamClearTopDepHBuff rhs = (CFBamClearTopDepHBuff) obj;

      int retval = super.compareTo(rhs);
      if (retval != 0) {
        return (retval);
      }
      {
        long lhsAuditClusterId = getAuditClusterId();
        long rhsAuditClusterId = rhs.getAuditClusterId();
        if (lhsAuditClusterId < rhsAuditClusterId) {
          return (-1);
        } else if (lhsAuditClusterId > rhsAuditClusterId) {
          return (1);
        }
      }
      {
        Calendar lhsAuditStamp = getAuditStamp();
        Calendar rhsAuditStamp = rhs.getAuditStamp();
        if (lhsAuditStamp == null) {
          if (rhsAuditStamp != null) {
            return (-1);
          }
        } else if (rhsAuditStamp == null) {
          return (1);
        } else {
          int cmpstat = lhsAuditStamp.compareTo(rhsAuditStamp);
          if (cmpstat != 0) {
            return (cmpstat);
          }
        }
      }
      {
        short lhsAuditActionId = getAuditActionId();
        short rhsAuditActionId = rhs.getAuditActionId();
        if (lhsAuditActionId < rhsAuditActionId) {
          return (-1);
        } else if (lhsAuditActionId > rhsAuditActionId) {
          return (1);
        }
      }
      {
        int lhsRequiredRevision = getRequiredRevision();
        int rhsRequiredRevision = rhs.getRequiredRevision();
        if (lhsRequiredRevision < rhsRequiredRevision) {
          return (-1);
        } else if (lhsRequiredRevision > rhsRequiredRevision) {
          return (1);
        }
      }
      {
        UUID lhsAuditSessionId = getAuditSessionId();
        UUID rhsAuditSessionId = rhs.getAuditSessionId();
        if (lhsAuditSessionId == null) {
          if (rhsAuditSessionId != null) {
            return (-1);
          }
        } else if (rhsAuditSessionId == null) {
          return (1);
        } else {
          int cmpstat = lhsAuditSessionId.compareTo(rhsAuditSessionId);
          if (cmpstat != 0) {
            return (cmpstat);
          }
        }
      }
      if (getRequiredTenantId() < rhs.getRequiredTenantId()) {
        return (-1);
      } else if (getRequiredTenantId() > rhs.getRequiredTenantId()) {
        return (1);
      }
      if (getRequiredId() < rhs.getRequiredId()) {
        return (-1);
      } else if (getRequiredId() > rhs.getRequiredId()) {
        return (1);
      }
      if (getRequiredRelationId() < rhs.getRequiredRelationId()) {
        return (-1);
      } else if (getRequiredRelationId() > rhs.getRequiredRelationId()) {
        return (1);
      }
      if (getRequiredContTableId() < rhs.getRequiredContTableId()) {
        return (-1);
      } else if (getRequiredContTableId() > rhs.getRequiredContTableId()) {
        return (1);
      }
      {
        int cmp = getRequiredName().compareTo(rhs.getRequiredName());
        if (cmp != 0) {
          return (cmp);
        }
      }
      return (0);
    } else {
      return (super.compareTo(obj));
    }
  }
 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);
  }