Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for TSecGroupInclude. /* * CF Security Core Implementation * * Copyright (c) 2010-2014 Mark Sobkow * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam; import java.sql.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurity.*; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.*; /* * CFSecurityRamTSecGroupIncludeTable in-memory RAM DbIO implementation * for TSecGroupInclude. */ public class CFSecurityRamTSecGroupIncludeTable implements ICFSecurityTSecGroupIncludeTable { private CFSecurityRamSchema schema; private Map<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> dictByPKey = new HashMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); private SortedMap<CFSecurityTSecGroupIncludeByTenantIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>> dictByTenantIdx = new TreeMap<CFSecurityTSecGroupIncludeByTenantIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>>(); private SortedMap<CFSecurityTSecGroupIncludeByGroupIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<CFSecurityTSecGroupIncludeByGroupIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>>(); private SortedMap<CFSecurityTSecGroupIncludeByIncludeIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<CFSecurityTSecGroupIncludeByIncludeIdxKey, SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>>(); private SortedMap<CFSecurityTSecGroupIncludeByUIncludeIdxKey, CFSecurityTSecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<CFSecurityTSecGroupIncludeByUIncludeIdxKey, CFSecurityTSecGroupIncludeBuff>(); public CFSecurityRamTSecGroupIncludeTable(CFSecurityRamSchema argSchema) { schema = argSchema; } public void createTSecGroupInclude(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeBuff Buff) { CFSecurityTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(((CFSecurityRamTenantTable) schema.getTableTenant()) .nextTSecGroupIncludeIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredTSecGroupIncludeId(pkey.getRequiredTSecGroupIncludeId()); CFSecurityTSecGroupIncludeByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupInclude() .newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFSecurityTSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFSecurityTSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); keyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFSecurityTSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUIncludeIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTSecGroupInclude", pkey); } if (dictByUIncludeIdx.containsKey(keyUIncludeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTSecGroupInclude", "TSecGroupIncludeUIncludeIdx", keyUIncludeIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroupInclude", "Owner", "TSecGroupIncludeTenant", "Tenant", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroupInclude", "Container", "TSecGroupIncludeGroup", "TSecGroup", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictIncludeIdx; if (dictByIncludeIdx.containsKey(keyIncludeIdx)) { subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx); } else { subdictIncludeIdx = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx); } subdictIncludeIdx.put(pkey, Buff); dictByUIncludeIdx.put(keyUIncludeIdx, Buff); } public CFSecurityTSecGroupIncludeBuff readDerived(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerived() "; CFSecurityTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupIncludeId(PKey.getRequiredTSecGroupIncludeId()); CFSecurityTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff lockDerived(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerived() "; CFSecurityTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupIncludeId(PKey.getRequiredTSecGroupIncludeId()); CFSecurityTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readAllDerived() "; CFSecurityTSecGroupIncludeBuff[] retList = new CFSecurityTSecGroupIncludeBuff[dictByPKey.values().size()]; Iterator<CFSecurityTSecGroupIncludeBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFSecurityTSecGroupIncludeBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerivedByTenantIdx() "; CFSecurityTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(TenantId); CFSecurityTSecGroupIncludeBuff[] recArray; if (dictByTenantIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictTenantIdx = dictByTenantIdx .get(key); recArray = new CFSecurityTSecGroupIncludeBuff[subdictTenantIdx.size()]; Iterator<CFSecurityTSecGroupIncludeBuff> iter = subdictTenantIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupIncludeBuff[0]; } return (recArray); } public CFSecurityTSecGroupIncludeBuff[] readDerivedByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerivedByGroupIdx() "; CFSecurityTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); CFSecurityTSecGroupIncludeBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); recArray = new CFSecurityTSecGroupIncludeBuff[subdictGroupIdx.size()]; Iterator<CFSecurityTSecGroupIncludeBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupIncludeBuff[0]; } return (recArray); } public CFSecurityTSecGroupIncludeBuff[] readDerivedByIncludeIdx(CFSecurityAuthorization Authorization, long TenantId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerivedByIncludeIdx() "; CFSecurityTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredIncludeGroupId(IncludeGroupId); CFSecurityTSecGroupIncludeBuff[] recArray; if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); recArray = new CFSecurityTSecGroupIncludeBuff[subdictIncludeIdx.size()]; Iterator<CFSecurityTSecGroupIncludeBuff> iter = subdictIncludeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupIncludeBuff[0]; } return (recArray); } public CFSecurityTSecGroupIncludeBuff readDerivedByUIncludeIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerivedByUIncludeIdx() "; CFSecurityTSecGroupIncludeByUIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newUIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); key.setRequiredIncludeGroupId(IncludeGroupId); CFSecurityTSecGroupIncludeBuff buff; if (dictByUIncludeIdx.containsKey(key)) { buff = dictByUIncludeIdx.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long TenantId, long TSecGroupIncludeId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readDerivedByIdIdx() "; CFSecurityTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupIncludeId(TSecGroupIncludeId); CFSecurityTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff readBuff(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuff() "; CFSecurityTSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGNC"))) { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff lockBuff(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuff() "; CFSecurityTSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGNC"))) { buff = null; } return (buff); } public CFSecurityTSecGroupIncludeBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readAllBuff() "; CFSecurityTSecGroupIncludeBuff buff; ArrayList<CFSecurityTSecGroupIncludeBuff> filteredList = new ArrayList<CFSecurityTSecGroupIncludeBuff>(); CFSecurityTSecGroupIncludeBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGNC")) { filteredList.add(buff); } } return (filteredList.toArray(new CFSecurityTSecGroupIncludeBuff[0])); } public CFSecurityTSecGroupIncludeBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long TenantId, long TSecGroupIncludeId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuffByIdIdx() "; CFSecurityTSecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, TenantId, TSecGroupIncludeId); if ((buff != null) && buff.getClassCode().equals("TGNC")) { return ((CFSecurityTSecGroupIncludeBuff) buff); } else { return (null); } } public CFSecurityTSecGroupIncludeBuff[] readBuffByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuffByTenantIdx() "; CFSecurityTSecGroupIncludeBuff buff; ArrayList<CFSecurityTSecGroupIncludeBuff> filteredList = new ArrayList<CFSecurityTSecGroupIncludeBuff>(); CFSecurityTSecGroupIncludeBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGNC")) { filteredList.add((CFSecurityTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupIncludeBuff[0])); } public CFSecurityTSecGroupIncludeBuff[] readBuffByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuffByGroupIdx() "; CFSecurityTSecGroupIncludeBuff buff; ArrayList<CFSecurityTSecGroupIncludeBuff> filteredList = new ArrayList<CFSecurityTSecGroupIncludeBuff>(); CFSecurityTSecGroupIncludeBuff[] buffList = readDerivedByGroupIdx(Authorization, TenantId, TSecGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGNC")) { filteredList.add((CFSecurityTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupIncludeBuff[0])); } public CFSecurityTSecGroupIncludeBuff[] readBuffByIncludeIdx(CFSecurityAuthorization Authorization, long TenantId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuffByIncludeIdx() "; CFSecurityTSecGroupIncludeBuff buff; ArrayList<CFSecurityTSecGroupIncludeBuff> filteredList = new ArrayList<CFSecurityTSecGroupIncludeBuff>(); CFSecurityTSecGroupIncludeBuff[] buffList = readDerivedByIncludeIdx(Authorization, TenantId, IncludeGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGNC")) { filteredList.add((CFSecurityTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupIncludeBuff[0])); } public CFSecurityTSecGroupIncludeBuff readBuffByUIncludeIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupInclude.readBuffByUIncludeIdx() "; CFSecurityTSecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, TenantId, TSecGroupId, IncludeGroupId); if ((buff != null) && buff.getClassCode().equals("TGNC")) { return ((CFSecurityTSecGroupIncludeBuff) buff); } else { return (null); } } public void updateTSecGroupInclude(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeBuff Buff) { CFSecurityTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId()); CFSecurityTSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTSecGroupInclude", "Existing record not found", "TSecGroupInclude", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTSecGroupInclude", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityTSecGroupIncludeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupInclude() .newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFSecurityTSecGroupIncludeByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupInclude() .newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFSecurityTSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupInclude() .newGroupIdxKey(); existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFSecurityTSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupInclude() .newGroupIdxKey(); newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFSecurityTSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); existingKeyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecurityTSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); newKeyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFSecurityTSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); existingKeyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecurityTSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); newKeyUIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyUIncludeIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); // Check unique indexes if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) { if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateTSecGroupInclude", "TSecGroupIncludeUIncludeIdx", newKeyUIncludeIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTSecGroupInclude", "Owner", "TSecGroupIncludeTenant", "Tenant", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTSecGroupInclude", "Container", "TSecGroupIncludeGroup", "TSecGroup", null); } } } // Update is valid SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByTenantIdx.get(existingKeyTenantIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByTenantIdx.containsKey(newKeyTenantIdx)) { subdict = dictByTenantIdx.get(newKeyTenantIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByGroupIdx.get(existingKeyGroupIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByGroupIdx.containsKey(newKeyGroupIdx)) { subdict = dictByGroupIdx.get(newKeyGroupIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByGroupIdx.put(newKeyGroupIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByIncludeIdx.get(existingKeyIncludeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) { subdict = dictByIncludeIdx.get(newKeyIncludeIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff>(); dictByIncludeIdx.put(newKeyIncludeIdx, subdict); } subdict.put(pkey, Buff); dictByUIncludeIdx.remove(existingKeyUIncludeIdx); dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff); } public void deleteTSecGroupInclude(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeBuff Buff) { final String S_ProcName = "CFSecurityRamTSecGroupIncludeTable.deleteTSecGroupInclude() "; CFSecurityTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId()); CFSecurityTSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTSecGroupInclude", pkey); } CFSecurityTSecGroupIncludeByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupInclude() .newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFSecurityTSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFSecurityTSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); keyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecurityTSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdict; dictByPKey.remove(pkey); subdict = dictByTenantIdx.get(keyTenantIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByIncludeIdx.get(keyIncludeIdx); subdict.remove(pkey); dictByUIncludeIdx.remove(keyUIncludeIdx); } public void deleteTSecGroupIncludeByIdIdx(CFSecurityAuthorization Authorization, long argTenantId, long argTSecGroupIncludeId) { CFSecurityTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupIncludeId(argTSecGroupIncludeId); deleteTSecGroupIncludeByIdIdx(Authorization, key); } public void deleteTSecGroupIncludeByIdIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludePKey argKey) { CFSecurityTSecGroupIncludeBuff cur; LinkedList<CFSecurityTSecGroupIncludeBuff> matchSet = new LinkedList<CFSecurityTSecGroupIncludeBuff>(); Iterator<CFSecurityTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByTenantIdx(CFSecurityAuthorization Authorization, long argTenantId) { CFSecurityTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(argTenantId); deleteTSecGroupIncludeByTenantIdx(Authorization, key); } public void deleteTSecGroupIncludeByTenantIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeByTenantIdxKey argKey) { CFSecurityTSecGroupIncludeBuff cur; LinkedList<CFSecurityTSecGroupIncludeBuff> matchSet = new LinkedList<CFSecurityTSecGroupIncludeBuff>(); Iterator<CFSecurityTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByGroupIdx(CFSecurityAuthorization Authorization, long argTenantId, int argTSecGroupId) { CFSecurityTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); deleteTSecGroupIncludeByGroupIdx(Authorization, key); } public void deleteTSecGroupIncludeByGroupIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeByGroupIdxKey argKey) { CFSecurityTSecGroupIncludeBuff cur; LinkedList<CFSecurityTSecGroupIncludeBuff> matchSet = new LinkedList<CFSecurityTSecGroupIncludeBuff>(); Iterator<CFSecurityTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByIncludeIdx(CFSecurityAuthorization Authorization, long argTenantId, int argIncludeGroupId) { CFSecurityTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteTSecGroupIncludeByIncludeIdx(Authorization, key); } public void deleteTSecGroupIncludeByIncludeIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeByIncludeIdxKey argKey) { CFSecurityTSecGroupIncludeBuff cur; LinkedList<CFSecurityTSecGroupIncludeBuff> matchSet = new LinkedList<CFSecurityTSecGroupIncludeBuff>(); Iterator<CFSecurityTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByUIncludeIdx(CFSecurityAuthorization Authorization, long argTenantId, int argTSecGroupId, int argIncludeGroupId) { CFSecurityTSecGroupIncludeByUIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newUIncludeIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteTSecGroupIncludeByUIncludeIdx(Authorization, key); } public void deleteTSecGroupIncludeByUIncludeIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupIncludeByUIncludeIdxKey argKey) { CFSecurityTSecGroupIncludeBuff cur; LinkedList<CFSecurityTSecGroupIncludeBuff> matchSet = new LinkedList<CFSecurityTSecGroupIncludeBuff>(); Iterator<CFSecurityTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public CFSecurityCursor openTSecGroupIncludeCursorAll(CFSecurityAuthorization Authorization) { CFSecurityCursor cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFSecurityCursor openTSecGroupIncludeCursorByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { CFSecurityCursor cursor; CFSecurityTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(TenantId); if (dictByTenantIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictTenantIdx = dictByTenantIdx .get(key); cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, subdictTenantIdx.values()); } else { cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupIncludeBuff>()); } return (cursor); } public CFSecurityCursor openTSecGroupIncludeCursorByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { CFSecurityCursor cursor; CFSecurityTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupIncludeBuff>()); } return (cursor); } public CFSecurityCursor openTSecGroupIncludeCursorByIncludeIdx(CFSecurityAuthorization Authorization, long TenantId, int IncludeGroupId) { CFSecurityCursor cursor; CFSecurityTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredIncludeGroupId(IncludeGroupId); if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupIncludePKey, CFSecurityTSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values()); } else { cursor = new CFSecurityRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupIncludeBuff>()); } return (cursor); } public void closeTSecGroupIncludeCursor(CFSecurityCursor Cursor) { // Cursor.DataReader.Close(); } public CFSecurityTSecGroupIncludeBuff nextTSecGroupIncludeCursor(CFSecurityCursor Cursor) { CFSecurityRamTSecGroupIncludeCursor cursor = (CFSecurityRamTSecGroupIncludeCursor) Cursor; CFSecurityTSecGroupIncludeBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFSecurityTSecGroupIncludeBuff prevTSecGroupIncludeCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFSecurityTSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public CFSecurityTSecGroupIncludeBuff firstTSecGroupIncludeCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFSecurityTSecGroupIncludeBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public CFSecurityTSecGroupIncludeBuff lastTSecGroupIncludeCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastTSecGroupIncludeCursor"); } public CFSecurityTSecGroupIncludeBuff nthTSecGroupIncludeCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFSecurityTSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }