public void forgetMemo(ICFCrmMemoObj Obj, boolean forgetSubObjects) { ICFCrmMemoObj obj = Obj; CFCrmMemoPKey pkey = obj.getPKey(); if (members.containsKey(pkey)) { ICFCrmMemoObj keepObj = members.get(pkey); // Detach object from alternate, duplicate, all and PKey indexes if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.remove(keepObj.getPKey()); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.remove(keepObj.getPKey()); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.remove(keyUDescrIdx); } if (allMemo != null) { allMemo.remove(keepObj.getPKey()); } members.remove(pkey); if (forgetSubObjects) { ((ICFCrmSchemaObj) schema) .getMemoTagTableObj() .forgetMemoTagByMemoIdx(keepObj.getRequiredTenantId(), keepObj.getRequiredMemoId()); } } }
public ICFCrmMemoObj realizeMemo(ICFCrmMemoObj Obj) { ICFCrmMemoObj obj = Obj; CFCrmMemoPKey pkey = obj.getPKey(); ICFCrmMemoObj keepObj = null; if (members.containsKey(pkey) && (null != members.get(pkey))) { ICFCrmMemoObj 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) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.remove(keepObj.getPKey()); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.remove(keepObj.getPKey()); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.remove(keyUDescrIdx); } keepObj.setBuff(Obj.getBuff()); // Attach new object to alternate and duplicate indexes -- PKey stay stable if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } if (allMemo != null) { allMemo.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 (allMemo != null) { allMemo.put(keepObj.getPKey(), keepObj); } if (indexByTenantIdx != null) { CFCrmMemoByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByMemoContactIdx != null) { CFCrmMemoByMemoContactIdxKey keyMemoContactIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newMemoContactIdxKey(); keyMemoContactIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyMemoContactIdx.setRequiredContactId(keepObj.getRequiredContactId()); Map<CFCrmMemoPKey, ICFCrmMemoObj> mapMemoContactIdx = indexByMemoContactIdx.get(keyMemoContactIdx); if (mapMemoContactIdx != null) { mapMemoContactIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUDescrIdx != null) { CFCrmMemoByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryMemo().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUDescrIdx.setRequiredContactId(keepObj.getRequiredContactId()); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } } return (keepObj); }