public void deleteReqMinMaxValue( CFSecurityAuthorization Authorization, CFDbTestReqMinMaxValueBuff Buff) { final String S_ProcName = "CFDbTestRamReqMinMaxValueTable.deleteReqMinMaxValue() "; CFDbTestReqMinMaxValuePKey pkey = schema.getFactoryReqMinMaxValue().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFDbTestReqMinMaxValueBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteReqMinMaxValue", pkey); } CFDbTestReqMinMaxValueByUDescrIdxKey keyUDescrIdx = schema.getFactoryReqMinMaxValue().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); CFDbTestReqMinMaxValueByTenantIdxKey keyTenantIdx = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); // Validate reverse foreign keys // Delete is valid Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdict; dictByPKey.remove(pkey); dictByUDescrIdx.remove(keyUDescrIdx); subdict = dictByTenantIdx.get(keyTenantIdx); subdict.remove(pkey); }
public void updateReqMinMaxValue( CFSecurityAuthorization Authorization, CFDbTestReqMinMaxValueBuff Buff) { CFDbTestReqMinMaxValuePKey pkey = schema.getFactoryReqMinMaxValue().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFDbTestReqMinMaxValueBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateReqMinMaxValue", "Existing record not found", "ReqMinMaxValue", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateReqMinMaxValue", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFDbTestReqMinMaxValueByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryReqMinMaxValue().newUDescrIdxKey(); existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); CFDbTestReqMinMaxValueByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryReqMinMaxValue().newUDescrIdxKey(); newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription()); CFDbTestReqMinMaxValueByTenantIdxKey existingKeyTenantIdx = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFDbTestReqMinMaxValueByTenantIdxKey newKeyTenantIdx = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); // Check unique indexes if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) { if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateReqMinMaxValue", "ReqMinMaxValueUDescrIdx", newKeyUDescrIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableTenant() .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateReqMinMaxValue", "Container", "Tenant", "Tenant", null); } } } // Update is valid Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByUDescrIdx.remove(existingKeyUDescrIdx); dictByUDescrIdx.put(newKeyUDescrIdx, Buff); subdict = dictByTenantIdx.get(existingKeyTenantIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByTenantIdx.containsKey(newKeyTenantIdx)) { subdict = dictByTenantIdx.get(newKeyTenantIdx); } else { subdict = new HashMap<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); }