public ICFInternetDomainObj readDomainByNameIdx( long TenantId, long SubDomainOfId, String Name, boolean forceRead) { if (indexByNameIdx == null) { indexByNameIdx = new HashMap<CFInternetDomainByNameIdxKey, ICFInternetDomainObj>(); } CFInternetDomainByNameIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); key.setRequiredName(Name); ICFInternetDomainObj obj = null; if ((!forceRead) && indexByNameIdx.containsKey(key)) { obj = indexByNameIdx.get(key); } else { CFInternetDomainBuff buff = ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .readDerivedByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name); if (buff != null) { obj = (ICFInternetDomainObj) schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode()); obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey()); obj.setBuff(buff); obj = (ICFInternetDomainObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByNameIdx.put(key, null); } } return (obj); }
public void deleteDomainBySubDomIdx(long TenantId, long SubDomainOfId) { CFInternetDomainBySubDomIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); if (indexBySubDomIdx == null) { indexBySubDomIdx = new HashMap< CFInternetDomainBySubDomIdxKey, Map<CFInternetDomainBasePKey, ICFInternetDomainObj>>(); } if (indexBySubDomIdx.containsKey(key)) { Map<CFInternetDomainBasePKey, ICFInternetDomainObj> dict = indexBySubDomIdx.get(key); ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .deleteDomainBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId); Iterator<ICFInternetDomainObj> iter = dict.values().iterator(); ICFInternetDomainObj obj; List<ICFInternetDomainObj> toForget = new LinkedList<ICFInternetDomainObj>(); while (iter.hasNext()) { obj = iter.next(); toForget.add(obj); } iter = toForget.iterator(); while (iter.hasNext()) { obj = iter.next(); obj.forget(true); } indexBySubDomIdx.remove(key); } else { ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .deleteDomainBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId); } }
public void forgetDomain(ICFInternetDomainObj Obj, boolean forgetSubObjects) { ICFInternetDomainObj obj = Obj; CFInternetDomainBasePKey pkey = obj.getPKey(); if (members.containsKey(pkey)) { ICFInternetDomainObj keepObj = members.get(pkey); // Detach object from alternate, duplicate, all and PKey indexes if (indexByTenantIdx != null) { CFInternetDomainBaseByTenantIdxKey keyTenantIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { indexByTenantIdx.remove(keyTenantIdx); } } if (indexBySubDomIdx != null) { CFInternetDomainBySubDomIdxKey keySubDomIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); keySubDomIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keySubDomIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapSubDomIdx = indexBySubDomIdx.get(keySubDomIdx); if (mapSubDomIdx != null) { mapSubDomIdx.remove(keepObj.getPKey()); } } if (indexByNameIdx != null) { CFInternetDomainByNameIdxKey keyNameIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); keyNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyNameIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); keyNameIdx.setRequiredName(keepObj.getRequiredName()); indexByNameIdx.remove(keyNameIdx); } if (allDomain != null) { allDomain.remove(keepObj.getPKey()); } members.remove(pkey); if (forgetSubObjects) { ((ICFInternetSchemaObj) schema) .getTopProjectTableObj() .forgetTopProjectByDomainIdx(keepObj.getRequiredTenantId(), keepObj.getRequiredId()); } } ((ICFBamSchemaObj) schema).getDomainBaseTableObj().forgetDomainBase(obj); }
public void deleteDomainByIdIdx(long TenantId, long Id) { CFInternetDomainBasePKey pkey = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey(); pkey.setRequiredTenantId(TenantId); pkey.setRequiredId(Id); ICFInternetDomainObj obj = readDomain(pkey); if (obj != null) { ICFInternetDomainEditObj editObj = (ICFInternetDomainEditObj) obj.getEdit(); boolean editStarted; if (editObj == null) { editObj = (ICFInternetDomainEditObj) 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 deleteDomain(ICFInternetDomainObj Obj) { ICFInternetDomainObj obj = Obj; ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .deleteDomain(schema.getAuthorization(), obj.getDomainBuff()); obj.forget(true); }
public void forgetDomainBySubDomIdx(long TenantId, long SubDomainOfId) { if (indexBySubDomIdx == null) { return; } CFInternetDomainBySubDomIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); if (indexBySubDomIdx.containsKey(key)) { Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapSubDomIdx = indexBySubDomIdx.get(key); if (mapSubDomIdx != null) { List<ICFInternetDomainObj> toForget = new LinkedList<ICFInternetDomainObj>(); ICFInternetDomainObj cur = null; Iterator<ICFInternetDomainObj> iter = mapSubDomIdx.values().iterator(); while (iter.hasNext()) { cur = iter.next(); toForget.add(cur); } iter = toForget.iterator(); while (iter.hasNext()) { cur = iter.next(); cur.forget(true); } } indexBySubDomIdx.remove(key); } }
public ICFInternetDomainObj readDomainByIdIdx(long TenantId, long Id, boolean forceRead) { CFInternetDomainBasePKey pkey = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey(); pkey.setRequiredTenantId(TenantId); pkey.setRequiredId(Id); ICFInternetDomainObj obj = readDomain(pkey, forceRead); return (obj); }
public ICFInternetDomainObj updateDomain(ICFInternetDomainObj Obj) { ICFInternetDomainObj obj = Obj; ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .updateDomain(schema.getAuthorization(), Obj.getDomainBuff()); if (Obj.getClassCode().equals("DOMN")) { obj = (ICFInternetDomainObj) Obj.realize(); } return (obj); }
public ICFInternetDomainObj lockDomain(CFInternetDomainBasePKey pkey) { ICFInternetDomainObj locked = null; CFInternetDomainBuff lockBuff = ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .lockDerived(schema.getAuthorization(), pkey); if (lockBuff != null) { locked = (ICFInternetDomainObj) schema.getDomainBaseTableObj().constructByClassCode(lockBuff.getClassCode()); locked.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey()); locked.setBuff(lockBuff); locked = (ICFInternetDomainObj) locked.realize(); } else { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "lockDomain", pkey); } return (locked); }
public ICFInternetDomainObj createDomain(ICFInternetDomainObj Obj) { ICFInternetDomainObj obj = Obj; CFInternetDomainBuff buff = obj.getDomainBuff(); ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .createDomain(schema.getAuthorization(), buff); obj.copyBuffToPKey(); if (obj.getPKey().getClassCode().equals("DOMN")) { obj = (ICFInternetDomainObj) (obj.realize()); } return (obj); }
public void deleteDomainByNameIdx(long TenantId, long SubDomainOfId, String Name) { if (indexByNameIdx == null) { indexByNameIdx = new HashMap<CFInternetDomainByNameIdxKey, ICFInternetDomainObj>(); } CFInternetDomainByNameIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); key.setRequiredName(Name); ICFInternetDomainObj obj = null; if (indexByNameIdx.containsKey(key)) { obj = indexByNameIdx.get(key); ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .deleteDomainByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name); obj.forget(true); } else { ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .deleteDomainByNameIdx(schema.getAuthorization(), TenantId, SubDomainOfId, Name); } }
public ICFInternetDomainObj readDomain(CFInternetDomainBasePKey pkey, boolean forceRead) { ICFInternetDomainObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFInternetDomainBuff readBuff = ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .readDerivedByIdIdx( schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredId()); if (readBuff != null) { obj = (ICFInternetDomainObj) schema.getDomainBaseTableObj().constructByClassCode(readBuff.getClassCode()); obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey()); obj.setBuff(readBuff); obj = (ICFInternetDomainObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public void forgetDomainByIdIdx(long TenantId, long Id) { if (members == null) { return; } CFInternetDomainBasePKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredId(Id); if (members.containsKey(key)) { ICFInternetDomainObj probed = members.get(key); if (probed != null) { probed.forget(true); } } }
public void forgetDomainByNameIdx(long TenantId, long SubDomainOfId, String Name) { if (indexByNameIdx == null) { return; } CFInternetDomainByNameIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); key.setRequiredName(Name); if (indexByNameIdx.containsKey(key)) { ICFInternetDomainObj probed = indexByNameIdx.get(key); if (probed != null) { probed.forget(true); } indexByNameIdx.remove(key); } }
public List<ICFInternetDomainObj> readDomainBySubDomIdx( long TenantId, long SubDomainOfId, boolean forceRead) { final String S_ProcName = "readDomainBySubDomIdx"; CFInternetDomainBySubDomIdxKey key = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredSubDomainOfId(SubDomainOfId); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> dict; if (indexBySubDomIdx == null) { indexBySubDomIdx = new HashMap< CFInternetDomainBySubDomIdxKey, Map<CFInternetDomainBasePKey, ICFInternetDomainObj>>(); } if ((!forceRead) && indexBySubDomIdx.containsKey(key)) { dict = indexBySubDomIdx.get(key); } else { dict = new HashMap<CFInternetDomainBasePKey, ICFInternetDomainObj>(); // Allow other threads to dirty-read while we're loading indexBySubDomIdx.put(key, dict); ICFInternetDomainObj obj; CFInternetDomainBuff[] buffList = ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .readDerivedBySubDomIdx(schema.getAuthorization(), TenantId, SubDomainOfId); CFInternetDomainBuff buff; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = (ICFInternetDomainObj) schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode()); obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey()); obj.setBuff(buff); ICFInternetDomainObj realized = (ICFInternetDomainObj) obj.realize(); } } Comparator<ICFInternetDomainObj> cmp = new Comparator<ICFInternetDomainObj>() { public int compare(ICFInternetDomainObj lhs, ICFInternetDomainObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFInternetDomainBasePKey lhsPKey = lhs.getPKey(); CFInternetDomainBasePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = dict.size(); ICFInternetDomainObj arr[] = new ICFInternetDomainObj[len]; Iterator<ICFInternetDomainObj> 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<ICFInternetDomainObj> arrayList = new ArrayList<ICFInternetDomainObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFInternetDomainObj> sortedList = arrayList; return (sortedList); }
public List<ICFInternetDomainObj> readAllDomain(boolean forceRead) { final String S_ProcName = "readAllDomain"; if ((allDomain == null) || forceRead) { Map<CFInternetDomainBasePKey, ICFInternetDomainObj> map = new HashMap<CFInternetDomainBasePKey, ICFInternetDomainObj>(); allDomain = map; CFInternetDomainBuff[] buffList = ((ICFBamSchema) schema.getBackingStore()) .getTableDomain() .readAllDerived(schema.getAuthorization()); CFInternetDomainBuff buff; ICFInternetDomainObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = (ICFInternetDomainObj) schema.getDomainBaseTableObj().constructByClassCode(buff.getClassCode()); obj.setPKey(((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newPKey()); obj.setBuff(buff); ICFInternetDomainObj realized = (ICFInternetDomainObj) obj.realize(); } } Comparator<ICFInternetDomainObj> cmp = new Comparator<ICFInternetDomainObj>() { public int compare(ICFInternetDomainObj lhs, ICFInternetDomainObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFInternetDomainBasePKey lhsPKey = lhs.getPKey(); CFInternetDomainBasePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allDomain.size(); ICFInternetDomainObj arr[] = new ICFInternetDomainObj[len]; Iterator<ICFInternetDomainObj> valIter = allDomain.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<ICFInternetDomainObj> arrayList = new ArrayList<ICFInternetDomainObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFInternetDomainObj> sortedList = arrayList; return (sortedList); }
public ICFInternetDomainObj realizeDomain(ICFInternetDomainObj Obj) { ICFInternetDomainObj obj = Obj; CFInternetDomainBasePKey pkey = obj.getPKey(); ICFInternetDomainObj keepObj = null; if (members.containsKey(pkey) && (null != members.get(pkey))) { ICFInternetDomainObj 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) { CFInternetDomainBaseByTenantIdxKey keyTenantIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { indexByTenantIdx.remove(keyTenantIdx); } } if (indexBySubDomIdx != null) { CFInternetDomainBySubDomIdxKey keySubDomIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); keySubDomIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keySubDomIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapSubDomIdx = indexBySubDomIdx.get(keySubDomIdx); if (mapSubDomIdx != null) { mapSubDomIdx.remove(keepObj.getPKey()); } } if (indexByNameIdx != null) { CFInternetDomainByNameIdxKey keyNameIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); keyNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyNameIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); keyNameIdx.setRequiredName(keepObj.getRequiredName()); indexByNameIdx.remove(keyNameIdx); } // 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 = (ICFInternetDomainObj) schema.getDomainBaseTableObj().realizeDomainBase(Obj); // Attach new object to alternate and duplicate indexes -- PKey stay stable if (indexByTenantIdx != null) { CFInternetDomainBaseByTenantIdxKey keyTenantIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexBySubDomIdx != null) { CFInternetDomainBySubDomIdxKey keySubDomIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); keySubDomIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keySubDomIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapSubDomIdx = indexBySubDomIdx.get(keySubDomIdx); if (mapSubDomIdx != null) { mapSubDomIdx.put(keepObj.getPKey(), keepObj); } } if (indexByNameIdx != null) { CFInternetDomainByNameIdxKey keyNameIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); keyNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyNameIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); keyNameIdx.setRequiredName(keepObj.getRequiredName()); indexByNameIdx.put(keyNameIdx, keepObj); } if (allDomain != null) { allDomain.put(keepObj.getPKey(), keepObj); } } else { keepObj = obj; keepObj = (ICFInternetDomainObj) schema.getDomainBaseTableObj().realizeDomainBase(keepObj); // Attach new object to PKey, all, alternate, and duplicate indexes members.put(keepObj.getPKey(), keepObj); if (allDomain != null) { allDomain.put(keepObj.getPKey(), keepObj); } if (indexByTenantIdx != null) { CFInternetDomainBaseByTenantIdxKey keyTenantIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomainBase().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexBySubDomIdx != null) { CFInternetDomainBySubDomIdxKey keySubDomIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newSubDomIdxKey(); keySubDomIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keySubDomIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); Map<CFInternetDomainBasePKey, ICFInternetDomainObj> mapSubDomIdx = indexBySubDomIdx.get(keySubDomIdx); if (mapSubDomIdx != null) { mapSubDomIdx.put(keepObj.getPKey(), keepObj); } } if (indexByNameIdx != null) { CFInternetDomainByNameIdxKey keyNameIdx = ((ICFBamSchema) schema.getBackingStore()).getFactoryDomain().newNameIdxKey(); keyNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyNameIdx.setRequiredSubDomainOfId(keepObj.getRequiredSubDomainOfId()); keyNameIdx.setRequiredName(keepObj.getRequiredName()); indexByNameIdx.put(keyNameIdx, keepObj); } } return (keepObj); }