public CFSecurityCursor openReqMinMaxValueCursorByTenantIdx( CFSecurityAuthorization Authorization, long TenantId) { CFSecurityCursor cursor; CFDbTestReqMinMaxValueByTenantIdxKey key = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); key.setRequiredTenantId(TenantId); if (dictByTenantIdx.containsKey(key)) { Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdictTenantIdx = dictByTenantIdx.get(key); cursor = new CFDbTestRamReqMinMaxValueCursor(Authorization, schema, subdictTenantIdx.values()); } else { cursor = new CFDbTestRamReqMinMaxValueCursor( Authorization, schema, new ArrayList<CFDbTestReqMinMaxValueBuff>()); } return (cursor); }
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 CFDbTestReqMinMaxValueBuff[] readDerivedByTenantIdx( CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFDbTestRamReqMinMaxValue.readDerivedByTenantIdx"; CFDbTestReqMinMaxValueByTenantIdxKey key = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); key.setRequiredTenantId(TenantId); CFDbTestReqMinMaxValueBuff[] recArray; if (dictByTenantIdx.containsKey(key)) { Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdictTenantIdx = dictByTenantIdx.get(key); recArray = new CFDbTestReqMinMaxValueBuff[subdictTenantIdx.size()]; Iterator<CFDbTestReqMinMaxValueBuff> iter = subdictTenantIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdictTenantIdx = new HashMap<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff>(); dictByTenantIdx.put(key, subdictTenantIdx); recArray = new CFDbTestReqMinMaxValueBuff[0]; } return (recArray); }
public void createReqMinMaxValue( CFSecurityAuthorization Authorization, CFDbTestReqMinMaxValueBuff Buff) { final String S_ProcName = "createReqMinMaxValue"; CFDbTestReqMinMaxValuePKey pkey = schema.getFactoryReqMinMaxValue().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId( ((CFDbTestRamTenantTable) schema.getTableTenant()) .nextReqMinMaxValueIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredId(pkey.getRequiredId()); CFDbTestReqMinMaxValueByUDescrIdxKey keyUDescrIdx = schema.getFactoryReqMinMaxValue().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription()); CFDbTestReqMinMaxValueByTenantIdxKey keyTenantIdx = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } if (dictByUDescrIdx.containsKey(keyUDescrIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, "ReqMinMaxValueUDescrIdx", keyUDescrIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema .getTableTenant() .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Container", "Tenant", "Tenant", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); dictByUDescrIdx.put(keyUDescrIdx, Buff); Map<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new HashMap<CFDbTestReqMinMaxValuePKey, CFDbTestReqMinMaxValueBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); }
public void deleteReqMinMaxValueByTenantIdx( CFSecurityAuthorization Authorization, long argTenantId) { CFDbTestReqMinMaxValueByTenantIdxKey key = schema.getFactoryReqMinMaxValue().newTenantIdxKey(); key.setRequiredTenantId(argTenantId); deleteReqMinMaxValueByTenantIdx(Authorization, key); }
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); }