public CFSecurityServiceBuff lockDerived( CFSecurityAuthorization Authorization, CFSecurityServicePKey PKey) { final String S_ProcName = "CFBamRamService.readDerived"; CFSecurityServicePKey key = schema.getFactoryService().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredServiceId(PKey.getRequiredServiceId()); CFSecurityServiceBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); }
public void createService(CFSecurityAuthorization Authorization, CFSecurityServiceBuff Buff) { final String S_ProcName = "createService"; CFSecurityServicePKey pkey = schema.getFactoryService().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredServiceId( ((CFBamRamClusterTable) schema.getTableCluster()) .nextServiceIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredServiceId(pkey.getRequiredServiceId()); CFSecurityServiceByClusterIdxKey keyClusterIdx = schema.getFactoryService().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecurityServiceByHostIdxKey keyHostIdx = schema.getFactoryService().newHostIdxKey(); keyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); CFSecurityServiceByTypeIdxKey keyTypeIdx = schema.getFactoryService().newTypeIdxKey(); keyTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId()); CFSecurityServiceByUTypeIdxKey keyUTypeIdx = schema.getFactoryService().newUTypeIdxKey(); keyUTypeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUTypeIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); keyUTypeIdx.setRequiredServiceTypeId(Buff.getRequiredServiceTypeId()); CFSecurityServiceByUHostPortIdxKey keyUHostPortIdx = schema.getFactoryService().newUHostPortIdxKey(); keyUHostPortIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUHostPortIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId()); keyUHostPortIdx.setRequiredHostPort(Buff.getRequiredHostPort()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory() .newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } if (dictByUTypeIdx.containsKey(keyUTypeIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException(getClass(), S_ProcName, "ServiceUTypeIdx", keyUTypeIdx); } if (dictByUHostPortIdx.containsKey(keyUHostPortIdx)) { throw CFLib.getDefaultExceptionFactory() .newUniqueIndexViolationException( getClass(), S_ProcName, "ServiceUHostPort", keyUHostPortIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema .getTableCluster() .readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory() .newUnresolvedRelationException( getClass(), S_ProcName, "Owner", "ServiceCluster", "Cluster", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictHostIdx; if (dictByHostIdx.containsKey(keyHostIdx)) { subdictHostIdx = dictByHostIdx.get(keyHostIdx); } else { subdictHostIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByHostIdx.put(keyHostIdx, subdictHostIdx); } subdictHostIdx.put(pkey, Buff); Map<CFSecurityServicePKey, CFSecurityServiceBuff> subdictTypeIdx; if (dictByTypeIdx.containsKey(keyTypeIdx)) { subdictTypeIdx = dictByTypeIdx.get(keyTypeIdx); } else { subdictTypeIdx = new HashMap<CFSecurityServicePKey, CFSecurityServiceBuff>(); dictByTypeIdx.put(keyTypeIdx, subdictTypeIdx); } subdictTypeIdx.put(pkey, Buff); dictByUTypeIdx.put(keyUTypeIdx, Buff); dictByUHostPortIdx.put(keyUHostPortIdx, Buff); }