public void createOptFullRange( CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) { final String S_ProcName = "createOptFullRange"; CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey(); pkey.setRequiredId(schema.nextOptFullRangeIdGen()); Buff.setRequiredId(pkey.getRequiredId()); CFDbTestOptFullRangeByUDescrIdxKey keyUDescrIdx = schema.getFactoryOptFullRange().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription()); CFDbTestOptFullRangeByTenantIdxKey keyTenantIdx = schema.getFactoryOptFullRange().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, "OptFullRangeUDescrIdx", 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<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new HashMap<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); }
public void deleteOptFullRange( CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) { final String S_ProcName = "CFDbTestRamOptFullRangeTable.deleteOptFullRange() "; CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFDbTestOptFullRangeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "deleteOptFullRange", pkey); } CFDbTestOptFullRangeByUDescrIdxKey keyUDescrIdx = schema.getFactoryOptFullRange().newUDescrIdxKey(); keyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); CFDbTestOptFullRangeByTenantIdxKey keyTenantIdx = schema.getFactoryOptFullRange().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); // Validate reverse foreign keys // Delete is valid Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdict; dictByPKey.remove(pkey); dictByUDescrIdx.remove(keyUDescrIdx); subdict = dictByTenantIdx.get(keyTenantIdx); subdict.remove(pkey); }
public void deleteOptFullRangeByUDescrIdx( CFSecurityAuthorization Authorization, long argTenantId, String argDescription) { CFDbTestOptFullRangeByUDescrIdxKey key = schema.getFactoryOptFullRange().newUDescrIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredDescription(argDescription); deleteOptFullRangeByUDescrIdx(Authorization, key); }
public CFDbTestOptFullRangeBuff lockDerived( CFSecurityAuthorization Authorization, CFDbTestOptFullRangePKey PKey) { final String S_ProcName = "CFDbTestRamOptFullRange.readDerived"; CFDbTestOptFullRangePKey key = schema.getFactoryOptFullRange().newPKey(); key.setRequiredId(PKey.getRequiredId()); CFDbTestOptFullRangeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public CFDbTestOptFullRangeBuff readDerivedByUDescrIdx( CFSecurityAuthorization Authorization, long TenantId, String Description) { final String S_ProcName = "CFDbTestRamOptFullRange.readDerivedByUDescrIdx"; CFDbTestOptFullRangeByUDescrIdxKey key = schema.getFactoryOptFullRange().newUDescrIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredDescription(Description); CFDbTestOptFullRangeBuff buff; if (dictByUDescrIdx.containsKey(key)) { buff = dictByUDescrIdx.get(key); } else { buff = null; } return (buff); }
public CFSecurityCursor openOptFullRangeCursorByTenantIdx( CFSecurityAuthorization Authorization, long TenantId) { CFSecurityCursor cursor; CFDbTestOptFullRangeByTenantIdxKey key = schema.getFactoryOptFullRange().newTenantIdxKey(); key.setRequiredTenantId(TenantId); if (dictByTenantIdx.containsKey(key)) { Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx = dictByTenantIdx.get(key); cursor = new CFDbTestRamOptFullRangeCursor(Authorization, schema, subdictTenantIdx.values()); } else { cursor = new CFDbTestRamOptFullRangeCursor( Authorization, schema, new ArrayList<CFDbTestOptFullRangeBuff>()); } return (cursor); }
public CFDbTestOptFullRangeBuff[] readDerivedByTenantIdx( CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFDbTestRamOptFullRange.readDerivedByTenantIdx"; CFDbTestOptFullRangeByTenantIdxKey key = schema.getFactoryOptFullRange().newTenantIdxKey(); key.setRequiredTenantId(TenantId); CFDbTestOptFullRangeBuff[] recArray; if (dictByTenantIdx.containsKey(key)) { Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx = dictByTenantIdx.get(key); recArray = new CFDbTestOptFullRangeBuff[subdictTenantIdx.size()]; Iterator<CFDbTestOptFullRangeBuff> iter = subdictTenantIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> subdictTenantIdx = new HashMap<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff>(); dictByTenantIdx.put(key, subdictTenantIdx); recArray = new CFDbTestOptFullRangeBuff[0]; } return (recArray); }
public void deleteOptFullRangeByIdIdx(CFSecurityAuthorization Authorization, short argId) { CFDbTestOptFullRangePKey key = schema.getFactoryOptFullRange().newPKey(); key.setRequiredId(argId); deleteOptFullRangeByIdIdx(Authorization, key); }
public void updateOptFullRange( CFSecurityAuthorization Authorization, CFDbTestOptFullRangeBuff Buff) { CFDbTestOptFullRangePKey pkey = schema.getFactoryOptFullRange().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); CFDbTestOptFullRangeBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory() .newStaleCacheDetectedException( getClass(), "updateOptFullRange", "Existing record not found", "OptFullRange", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "updateOptFullRange", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFDbTestOptFullRangeByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryOptFullRange().newUDescrIdxKey(); existingKeyUDescrIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription()); CFDbTestOptFullRangeByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryOptFullRange().newUDescrIdxKey(); newKeyUDescrIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription()); CFDbTestOptFullRangeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryOptFullRange().newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFDbTestOptFullRangeByTenantIdxKey newKeyTenantIdx = schema.getFactoryOptFullRange().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); // Check unique indexes if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) { if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), "updateOptFullRange", "OptFullRangeUDescrIdx", newKeyUDescrIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema .getTableTenant() .readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), "updateOptFullRange", "Container", "Tenant", "Tenant", null); } } } // Update is valid Map<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff> 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<CFDbTestOptFullRangePKey, CFDbTestOptFullRangeBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); }