Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for SecGroupInclude. /* * MSS Code Factory Accounting Business Application Model * * Copyright (c) 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.cfacc.v2_0.CFAccRam; 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.cfacc.v2_0.CFAcc.*; import net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.*; /* * CFAccRamSecGroupIncludeTable in-memory RAM DbIO implementation * for SecGroupInclude. */ public class CFAccRamSecGroupIncludeTable implements ICFAccSecGroupIncludeTable { private CFAccRamSchema schema; private Map<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> dictByPKey = new HashMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); private SortedMap<CFAccSecGroupIncludeByClusterIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>> dictByClusterIdx = new TreeMap<CFAccSecGroupIncludeByClusterIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>>(); private SortedMap<CFAccSecGroupIncludeByGroupIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<CFAccSecGroupIncludeByGroupIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>>(); private SortedMap<CFAccSecGroupIncludeByIncludeIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<CFAccSecGroupIncludeByIncludeIdxKey, SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>>(); private SortedMap<CFAccSecGroupIncludeByUIncludeIdxKey, CFAccSecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<CFAccSecGroupIncludeByUIncludeIdxKey, CFAccSecGroupIncludeBuff>(); public CFAccRamSecGroupIncludeTable(CFAccRamSchema argSchema) { schema = argSchema; } public void createSecGroupInclude(CFAccAuthorization Authorization, CFAccSecGroupIncludeBuff Buff) { CFAccSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(((CFAccRamClusterTable) schema.getTableCluster()) .nextSecGroupIncludeIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecGroupIncludeId(pkey.getRequiredSecGroupIncludeId()); CFAccSecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAccSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAccSecGroupIncludeByUIncludeIdxKey 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictIncludeIdx; if (dictByIncludeIdx.containsKey(keyIncludeIdx)) { subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx); } else { subdictIncludeIdx = new TreeMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx); } subdictIncludeIdx.put(pkey, Buff); dictByUIncludeIdx.put(keyUIncludeIdx, Buff); } public CFAccSecGroupIncludeBuff readDerived(CFAccAuthorization Authorization, CFAccSecGroupIncludePKey PKey) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerived() "; CFAccSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFAccSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff lockDerived(CFAccAuthorization Authorization, CFAccSecGroupIncludePKey PKey) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerived() "; CFAccSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFAccSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff[] readAllDerived(CFAccAuthorization Authorization) { final String S_ProcName = "CFAccRamSecGroupInclude.readAllDerived() "; CFAccSecGroupIncludeBuff[] retList = new CFAccSecGroupIncludeBuff[dictByPKey.values().size()]; Iterator<CFAccSecGroupIncludeBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAccSecGroupIncludeBuff[] readDerivedByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerivedByClusterIdx() "; CFAccSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFAccSecGroupIncludeBuff[] recArray; if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); recArray = new CFAccSecGroupIncludeBuff[subdictClusterIdx.size()]; Iterator<CFAccSecGroupIncludeBuff> iter = subdictClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupIncludeBuff[0]; } return (recArray); } public CFAccSecGroupIncludeBuff[] readDerivedByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerivedByGroupIdx() "; CFAccSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); CFAccSecGroupIncludeBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx.get(key); recArray = new CFAccSecGroupIncludeBuff[subdictGroupIdx.size()]; Iterator<CFAccSecGroupIncludeBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupIncludeBuff[0]; } return (recArray); } public CFAccSecGroupIncludeBuff[] readDerivedByIncludeIdx(CFAccAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerivedByIncludeIdx() "; CFAccSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAccSecGroupIncludeBuff[] recArray; if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); recArray = new CFAccSecGroupIncludeBuff[subdictIncludeIdx.size()]; Iterator<CFAccSecGroupIncludeBuff> iter = subdictIncludeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupIncludeBuff[0]; } return (recArray); } public CFAccSecGroupIncludeBuff readDerivedByUIncludeIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerivedByUIncludeIdx() "; CFAccSecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); key.setRequiredIncludeGroupId(IncludeGroupId); CFAccSecGroupIncludeBuff buff; if (dictByUIncludeIdx.containsKey(key)) { buff = dictByUIncludeIdx.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff readDerivedByIdIdx(CFAccAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFAccRamSecGroupInclude.readDerivedByIdIdx() "; CFAccSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupIncludeId(SecGroupIncludeId); CFAccSecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff readBuff(CFAccAuthorization Authorization, CFAccSecGroupIncludePKey PKey) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuff() "; CFAccSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff lockBuff(CFAccAuthorization Authorization, CFAccSecGroupIncludePKey PKey) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuff() "; CFAccSecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFAccSecGroupIncludeBuff[] readAllBuff(CFAccAuthorization Authorization) { final String S_ProcName = "CFAccRamSecGroupInclude.readAllBuff() "; CFAccSecGroupIncludeBuff buff; ArrayList<CFAccSecGroupIncludeBuff> filteredList = new ArrayList<CFAccSecGroupIncludeBuff>(); CFAccSecGroupIncludeBuff[] 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 CFAccSecGroupIncludeBuff[0])); } public CFAccSecGroupIncludeBuff readBuffByIdIdx(CFAccAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuffByIdIdx() "; CFAccSecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecGroupIncludeId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFAccSecGroupIncludeBuff) buff); } else { return (null); } } public CFAccSecGroupIncludeBuff[] readBuffByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuffByClusterIdx() "; CFAccSecGroupIncludeBuff buff; ArrayList<CFAccSecGroupIncludeBuff> filteredList = new ArrayList<CFAccSecGroupIncludeBuff>(); CFAccSecGroupIncludeBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add((CFAccSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupIncludeBuff[0])); } public CFAccSecGroupIncludeBuff[] readBuffByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuffByGroupIdx() "; CFAccSecGroupIncludeBuff buff; ArrayList<CFAccSecGroupIncludeBuff> filteredList = new ArrayList<CFAccSecGroupIncludeBuff>(); CFAccSecGroupIncludeBuff[] 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((CFAccSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupIncludeBuff[0])); } public CFAccSecGroupIncludeBuff[] readBuffByIncludeIdx(CFAccAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuffByIncludeIdx() "; CFAccSecGroupIncludeBuff buff; ArrayList<CFAccSecGroupIncludeBuff> filteredList = new ArrayList<CFAccSecGroupIncludeBuff>(); CFAccSecGroupIncludeBuff[] 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((CFAccSecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupIncludeBuff[0])); } public CFAccSecGroupIncludeBuff readBuffByUIncludeIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFAccRamSecGroupInclude.readBuffByUIncludeIdx() "; CFAccSecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, ClusterId, SecGroupId, IncludeGroupId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFAccSecGroupIncludeBuff) buff); } else { return (null); } } public void updateSecGroupInclude(CFAccAuthorization Authorization, CFAccSecGroupIncludeBuff Buff) { CFAccSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFAccSecGroupIncludeBuff 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); CFAccSecGroupIncludeByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAccSecGroupIncludeByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAccSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAccSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); existingKeyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAccSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); newKeyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFAccSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); existingKeyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAccSecGroupIncludeByUIncludeIdxKey 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); 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<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff>(); dictByIncludeIdx.put(newKeyIncludeIdx, subdict); } subdict.put(pkey, Buff); dictByUIncludeIdx.remove(existingKeyUIncludeIdx); dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff); } public void deleteSecGroupInclude(CFAccAuthorization Authorization, CFAccSecGroupIncludeBuff Buff) { final String S_ProcName = "CFAccRamSecGroupIncludeTable.deleteSecGroupInclude() "; CFAccSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFAccSecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupInclude", pkey); } CFAccSecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAccSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAccSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFAccSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> 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(CFAccAuthorization Authorization, long argClusterId, long argSecGroupIncludeId) { CFAccSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupIncludeId(argSecGroupIncludeId); deleteSecGroupIncludeByIdIdx(Authorization, key); } public void deleteSecGroupIncludeByIdIdx(CFAccAuthorization Authorization, CFAccSecGroupIncludePKey argKey) { CFAccSecGroupIncludeBuff cur; LinkedList<CFAccSecGroupIncludeBuff> matchSet = new LinkedList<CFAccSecGroupIncludeBuff>(); Iterator<CFAccSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByClusterIdx(CFAccAuthorization Authorization, long argClusterId) { CFAccSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSecGroupIncludeByClusterIdx(Authorization, key); } public void deleteSecGroupIncludeByClusterIdx(CFAccAuthorization Authorization, CFAccSecGroupIncludeByClusterIdxKey argKey) { CFAccSecGroupIncludeBuff cur; LinkedList<CFAccSecGroupIncludeBuff> matchSet = new LinkedList<CFAccSecGroupIncludeBuff>(); Iterator<CFAccSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByGroupIdx(CFAccAuthorization Authorization, long argClusterId, int argSecGroupId) { CFAccSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); deleteSecGroupIncludeByGroupIdx(Authorization, key); } public void deleteSecGroupIncludeByGroupIdx(CFAccAuthorization Authorization, CFAccSecGroupIncludeByGroupIdxKey argKey) { CFAccSecGroupIncludeBuff cur; LinkedList<CFAccSecGroupIncludeBuff> matchSet = new LinkedList<CFAccSecGroupIncludeBuff>(); Iterator<CFAccSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByIncludeIdx(CFAccAuthorization Authorization, long argClusterId, int argIncludeGroupId) { CFAccSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByIncludeIdx(CFAccAuthorization Authorization, CFAccSecGroupIncludeByIncludeIdxKey argKey) { CFAccSecGroupIncludeBuff cur; LinkedList<CFAccSecGroupIncludeBuff> matchSet = new LinkedList<CFAccSecGroupIncludeBuff>(); Iterator<CFAccSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByUIncludeIdx(CFAccAuthorization Authorization, long argClusterId, int argSecGroupId, int argIncludeGroupId) { CFAccSecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByUIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByUIncludeIdx(CFAccAuthorization Authorization, CFAccSecGroupIncludeByUIncludeIdxKey argKey) { CFAccSecGroupIncludeBuff cur; LinkedList<CFAccSecGroupIncludeBuff> matchSet = new LinkedList<CFAccSecGroupIncludeBuff>(); Iterator<CFAccSecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public CFAccCursor openSecGroupIncludeCursorAll(CFAccAuthorization Authorization) { CFAccCursor cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFAccCursor openSecGroupIncludeCursorByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { CFAccCursor cursor; CFAccSecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, subdictClusterIdx.values()); } else { cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAccSecGroupIncludeBuff>()); } return (cursor); } public CFAccCursor openSecGroupIncludeCursorByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { CFAccCursor cursor; CFAccSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx.get(key); cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAccSecGroupIncludeBuff>()); } return (cursor); } public CFAccCursor openSecGroupIncludeCursorByIncludeIdx(CFAccAuthorization Authorization, long ClusterId, int IncludeGroupId) { CFAccCursor cursor; CFAccSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFAccSecGroupIncludePKey, CFAccSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values()); } else { cursor = new CFAccRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFAccSecGroupIncludeBuff>()); } return (cursor); } public void closeSecGroupIncludeCursor(CFAccCursor Cursor) { // Cursor.DataReader.Close(); } public CFAccSecGroupIncludeBuff nextSecGroupIncludeCursor(CFAccCursor Cursor) { CFAccRamSecGroupIncludeCursor cursor = (CFAccRamSecGroupIncludeCursor) Cursor; CFAccSecGroupIncludeBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAccSecGroupIncludeBuff prevSecGroupIncludeCursor(CFAccCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAccSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFAccSecGroupIncludeBuff firstSecGroupIncludeCursor(CFAccCursor Cursor) { int targetRowIdx = 1; CFAccSecGroupIncludeBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFAccSecGroupIncludeBuff lastSecGroupIncludeCursor(CFAccCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecGroupIncludeCursor"); } public CFAccSecGroupIncludeBuff nthSecGroupIncludeCursor(CFAccCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAccSecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }