Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for TSecGroupInclude. /* * CF Asterisk 11 Configuration Model * * Copyright (c) 2013-2014 Mark Sobkow * * This program is available as free software under the GNU GPL v3, or * under a commercial license from Mark Sobkow. For commercial licensing * details, please contact msobkow@sasktel.net. * * Under the terms of the GPL: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * This source code incorporates modified modules originally licensed * under the Apache 2.0 license by MSS Code Factory including CFSecurity * (net-sourceforge-msscodefactory-2.0-cfsecurity.xml), * CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and * CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the * required models being available as part of the MSS Code Factory 1.11 * distribution source and install zips. * * You can download installations of MSS Code Factory 1.11 from * http://msscodefactory.sourceforge.net/ * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam; 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.cfasterisk.v2_0.CFAst.*; import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.*; /* * CFAstRamTSecGroupIncludeTable in-memory RAM DbIO implementation * for TSecGroupInclude. */ public class CFAstRamTSecGroupIncludeTable implements ICFAstTSecGroupIncludeTable { private CFAstRamSchema schema; private Map<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> dictByPKey = new HashMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); private SortedMap<CFAstTSecGroupIncludeByTenantIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>> dictByTenantIdx = new TreeMap<CFAstTSecGroupIncludeByTenantIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>>(); private SortedMap<CFAstTSecGroupIncludeByGroupIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<CFAstTSecGroupIncludeByGroupIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>>(); private SortedMap<CFAstTSecGroupIncludeByIncludeIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<CFAstTSecGroupIncludeByIncludeIdxKey, SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>>(); private SortedMap<CFAstTSecGroupIncludeByUIncludeIdxKey, CFAstTSecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<CFAstTSecGroupIncludeByUIncludeIdxKey, CFAstTSecGroupIncludeBuff>(); public CFAstRamTSecGroupIncludeTable(CFAstRamSchema argSchema) { schema = argSchema; } public void createTSecGroupInclude(CFAstAuthorization Authorization, CFAstTSecGroupIncludeBuff Buff) { CFAstTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(((CFAstRamTenantTable) schema.getTableTenant()) .nextTSecGroupIncludeIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredTSecGroupIncludeId(pkey.getRequiredTSecGroupIncludeId()); CFAstTSecGroupIncludeByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAstTSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFAstTSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAstTSecGroupIncludeByUIncludeIdxKey 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictIncludeIdx; if (dictByIncludeIdx.containsKey(keyIncludeIdx)) { subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx); } else { subdictIncludeIdx = new TreeMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx); } subdictIncludeIdx.put(pkey, Buff); dictByUIncludeIdx.put(keyUIncludeIdx, Buff); } public CFAstTSecGroupIncludeBuff readDerived(CFAstAuthorization Authorization, CFAstTSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerived() "; CFAstTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupIncludeId(PKey.getRequiredTSecGroupIncludeId()); CFAstTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff lockDerived(CFAstAuthorization Authorization, CFAstTSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerived() "; CFAstTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupIncludeId(PKey.getRequiredTSecGroupIncludeId()); CFAstTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff[] readAllDerived(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamTSecGroupInclude.readAllDerived() "; CFAstTSecGroupIncludeBuff[] retList = new CFAstTSecGroupIncludeBuff[dictByPKey.values().size()]; Iterator<CFAstTSecGroupIncludeBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAstTSecGroupIncludeBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerivedByTenantIdx() "; CFAstTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(TenantId); CFAstTSecGroupIncludeBuff[] recArray; if (dictByTenantIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictTenantIdx = dictByTenantIdx .get(key); recArray = new CFAstTSecGroupIncludeBuff[subdictTenantIdx.size()]; Iterator<CFAstTSecGroupIncludeBuff> iter = subdictTenantIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstTSecGroupIncludeBuff[0]; } return (recArray); } public CFAstTSecGroupIncludeBuff[] readDerivedByGroupIdx(CFAstAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerivedByGroupIdx() "; CFAstTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); CFAstTSecGroupIncludeBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); recArray = new CFAstTSecGroupIncludeBuff[subdictGroupIdx.size()]; Iterator<CFAstTSecGroupIncludeBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstTSecGroupIncludeBuff[0]; } return (recArray); } public CFAstTSecGroupIncludeBuff[] readDerivedByIncludeIdx(CFAstAuthorization Authorization, long TenantId, int IncludeGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerivedByIncludeIdx() "; CFAstTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAstTSecGroupIncludeBuff[] recArray; if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); recArray = new CFAstTSecGroupIncludeBuff[subdictIncludeIdx.size()]; Iterator<CFAstTSecGroupIncludeBuff> iter = subdictIncludeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstTSecGroupIncludeBuff[0]; } return (recArray); } public CFAstTSecGroupIncludeBuff readDerivedByUIncludeIdx(CFAstAuthorization Authorization, long TenantId, int TSecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerivedByUIncludeIdx() "; CFAstTSecGroupIncludeByUIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newUIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAstTSecGroupIncludeBuff buff; if (dictByUIncludeIdx.containsKey(key)) { buff = dictByUIncludeIdx.get(key); } else { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff readDerivedByIdIdx(CFAstAuthorization Authorization, long TenantId, long TSecGroupIncludeId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readDerivedByIdIdx() "; CFAstTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupIncludeId(TSecGroupIncludeId); CFAstTSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff readBuff(CFAstAuthorization Authorization, CFAstTSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuff() "; CFAstTSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGNC"))) { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff lockBuff(CFAstAuthorization Authorization, CFAstTSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuff() "; CFAstTSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGNC"))) { buff = null; } return (buff); } public CFAstTSecGroupIncludeBuff[] readAllBuff(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamTSecGroupInclude.readAllBuff() "; CFAstTSecGroupIncludeBuff buff; ArrayList<CFAstTSecGroupIncludeBuff> filteredList = new ArrayList<CFAstTSecGroupIncludeBuff>(); CFAstTSecGroupIncludeBuff[] 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 CFAstTSecGroupIncludeBuff[0])); } public CFAstTSecGroupIncludeBuff readBuffByIdIdx(CFAstAuthorization Authorization, long TenantId, long TSecGroupIncludeId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuffByIdIdx() "; CFAstTSecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, TenantId, TSecGroupIncludeId); if ((buff != null) && buff.getClassCode().equals("TGNC")) { return ((CFAstTSecGroupIncludeBuff) buff); } else { return (null); } } public CFAstTSecGroupIncludeBuff[] readBuffByTenantIdx(CFAstAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuffByTenantIdx() "; CFAstTSecGroupIncludeBuff buff; ArrayList<CFAstTSecGroupIncludeBuff> filteredList = new ArrayList<CFAstTSecGroupIncludeBuff>(); CFAstTSecGroupIncludeBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGNC")) { filteredList.add((CFAstTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstTSecGroupIncludeBuff[0])); } public CFAstTSecGroupIncludeBuff[] readBuffByGroupIdx(CFAstAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuffByGroupIdx() "; CFAstTSecGroupIncludeBuff buff; ArrayList<CFAstTSecGroupIncludeBuff> filteredList = new ArrayList<CFAstTSecGroupIncludeBuff>(); CFAstTSecGroupIncludeBuff[] 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((CFAstTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstTSecGroupIncludeBuff[0])); } public CFAstTSecGroupIncludeBuff[] readBuffByIncludeIdx(CFAstAuthorization Authorization, long TenantId, int IncludeGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuffByIncludeIdx() "; CFAstTSecGroupIncludeBuff buff; ArrayList<CFAstTSecGroupIncludeBuff> filteredList = new ArrayList<CFAstTSecGroupIncludeBuff>(); CFAstTSecGroupIncludeBuff[] 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((CFAstTSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstTSecGroupIncludeBuff[0])); } public CFAstTSecGroupIncludeBuff readBuffByUIncludeIdx(CFAstAuthorization Authorization, long TenantId, int TSecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAstRamTSecGroupInclude.readBuffByUIncludeIdx() "; CFAstTSecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, TenantId, TSecGroupId, IncludeGroupId); if ((buff != null) && buff.getClassCode().equals("TGNC")) { return ((CFAstTSecGroupIncludeBuff) buff); } else { return (null); } } public void updateTSecGroupInclude(CFAstAuthorization Authorization, CFAstTSecGroupIncludeBuff Buff) { CFAstTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId()); CFAstTSecGroupIncludeBuff 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); CFAstTSecGroupIncludeByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupInclude() .newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAstTSecGroupIncludeByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFAstTSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupInclude() .newGroupIdxKey(); existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFAstTSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFAstTSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); existingKeyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstTSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactoryTSecGroupInclude() .newIncludeIdxKey(); newKeyIncludeIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAstTSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); existingKeyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstTSecGroupIncludeByUIncludeIdxKey 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); 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<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff>(); dictByIncludeIdx.put(newKeyIncludeIdx, subdict); } subdict.put(pkey, Buff); dictByUIncludeIdx.remove(existingKeyUIncludeIdx); dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff); } public void deleteTSecGroupInclude(CFAstAuthorization Authorization, CFAstTSecGroupIncludeBuff Buff) { final String S_ProcName = "CFAstRamTSecGroupIncludeTable.deleteTSecGroupInclude() "; CFAstTSecGroupIncludePKey pkey = schema.getFactoryTSecGroupInclude().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupIncludeId(Buff.getRequiredTSecGroupIncludeId()); CFAstTSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTSecGroupInclude", pkey); } CFAstTSecGroupIncludeByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFAstTSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFAstTSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstTSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactoryTSecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyUIncludeIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> 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(CFAstAuthorization Authorization, long argTenantId, long argTSecGroupIncludeId) { CFAstTSecGroupIncludePKey key = schema.getFactoryTSecGroupInclude().newPKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupIncludeId(argTSecGroupIncludeId); deleteTSecGroupIncludeByIdIdx(Authorization, key); } public void deleteTSecGroupIncludeByIdIdx(CFAstAuthorization Authorization, CFAstTSecGroupIncludePKey argKey) { CFAstTSecGroupIncludeBuff cur; LinkedList<CFAstTSecGroupIncludeBuff> matchSet = new LinkedList<CFAstTSecGroupIncludeBuff>(); Iterator<CFAstTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByTenantIdx(CFAstAuthorization Authorization, long argTenantId) { CFAstTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(argTenantId); deleteTSecGroupIncludeByTenantIdx(Authorization, key); } public void deleteTSecGroupIncludeByTenantIdx(CFAstAuthorization Authorization, CFAstTSecGroupIncludeByTenantIdxKey argKey) { CFAstTSecGroupIncludeBuff cur; LinkedList<CFAstTSecGroupIncludeBuff> matchSet = new LinkedList<CFAstTSecGroupIncludeBuff>(); Iterator<CFAstTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByGroupIdx(CFAstAuthorization Authorization, long argTenantId, int argTSecGroupId) { CFAstTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); deleteTSecGroupIncludeByGroupIdx(Authorization, key); } public void deleteTSecGroupIncludeByGroupIdx(CFAstAuthorization Authorization, CFAstTSecGroupIncludeByGroupIdxKey argKey) { CFAstTSecGroupIncludeBuff cur; LinkedList<CFAstTSecGroupIncludeBuff> matchSet = new LinkedList<CFAstTSecGroupIncludeBuff>(); Iterator<CFAstTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByIncludeIdx(CFAstAuthorization Authorization, long argTenantId, int argIncludeGroupId) { CFAstTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteTSecGroupIncludeByIncludeIdx(Authorization, key); } public void deleteTSecGroupIncludeByIncludeIdx(CFAstAuthorization Authorization, CFAstTSecGroupIncludeByIncludeIdxKey argKey) { CFAstTSecGroupIncludeBuff cur; LinkedList<CFAstTSecGroupIncludeBuff> matchSet = new LinkedList<CFAstTSecGroupIncludeBuff>(); Iterator<CFAstTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public void deleteTSecGroupIncludeByUIncludeIdx(CFAstAuthorization Authorization, long argTenantId, int argTSecGroupId, int argIncludeGroupId) { CFAstTSecGroupIncludeByUIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newUIncludeIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteTSecGroupIncludeByUIncludeIdx(Authorization, key); } public void deleteTSecGroupIncludeByUIncludeIdx(CFAstAuthorization Authorization, CFAstTSecGroupIncludeByUIncludeIdxKey argKey) { CFAstTSecGroupIncludeBuff cur; LinkedList<CFAstTSecGroupIncludeBuff> matchSet = new LinkedList<CFAstTSecGroupIncludeBuff>(); Iterator<CFAstTSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstTSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupInclude(Authorization, cur); } } public CFAstCursor openTSecGroupIncludeCursorAll(CFAstAuthorization Authorization) { CFAstCursor cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFAstCursor openTSecGroupIncludeCursorByTenantIdx(CFAstAuthorization Authorization, long TenantId) { CFAstCursor cursor; CFAstTSecGroupIncludeByTenantIdxKey key = schema.getFactoryTSecGroupInclude().newTenantIdxKey(); key.setRequiredTenantId(TenantId); if (dictByTenantIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictTenantIdx = dictByTenantIdx .get(key); cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, subdictTenantIdx.values()); } else { cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstTSecGroupIncludeBuff>()); } return (cursor); } public CFAstCursor openTSecGroupIncludeCursorByGroupIdx(CFAstAuthorization Authorization, long TenantId, int TSecGroupId) { CFAstCursor cursor; CFAstTSecGroupIncludeByGroupIdxKey key = schema.getFactoryTSecGroupInclude().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstTSecGroupIncludeBuff>()); } return (cursor); } public CFAstCursor openTSecGroupIncludeCursorByIncludeIdx(CFAstAuthorization Authorization, long TenantId, int IncludeGroupId) { CFAstCursor cursor; CFAstTSecGroupIncludeByIncludeIdxKey key = schema.getFactoryTSecGroupInclude().newIncludeIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredIncludeGroupId(IncludeGroupId); if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAstTSecGroupIncludePKey, CFAstTSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values()); } else { cursor = new CFAstRamTSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstTSecGroupIncludeBuff>()); } return (cursor); } public void closeTSecGroupIncludeCursor(CFAstCursor Cursor) { // Cursor.DataReader.Close(); } public CFAstTSecGroupIncludeBuff nextTSecGroupIncludeCursor(CFAstCursor Cursor) { CFAstRamTSecGroupIncludeCursor cursor = (CFAstRamTSecGroupIncludeCursor) Cursor; CFAstTSecGroupIncludeBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAstTSecGroupIncludeBuff prevTSecGroupIncludeCursor(CFAstCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAstTSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public CFAstTSecGroupIncludeBuff firstTSecGroupIncludeCursor(CFAstCursor Cursor) { int targetRowIdx = 1; CFAstTSecGroupIncludeBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public CFAstTSecGroupIncludeBuff lastTSecGroupIncludeCursor(CFAstCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastTSecGroupIncludeCursor"); } public CFAstTSecGroupIncludeBuff nthTSecGroupIncludeCursor(CFAstCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAstTSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupIncludeCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }