public ICFSecurityServiceTypeObj realizeServiceType(ICFSecurityServiceTypeObj Obj) { ICFSecurityServiceTypeObj obj = Obj; CFSecurityServiceTypePKey pkey = obj.getPKey(); ICFSecurityServiceTypeObj keepObj = null; if (members.containsKey(pkey) && (null != members.get(pkey))) { ICFSecurityServiceTypeObj 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 (indexByUDescrIdx != null) { CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey(); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.remove(keyUDescrIdx); } keepObj.setBuff(Obj.getBuff()); // Attach new object to alternate and duplicate indexes -- PKey stay stable if (indexByUDescrIdx != null) { CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey(); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } if (allServiceType != null) { allServiceType.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 (allServiceType != null) { allServiceType.put(keepObj.getPKey(), keepObj); } if (indexByUDescrIdx != null) { CFSecurityServiceTypeByUDescrIdxKey keyUDescrIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey(); keyUDescrIdx.setRequiredDescription(keepObj.getRequiredDescription()); indexByUDescrIdx.put(keyUDescrIdx, keepObj); } } return (keepObj); }
public ICFAccTaxObj readTaxByUNameIdx(long TenantId, String Name, boolean forceRead) { if (indexByUNameIdx == null) { indexByUNameIdx = new HashMap<CFAccTaxByUNameIdxKey, ICFAccTaxObj>(); } CFAccTaxByUNameIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredName(Name); ICFAccTaxObj obj = null; if ((!forceRead) && indexByUNameIdx.containsKey(key)) { obj = indexByUNameIdx.get(key); } else { CFAccTaxBuff buff = ((ICFAccSchema) schema.getBackingStore()) .getTableTax() .readDerivedByUNameIdx(schema.getAuthorization(), TenantId, Name); if (buff != null) { obj = schema.getTaxTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newPKey()); obj.setBuff(buff); obj = (ICFAccTaxObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUNameIdx.put(key, null); } } return (obj); }
public ICFSecurityTSecGroupMemberObj readTSecGroupMemberByUUserIdx( long TenantId, int TSecGroupId, UUID SecUserId, boolean forceRead) { if (indexByUUserIdx == null) { indexByUUserIdx = new HashMap<CFSecurityTSecGroupMemberByUUserIdxKey, ICFSecurityTSecGroupMemberObj>(); } CFSecurityTSecGroupMemberByUUserIdxKey key = ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newUUserIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); key.setRequiredSecUserId(SecUserId); ICFSecurityTSecGroupMemberObj obj = null; if ((!forceRead) && indexByUUserIdx.containsKey(key)) { obj = indexByUUserIdx.get(key); } else { CFSecurityTSecGroupMemberBuff buff = ((ICFCrmSchema) schema.getBackingStore()) .getTableTSecGroupMember() .readDerivedByUUserIdx(schema.getAuthorization(), TenantId, TSecGroupId, SecUserId); if (buff != null) { obj = schema.getTSecGroupMemberTableObj().newInstance(); obj.setPKey( ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey()); obj.setBuff(buff); obj = (ICFSecurityTSecGroupMemberObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUUserIdx.put(key, null); } } return (obj); }
public ICFSecurityTSecGroupMemberObj readTSecGroupMember( CFSecurityTSecGroupMemberPKey pkey, boolean forceRead) { ICFSecurityTSecGroupMemberObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecurityTSecGroupMemberBuff readBuff = ((ICFCrmSchema) schema.getBackingStore()) .getTableTSecGroupMember() .readDerivedByIdIdx( schema.getAuthorization(), pkey.getRequiredTenantId(), pkey.getRequiredTSecGroupMemberId()); if (readBuff != null) { obj = schema.getTSecGroupMemberTableObj().newInstance(); obj.setPKey( ((ICFCrmSchema) schema.getBackingStore()).getFactoryTSecGroupMember().newPKey()); obj.setBuff(readBuff); obj = (ICFSecurityTSecGroupMemberObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public ICFSecurityServiceTypeObj readServiceTypeByUDescrIdx( String Description, boolean forceRead) { if (indexByUDescrIdx == null) { indexByUDescrIdx = new HashMap<CFSecurityServiceTypeByUDescrIdxKey, ICFSecurityServiceTypeObj>(); } CFSecurityServiceTypeByUDescrIdxKey key = ((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newUDescrIdxKey(); key.setRequiredDescription(Description); ICFSecurityServiceTypeObj obj = null; if ((!forceRead) && indexByUDescrIdx.containsKey(key)) { obj = indexByUDescrIdx.get(key); } else { CFSecurityServiceTypeBuff buff = ((ICFAccSchema) schema.getBackingStore()) .getTableServiceType() .readDerivedByUDescrIdx(schema.getAuthorization(), Description); if (buff != null) { obj = schema.getServiceTypeTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey()); obj.setBuff(buff); obj = (ICFSecurityServiceTypeObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUDescrIdx.put(key, null); } } return (obj); }
public ICFSecuritySecAppObj readSecAppByUJEEMountIdx( long ClusterId, String JEEMountName, boolean forceRead) { if (indexByUJEEMountIdx == null) { indexByUJEEMountIdx = new HashMap<CFSecuritySecAppByUJEEMountIdxKey, ICFSecuritySecAppObj>(); } CFSecuritySecAppByUJEEMountIdxKey key = ((ICFCrmSchema) schema.getBackingStore()).getFactorySecApp().newUJEEMountIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredJEEMountName(JEEMountName); ICFSecuritySecAppObj obj = null; if ((!forceRead) && indexByUJEEMountIdx.containsKey(key)) { obj = indexByUJEEMountIdx.get(key); } else { CFSecuritySecAppBuff buff = ((ICFCrmSchema) schema.getBackingStore()) .getTableSecApp() .readDerivedByUJEEMountIdx(schema.getAuthorization(), ClusterId, JEEMountName); if (buff != null) { obj = schema.getSecAppTableObj().newInstance(); obj.setPKey(((ICFCrmSchema) schema.getBackingStore()).getFactorySecApp().newPKey()); obj.setBuff(buff); obj = (ICFSecuritySecAppObj) obj.realize(); } else if (schema.getCacheMisses()) { indexByUJEEMountIdx.put(key, null); } } return (obj); }
public ICFSecurityServiceTypeObj readServiceType( CFSecurityServiceTypePKey pkey, boolean forceRead) { ICFSecurityServiceTypeObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecurityServiceTypeBuff readBuff = ((ICFAccSchema) schema.getBackingStore()) .getTableServiceType() .readDerivedByIdIdx(schema.getAuthorization(), pkey.getRequiredServiceTypeId()); if (readBuff != null) { obj = schema.getServiceTypeTableObj().newInstance(); obj.setPKey(((ICFAccSchema) schema.getBackingStore()).getFactoryServiceType().newPKey()); obj.setBuff(readBuff); obj = (ICFSecurityServiceTypeObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public ICFAccTaxObj realizeTax(ICFAccTaxObj Obj) { ICFAccTaxObj obj = Obj; CFAccTaxPKey pkey = obj.getPKey(); ICFAccTaxObj keepObj = null; if (members.containsKey(pkey) && (null != members.get(pkey))) { ICFAccTaxObj 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) { CFAccTaxByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFAccTaxPKey, ICFAccTaxObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.remove(keepObj.getPKey()); } } if (indexByUNameIdx != null) { CFAccTaxByUNameIdxKey keyUNameIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey(); keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUNameIdx.setRequiredName(keepObj.getRequiredName()); indexByUNameIdx.remove(keyUNameIdx); } keepObj.setBuff(Obj.getBuff()); // Attach new object to alternate and duplicate indexes -- PKey stay stable if (indexByTenantIdx != null) { CFAccTaxByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFAccTaxPKey, ICFAccTaxObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUNameIdx != null) { CFAccTaxByUNameIdxKey keyUNameIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey(); keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUNameIdx.setRequiredName(keepObj.getRequiredName()); indexByUNameIdx.put(keyUNameIdx, keepObj); } if (allTax != null) { allTax.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 (allTax != null) { allTax.put(keepObj.getPKey(), keepObj); } if (indexByTenantIdx != null) { CFAccTaxByTenantIdxKey keyTenantIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); Map<CFAccTaxPKey, ICFAccTaxObj> mapTenantIdx = indexByTenantIdx.get(keyTenantIdx); if (mapTenantIdx != null) { mapTenantIdx.put(keepObj.getPKey(), keepObj); } } if (indexByUNameIdx != null) { CFAccTaxByUNameIdxKey keyUNameIdx = ((ICFAccSchema) schema.getBackingStore()).getFactoryTax().newUNameIdxKey(); keyUNameIdx.setRequiredTenantId(keepObj.getRequiredTenantId()); keyUNameIdx.setRequiredName(keepObj.getRequiredName()); indexByUNameIdx.put(keyUNameIdx, keepObj); } } return (keepObj); }
public void createFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) { final String S_ProcName = "createFee"; CFAccFeePKey pkey = schema.getFactoryFee().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredFeeId( ((CFAccRamTenantTable) schema.getTableTenant()) .nextFeeIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredFeeId(pkey.getRequiredFeeId()); CFAccFeeByDateIdxKey keyDateIdx = schema.getFactoryFee().newDateIdxKey(); keyDateIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyDateIdx.setRequiredAccountId(Buff.getRequiredAccountId()); keyDateIdx.setRequiredFeeDate(Buff.getRequiredFeeDate()); CFAccFeeByTenantIdxKey keyTenantIdx = schema.getFactoryFee().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccFeeByAcctIdxKey keyAcctIdx = schema.getFactoryFee().newAcctIdxKey(); keyAcctIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyAcctIdx.setRequiredAccountId(Buff.getRequiredAccountId()); CFAccFeeByLedgerIdxKey keyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey(); keyLedgerIdx.setOptionalLedgerTenantId(Buff.getOptionalLedgerTenantId()); keyLedgerIdx.setOptionalLedgerId(Buff.getOptionalLedgerId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } // Validate foreign keys { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema .getTableAccount() .readDerivedByIdIdx( Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Container", "Account", "Account", null); } } } { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema .getTableTenant() .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Owner", "Tenant", "Tenant", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFAccFeePKey, CFAccFeeBuff> subdictDateIdx; if (dictByDateIdx.containsKey(keyDateIdx)) { subdictDateIdx = dictByDateIdx.get(keyDateIdx); } else { subdictDateIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByDateIdx.put(keyDateIdx, subdictDateIdx); } subdictDateIdx.put(pkey, Buff); Map<CFAccFeePKey, CFAccFeeBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); Map<CFAccFeePKey, CFAccFeeBuff> subdictAcctIdx; if (dictByAcctIdx.containsKey(keyAcctIdx)) { subdictAcctIdx = dictByAcctIdx.get(keyAcctIdx); } else { subdictAcctIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByAcctIdx.put(keyAcctIdx, subdictAcctIdx); } subdictAcctIdx.put(pkey, Buff); Map<CFAccFeePKey, CFAccFeeBuff> subdictLedgerIdx; if (dictByLedgerIdx.containsKey(keyLedgerIdx)) { subdictLedgerIdx = dictByLedgerIdx.get(keyLedgerIdx); } else { subdictLedgerIdx = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByLedgerIdx.put(keyLedgerIdx, subdictLedgerIdx); } subdictLedgerIdx.put(pkey, Buff); }
public void updateFee(CFSecurityAuthorization Authorization, CFAccFeeBuff Buff) { CFAccFeePKey pkey = schema.getFactoryFee().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredFeeId(Buff.getRequiredFeeId()); CFAccFeeBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateFee", "Existing record not found", "Fee", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateFee", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAccFeeByDateIdxKey existingKeyDateIdx = schema.getFactoryFee().newDateIdxKey(); existingKeyDateIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyDateIdx.setRequiredAccountId(existing.getRequiredAccountId()); existingKeyDateIdx.setRequiredFeeDate(existing.getRequiredFeeDate()); CFAccFeeByDateIdxKey newKeyDateIdx = schema.getFactoryFee().newDateIdxKey(); newKeyDateIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyDateIdx.setRequiredAccountId(Buff.getRequiredAccountId()); newKeyDateIdx.setRequiredFeeDate(Buff.getRequiredFeeDate()); CFAccFeeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryFee().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAccFeeByTenantIdxKey newKeyTenantIdx = schema.getFactoryFee().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAccFeeByAcctIdxKey existingKeyAcctIdx = schema.getFactoryFee().newAcctIdxKey(); existingKeyAcctIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyAcctIdx.setRequiredAccountId(existing.getRequiredAccountId()); CFAccFeeByAcctIdxKey newKeyAcctIdx = schema.getFactoryFee().newAcctIdxKey(); newKeyAcctIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyAcctIdx.setRequiredAccountId(Buff.getRequiredAccountId()); CFAccFeeByLedgerIdxKey existingKeyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey(); existingKeyLedgerIdx.setOptionalLedgerTenantId(existing.getOptionalLedgerTenantId()); existingKeyLedgerIdx.setOptionalLedgerId(existing.getOptionalLedgerId()); CFAccFeeByLedgerIdxKey newKeyLedgerIdx = schema.getFactoryFee().newLedgerIdxKey(); newKeyLedgerIdx.setOptionalLedgerTenantId(Buff.getOptionalLedgerTenantId()); newKeyLedgerIdx.setOptionalLedgerId(Buff.getOptionalLedgerId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableAccount() .readDerivedByIdIdx( Authorization, Buff.getRequiredTenantId(), Buff.getRequiredAccountId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateFee", "Container", "Account", "Account", null); } } } { boolean allNull = true; if (allNull) { if (null == schema .getTableTenant() .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateFee", "Owner", "Tenant", "Tenant", null); } } } // Update is valid Map<CFAccFeePKey, CFAccFeeBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByDateIdx.get(existingKeyDateIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByDateIdx.containsKey(newKeyDateIdx)) { subdict = dictByDateIdx.get(newKeyDateIdx); } else { subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByDateIdx.put(newKeyDateIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByTenantIdx.get(existingKeyTenantIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByTenantIdx.containsKey(newKeyTenantIdx)) { subdict = dictByTenantIdx.get(newKeyTenantIdx); } else { subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByAcctIdx.get(existingKeyAcctIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByAcctIdx.containsKey(newKeyAcctIdx)) { subdict = dictByAcctIdx.get(newKeyAcctIdx); } else { subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByAcctIdx.put(newKeyAcctIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByLedgerIdx.get(existingKeyLedgerIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByLedgerIdx.containsKey(newKeyLedgerIdx)) { subdict = dictByLedgerIdx.get(newKeyLedgerIdx); } else { subdict = new HashMap<CFAccFeePKey, CFAccFeeBuff>(); dictByLedgerIdx.put(newKeyLedgerIdx, subdict); } subdict.put(pkey, Buff); }