Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for SecGroupInclude. /* * 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.*; /* * CFAstRamSecGroupIncludeTable in-memory RAM DbIO implementation * for SecGroupInclude. */ public class CFAstRamSecGroupIncludeTable implements ICFAstSecGroupIncludeTable { private CFAstRamSchema schema; private Map<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> dictByPKey = new HashMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); private SortedMap<CFAstSecGroupIncludeByClusterIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>> dictByClusterIdx = new TreeMap<CFAstSecGroupIncludeByClusterIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>>(); private SortedMap<CFAstSecGroupIncludeByGroupIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<CFAstSecGroupIncludeByGroupIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>>(); private SortedMap<CFAstSecGroupIncludeByIncludeIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<CFAstSecGroupIncludeByIncludeIdxKey, SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>>(); private SortedMap<CFAstSecGroupIncludeByUIncludeIdxKey, CFAstSecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<CFAstSecGroupIncludeByUIncludeIdxKey, CFAstSecGroupIncludeBuff>(); public CFAstRamSecGroupIncludeTable(CFAstRamSchema argSchema) { schema = argSchema; } public void createSecGroupInclude(CFAstAuthorization Authorization, CFAstSecGroupIncludeBuff Buff) { CFAstSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(((CFAstRamClusterTable) schema.getTableCluster()) .nextSecGroupIncludeIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecGroupIncludeId(pkey.getRequiredSecGroupIncludeId()); CFAstSecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAstSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAstSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAstSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecGroupInclude", pkey); } if (dictByUIncludeIdx.containsKey(keyUIncludeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecGroupInclude", "SecGroupIncludeUIncludeIdx", keyUIncludeIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecGroupInclude", "Owner", "SecGroupIncludeCluster", "Cluster", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecGroupInclude", "Container", "SecGroupIncludeGroup", "SecGroup", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictIncludeIdx; if (dictByIncludeIdx.containsKey(keyIncludeIdx)) { subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx); } else { subdictIncludeIdx = new TreeMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx); } subdictIncludeIdx.put(pkey, Buff); dictByUIncludeIdx.put(keyUIncludeIdx, Buff); } public CFAstSecGroupIncludeBuff readDerived(CFAstAuthorization Authorization, CFAstSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerived() "; CFAstSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFAstSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff lockDerived(CFAstAuthorization Authorization, CFAstSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerived() "; CFAstSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFAstSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff[] readAllDerived(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamSecGroupInclude.readAllDerived() "; CFAstSecGroupIncludeBuff[] retList = new CFAstSecGroupIncludeBuff[dictByPKey.values().size()]; Iterator<CFAstSecGroupIncludeBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAstSecGroupIncludeBuff[] readDerivedByClusterIdx(CFAstAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerivedByClusterIdx() "; CFAstSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFAstSecGroupIncludeBuff[] recArray; if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); recArray = new CFAstSecGroupIncludeBuff[subdictClusterIdx.size()]; Iterator<CFAstSecGroupIncludeBuff> iter = subdictClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstSecGroupIncludeBuff[0]; } return (recArray); } public CFAstSecGroupIncludeBuff[] readDerivedByGroupIdx(CFAstAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerivedByGroupIdx() "; CFAstSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); CFAstSecGroupIncludeBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx.get(key); recArray = new CFAstSecGroupIncludeBuff[subdictGroupIdx.size()]; Iterator<CFAstSecGroupIncludeBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstSecGroupIncludeBuff[0]; } return (recArray); } public CFAstSecGroupIncludeBuff[] readDerivedByIncludeIdx(CFAstAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerivedByIncludeIdx() "; CFAstSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAstSecGroupIncludeBuff[] recArray; if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); recArray = new CFAstSecGroupIncludeBuff[subdictIncludeIdx.size()]; Iterator<CFAstSecGroupIncludeBuff> iter = subdictIncludeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstSecGroupIncludeBuff[0]; } return (recArray); } public CFAstSecGroupIncludeBuff readDerivedByUIncludeIdx(CFAstAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerivedByUIncludeIdx() "; CFAstSecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAstSecGroupIncludeBuff buff; if (dictByUIncludeIdx.containsKey(key)) { buff = dictByUIncludeIdx.get(key); } else { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff readDerivedByIdIdx(CFAstAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFAstRamSecGroupInclude.readDerivedByIdIdx() "; CFAstSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupIncludeId(SecGroupIncludeId); CFAstSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff readBuff(CFAstAuthorization Authorization, CFAstSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuff() "; CFAstSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff lockBuff(CFAstAuthorization Authorization, CFAstSecGroupIncludePKey PKey) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuff() "; CFAstSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFAstSecGroupIncludeBuff[] readAllBuff(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamSecGroupInclude.readAllBuff() "; CFAstSecGroupIncludeBuff buff; ArrayList<CFAstSecGroupIncludeBuff> filteredList = new ArrayList<CFAstSecGroupIncludeBuff>(); CFAstSecGroupIncludeBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add(buff); } } return (filteredList.toArray(new CFAstSecGroupIncludeBuff[0])); } public CFAstSecGroupIncludeBuff readBuffByIdIdx(CFAstAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuffByIdIdx() "; CFAstSecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecGroupIncludeId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFAstSecGroupIncludeBuff) buff); } else { return (null); } } public CFAstSecGroupIncludeBuff[] readBuffByClusterIdx(CFAstAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuffByClusterIdx() "; CFAstSecGroupIncludeBuff buff; ArrayList<CFAstSecGroupIncludeBuff> filteredList = new ArrayList<CFAstSecGroupIncludeBuff>(); CFAstSecGroupIncludeBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add((CFAstSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstSecGroupIncludeBuff[0])); } public CFAstSecGroupIncludeBuff[] readBuffByGroupIdx(CFAstAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuffByGroupIdx() "; CFAstSecGroupIncludeBuff buff; ArrayList<CFAstSecGroupIncludeBuff> filteredList = new ArrayList<CFAstSecGroupIncludeBuff>(); CFAstSecGroupIncludeBuff[] buffList = readDerivedByGroupIdx(Authorization, ClusterId, SecGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add((CFAstSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstSecGroupIncludeBuff[0])); } public CFAstSecGroupIncludeBuff[] readBuffByIncludeIdx(CFAstAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuffByIncludeIdx() "; CFAstSecGroupIncludeBuff buff; ArrayList<CFAstSecGroupIncludeBuff> filteredList = new ArrayList<CFAstSecGroupIncludeBuff>(); CFAstSecGroupIncludeBuff[] buffList = readDerivedByIncludeIdx(Authorization, ClusterId, IncludeGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add((CFAstSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAstSecGroupIncludeBuff[0])); } public CFAstSecGroupIncludeBuff readBuffByUIncludeIdx(CFAstAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAstRamSecGroupInclude.readBuffByUIncludeIdx() "; CFAstSecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, ClusterId, SecGroupId, IncludeGroupId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFAstSecGroupIncludeBuff) buff); } else { return (null); } } public void updateSecGroupInclude(CFAstAuthorization Authorization, CFAstSecGroupIncludeBuff Buff) { CFAstSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFAstSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateSecGroupInclude", "Existing record not found", "SecGroupInclude", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupInclude", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAstSecGroupIncludeByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAstSecGroupIncludeByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAstSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAstSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAstSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); existingKeyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); newKeyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAstSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); existingKeyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); newKeyUIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); // Check unique indexes if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) { if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateSecGroupInclude", "SecGroupIncludeUIncludeIdx", newKeyUIncludeIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSecGroupInclude", "Owner", "SecGroupIncludeCluster", "Cluster", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSecGroupInclude", "Container", "SecGroupIncludeGroup", "SecGroup", null); } } } // Update is valid SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByClusterIdx.get(existingKeyClusterIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByClusterIdx.containsKey(newKeyClusterIdx)) { subdict = dictByClusterIdx.get(newKeyClusterIdx); } else { subdict = new TreeMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); dictByClusterIdx.put(newKeyClusterIdx, 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<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); 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<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff>(); dictByIncludeIdx.put(newKeyIncludeIdx, subdict); } subdict.put(pkey, Buff); dictByUIncludeIdx.remove(existingKeyUIncludeIdx); dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff); } public void deleteSecGroupInclude(CFAstAuthorization Authorization, CFAstSecGroupIncludeBuff Buff) { final String S_ProcName = "CFAstRamSecGroupIncludeTable.deleteSecGroupInclude() "; CFAstSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFAstSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupInclude", pkey); } CFAstSecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAstSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAstSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAstSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByIncludeIdx.get(keyIncludeIdx); subdict.remove(pkey); dictByUIncludeIdx.remove(keyUIncludeIdx); } public void deleteSecGroupIncludeByIdIdx(CFAstAuthorization Authorization, long argClusterId, long argSecGroupIncludeId) { CFAstSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupIncludeId(argSecGroupIncludeId); deleteSecGroupIncludeByIdIdx(Authorization, key); } public void deleteSecGroupIncludeByIdIdx(CFAstAuthorization Authorization, CFAstSecGroupIncludePKey argKey) { CFAstSecGroupIncludeBuff cur; LinkedList<CFAstSecGroupIncludeBuff> matchSet = new LinkedList<CFAstSecGroupIncludeBuff>(); Iterator<CFAstSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByClusterIdx(CFAstAuthorization Authorization, long argClusterId) { CFAstSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSecGroupIncludeByClusterIdx(Authorization, key); } public void deleteSecGroupIncludeByClusterIdx(CFAstAuthorization Authorization, CFAstSecGroupIncludeByClusterIdxKey argKey) { CFAstSecGroupIncludeBuff cur; LinkedList<CFAstSecGroupIncludeBuff> matchSet = new LinkedList<CFAstSecGroupIncludeBuff>(); Iterator<CFAstSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByGroupIdx(CFAstAuthorization Authorization, long argClusterId, int argSecGroupId) { CFAstSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); deleteSecGroupIncludeByGroupIdx(Authorization, key); } public void deleteSecGroupIncludeByGroupIdx(CFAstAuthorization Authorization, CFAstSecGroupIncludeByGroupIdxKey argKey) { CFAstSecGroupIncludeBuff cur; LinkedList<CFAstSecGroupIncludeBuff> matchSet = new LinkedList<CFAstSecGroupIncludeBuff>(); Iterator<CFAstSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByIncludeIdx(CFAstAuthorization Authorization, long argClusterId, int argIncludeGroupId) { CFAstSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByIncludeIdx(CFAstAuthorization Authorization, CFAstSecGroupIncludeByIncludeIdxKey argKey) { CFAstSecGroupIncludeBuff cur; LinkedList<CFAstSecGroupIncludeBuff> matchSet = new LinkedList<CFAstSecGroupIncludeBuff>(); Iterator<CFAstSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByUIncludeIdx(CFAstAuthorization Authorization, long argClusterId, int argSecGroupId, int argIncludeGroupId) { CFAstSecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByUIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByUIncludeIdx(CFAstAuthorization Authorization, CFAstSecGroupIncludeByUIncludeIdxKey argKey) { CFAstSecGroupIncludeBuff cur; LinkedList<CFAstSecGroupIncludeBuff> matchSet = new LinkedList<CFAstSecGroupIncludeBuff>(); Iterator<CFAstSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public CFAstCursor openSecGroupIncludeCursorAll(CFAstAuthorization Authorization) { CFAstCursor cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFAstCursor openSecGroupIncludeCursorByClusterIdx(CFAstAuthorization Authorization, long ClusterId) { CFAstCursor cursor; CFAstSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, subdictClusterIdx.values()); } else { cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstSecGroupIncludeBuff>()); } return (cursor); } public CFAstCursor openSecGroupIncludeCursorByGroupIdx(CFAstAuthorization Authorization, long ClusterId, int SecGroupId) { CFAstCursor cursor; CFAstSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx.get(key); cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstSecGroupIncludeBuff>()); } return (cursor); } public CFAstCursor openSecGroupIncludeCursorByIncludeIdx(CFAstAuthorization Authorization, long ClusterId, int IncludeGroupId) { CFAstCursor cursor; CFAstSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAstSecGroupIncludePKey, CFAstSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values()); } else { cursor = new CFAstRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAstSecGroupIncludeBuff>()); } return (cursor); } public void closeSecGroupIncludeCursor(CFAstCursor Cursor) { // Cursor.DataReader.Close(); } public CFAstSecGroupIncludeBuff nextSecGroupIncludeCursor(CFAstCursor Cursor) { CFAstRamSecGroupIncludeCursor cursor = (CFAstRamSecGroupIncludeCursor) Cursor; CFAstSecGroupIncludeBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAstSecGroupIncludeBuff prevSecGroupIncludeCursor(CFAstCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAstSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFAstSecGroupIncludeBuff firstSecGroupIncludeCursor(CFAstCursor Cursor) { int targetRowIdx = 1; CFAstSecGroupIncludeBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFAstSecGroupIncludeBuff lastSecGroupIncludeCursor(CFAstCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecGroupIncludeCursor"); } public CFAstSecGroupIncludeBuff nthSecGroupIncludeCursor(CFAstCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAstSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }