public void forgetTenantByClusterIdx(long ClusterId) {
    if (indexByClusterIdx == null) {
      return;
    }
    CFSecurityTenantByClusterIdxKey key =
        ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
    key.setRequiredClusterId(ClusterId);
    if (indexByClusterIdx.containsKey(key)) {
      Map<CFSecurityTenantPKey, ICFSecurityTenantObj> mapClusterIdx = indexByClusterIdx.get(key);
      if (mapClusterIdx != null) {
        List<ICFSecurityTenantObj> toForget = new LinkedList<ICFSecurityTenantObj>();
        ICFSecurityTenantObj cur = null;
        Iterator<ICFSecurityTenantObj> 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 deleteTenantByClusterIdx(long ClusterId) {
   CFSecurityTenantByClusterIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
   key.setRequiredClusterId(ClusterId);
   if (indexByClusterIdx == null) {
     indexByClusterIdx =
         new HashMap<
             CFSecurityTenantByClusterIdxKey, Map<CFSecurityTenantPKey, ICFSecurityTenantObj>>();
   }
   if (indexByClusterIdx.containsKey(key)) {
     Map<CFSecurityTenantPKey, ICFSecurityTenantObj> dict = indexByClusterIdx.get(key);
     ((ICFSecuritySchema) schema.getBackingStore())
         .getTableTenant()
         .deleteTenantByClusterIdx(schema.getAuthorization(), ClusterId);
     Iterator<ICFSecurityTenantObj> iter = dict.values().iterator();
     ICFSecurityTenantObj obj;
     List<ICFSecurityTenantObj> toForget = new LinkedList<ICFSecurityTenantObj>();
     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())
         .getTableTenant()
         .deleteTenantByClusterIdx(schema.getAuthorization(), ClusterId);
   }
 }
  public void forgetTenant(ICFSecurityTenantObj Obj, boolean forgetSubObjects) {
    ICFSecurityTenantObj obj = Obj;
    CFSecurityTenantPKey pkey = obj.getPKey();
    if (members.containsKey(pkey)) {
      ICFSecurityTenantObj keepObj = members.get(pkey);
      // Detach object from alternate, duplicate, all and PKey indexes

      if (indexByClusterIdx != null) {
        CFSecurityTenantByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecurityTenantPKey, ICFSecurityTenantObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFSecurityTenantByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredTenantName(keepObj.getRequiredTenantName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

      if (allTenant != null) {
        allTenant.remove(keepObj.getPKey());
      }
      members.remove(pkey);
      if (forgetSubObjects) {
        ((ICFSecuritySchemaObj) schema)
            .getTSecGroupTableObj()
            .forgetTSecGroupByTenantIdx(keepObj.getRequiredId());
      }
    }
  }
 public void deleteTenantByClusterIdx(
     CFSecurityAuthorization Authorization, CFSecurityTenantByClusterIdxKey argKey) {
   deleteTenantByClusterIdx(Authorization, argKey.getRequiredClusterId());
 }
 public List<ICFSecurityTenantObj> readTenantByClusterIdx(long ClusterId, boolean forceRead) {
   final String S_ProcName = "readTenantByClusterIdx";
   CFSecurityTenantByClusterIdxKey key =
       ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
   key.setRequiredClusterId(ClusterId);
   Map<CFSecurityTenantPKey, ICFSecurityTenantObj> dict;
   if (indexByClusterIdx == null) {
     indexByClusterIdx =
         new HashMap<
             CFSecurityTenantByClusterIdxKey, Map<CFSecurityTenantPKey, ICFSecurityTenantObj>>();
   }
   if ((!forceRead) && indexByClusterIdx.containsKey(key)) {
     dict = indexByClusterIdx.get(key);
   } else {
     dict = new HashMap<CFSecurityTenantPKey, ICFSecurityTenantObj>();
     // Allow other threads to dirty-read while we're loading
     indexByClusterIdx.put(key, dict);
     ICFSecurityTenantObj obj;
     CFSecurityTenantBuff[] buffList =
         ((ICFSecuritySchema) schema.getBackingStore())
             .getTableTenant()
             .readDerivedByClusterIdx(schema.getAuthorization(), ClusterId);
     CFSecurityTenantBuff buff;
     for (int idx = 0; idx < buffList.length; idx++) {
       buff = buffList[idx];
       obj = schema.getTenantTableObj().newInstance();
       obj.setPKey(((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newPKey());
       obj.setBuff(buff);
       ICFSecurityTenantObj realized = (ICFSecurityTenantObj) obj.realize();
     }
   }
   Comparator<ICFSecurityTenantObj> cmp =
       new Comparator<ICFSecurityTenantObj>() {
         public int compare(ICFSecurityTenantObj lhs, ICFSecurityTenantObj rhs) {
           if (lhs == null) {
             if (rhs == null) {
               return (0);
             } else {
               return (-1);
             }
           } else if (rhs == null) {
             return (1);
           } else {
             CFSecurityTenantPKey lhsPKey = lhs.getPKey();
             CFSecurityTenantPKey rhsPKey = rhs.getPKey();
             int ret = lhsPKey.compareTo(rhsPKey);
             return (ret);
           }
         }
       };
   int len = dict.size();
   ICFSecurityTenantObj arr[] = new ICFSecurityTenantObj[len];
   Iterator<ICFSecurityTenantObj> 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<ICFSecurityTenantObj> arrayList = new ArrayList<ICFSecurityTenantObj>(len);
   for (idx = 0; idx < len; idx++) {
     arrayList.add(arr[idx]);
   }
   List<ICFSecurityTenantObj> sortedList = arrayList;
   return (sortedList);
 }
  public ICFSecurityTenantObj realizeTenant(ICFSecurityTenantObj Obj) {
    ICFSecurityTenantObj obj = Obj;
    CFSecurityTenantPKey pkey = obj.getPKey();
    ICFSecurityTenantObj keepObj = null;
    if (members.containsKey(pkey) && (null != members.get(pkey))) {
      ICFSecurityTenantObj 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) {
        CFSecurityTenantByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecurityTenantPKey, ICFSecurityTenantObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.remove(keepObj.getPKey());
        }
      }

      if (indexByUNameIdx != null) {
        CFSecurityTenantByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredTenantName(keepObj.getRequiredTenantName());
        indexByUNameIdx.remove(keyUNameIdx);
      }

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

      if (indexByClusterIdx != null) {
        CFSecurityTenantByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecurityTenantPKey, ICFSecurityTenantObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecurityTenantByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredTenantName(keepObj.getRequiredTenantName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
      if (allTenant != null) {
        allTenant.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 (allTenant != null) {
        allTenant.put(keepObj.getPKey(), keepObj);
      }

      if (indexByClusterIdx != null) {
        CFSecurityTenantByClusterIdxKey keyClusterIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        Map<CFSecurityTenantPKey, ICFSecurityTenantObj> mapClusterIdx =
            indexByClusterIdx.get(keyClusterIdx);
        if (mapClusterIdx != null) {
          mapClusterIdx.put(keepObj.getPKey(), keepObj);
        }
      }

      if (indexByUNameIdx != null) {
        CFSecurityTenantByUNameIdxKey keyUNameIdx =
            ((ICFSecuritySchema) schema.getBackingStore()).getFactoryTenant().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(keepObj.getRequiredClusterId());
        keyUNameIdx.setRequiredTenantName(keepObj.getRequiredTenantName());
        indexByUNameIdx.put(keyUNameIdx, keepObj);
      }
    }
    return (keepObj);
  }
  public int compareTo(Object obj) {
    if (obj == null) {
      return (-1);
    } else if (obj instanceof CFSecurityTenantBuff) {
      CFSecurityTenantBuff rhs = (CFSecurityTenantBuff) obj;
      int retval = 0;
      {
        int cmp = getCreatedByUserId().compareTo(rhs.getCreatedByUserId());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getCreatedAt().compareTo(rhs.getCreatedAt());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getUpdatedByUserId().compareTo(rhs.getUpdatedByUserId());
        if (cmp != 0) {
          return (cmp);
        }

        cmp = getUpdatedAt().compareTo(rhs.getUpdatedAt());
        if (cmp != 0) {
          return (cmp);
        }
      }
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredId() < rhs.getRequiredId()) {
        return (-1);
      } else if (getRequiredId() > rhs.getRequiredId()) {
        return (1);
      }
      {
        int cmp = getRequiredTenantName().compareTo(rhs.getRequiredTenantName());
        if (cmp != 0) {
          return (cmp);
        }
      }
      return (0);
    } else if (obj instanceof CFSecurityTenantPKey) {
      CFSecurityTenantPKey rhs = (CFSecurityTenantPKey) obj;
      if (getRequiredId() < rhs.getRequiredId()) {
        return (-1);
      } else if (getRequiredId() > rhs.getRequiredId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityTenantHPKey) {
      CFSecurityTenantHPKey rhs = (CFSecurityTenantHPKey) obj;
      {
        int lhsRequiredRevision = getRequiredRevision();
        int rhsRequiredRevision = rhs.getRequiredRevision();
        if (lhsRequiredRevision < rhsRequiredRevision) {
          return (-1);
        } else if (lhsRequiredRevision > rhsRequiredRevision) {
          return (1);
        }
      }
      if (getRequiredId() < rhs.getRequiredId()) {
        return (-1);
      } else if (getRequiredId() > rhs.getRequiredId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityTenantHBuff) {
      CFSecurityTenantHBuff rhs = (CFSecurityTenantHBuff) obj;
      int retval = 0;
      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      if (getRequiredId() < rhs.getRequiredId()) {
        return (-1);
      } else if (getRequiredId() > rhs.getRequiredId()) {
        return (1);
      }
      {
        int cmp = getRequiredTenantName().compareTo(rhs.getRequiredTenantName());
        if (cmp != 0) {
          return (cmp);
        }
      }
      return (0);
    } else if (obj instanceof CFSecurityTenantByClusterIdxKey) {
      CFSecurityTenantByClusterIdxKey rhs = (CFSecurityTenantByClusterIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      return (0);
    } else if (obj instanceof CFSecurityTenantByUNameIdxKey) {
      CFSecurityTenantByUNameIdxKey rhs = (CFSecurityTenantByUNameIdxKey) obj;

      if (getRequiredClusterId() < rhs.getRequiredClusterId()) {
        return (-1);
      } else if (getRequiredClusterId() > rhs.getRequiredClusterId()) {
        return (1);
      }
      {
        int cmp = getRequiredTenantName().compareTo(rhs.getRequiredTenantName());
        if (cmp != 0) {
          return (cmp);
        }
      }
      return (0);
    } else {
      throw CFLib.getDefaultExceptionFactory()
          .newUnsupportedClassException(getClass(), "compareTo", "obj", obj, null);
    }
  }
 public boolean equals(Object obj) {
   if (obj == null) {
     return (false);
   } else if (obj instanceof CFSecurityTenantBuff) {
     CFSecurityTenantBuff rhs = (CFSecurityTenantBuff) obj;
     if (!getCreatedByUserId().equals(rhs.getCreatedByUserId())) {
       return (false);
     }
     if (!getCreatedAt().equals(rhs.getCreatedAt())) {
       return (false);
     }
     if (!getUpdatedByUserId().equals(rhs.getUpdatedByUserId())) {
       return (false);
     }
     if (!getUpdatedAt().equals(rhs.getUpdatedAt())) {
       return (false);
     }
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredId() != rhs.getRequiredId()) {
       return (false);
     }
     if (!getRequiredTenantName().equals(rhs.getRequiredTenantName())) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityTenantPKey) {
     CFSecurityTenantPKey rhs = (CFSecurityTenantPKey) obj;
     if (getRequiredId() != rhs.getRequiredId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityTenantHBuff) {
     CFSecurityTenantHBuff rhs = (CFSecurityTenantHBuff) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (getRequiredId() != rhs.getRequiredId()) {
       return (false);
     }
     if (!getRequiredTenantName().equals(rhs.getRequiredTenantName())) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityTenantHPKey) {
     CFSecurityTenantHPKey rhs = (CFSecurityTenantHPKey) obj;
     if (getRequiredId() != rhs.getRequiredId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityTenantByClusterIdxKey) {
     CFSecurityTenantByClusterIdxKey rhs = (CFSecurityTenantByClusterIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     return (true);
   } else if (obj instanceof CFSecurityTenantByUNameIdxKey) {
     CFSecurityTenantByUNameIdxKey rhs = (CFSecurityTenantByUNameIdxKey) obj;
     if (getRequiredClusterId() != rhs.getRequiredClusterId()) {
       return (false);
     }
     if (!getRequiredTenantName().equals(rhs.getRequiredTenantName())) {
       return (false);
     }
     return (true);
   } else {
     boolean retval = super.equals(obj);
     return (retval);
   }
 }