Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for SecGroupInclude. /* * CF Security Core Implementation * * Copyright (c) 2010-2014 Mark Sobkow * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam; import java.sql.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurity.*; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.*; /* * CFSecurityRamSecGroupIncludeTable in-memory RAM DbIO implementation * for SecGroupInclude. */ public class CFSecurityRamSecGroupIncludeTable implements ICFSecuritySecGroupIncludeTable { private CFSecurityRamSchema schema; private Map<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> dictByPKey = new HashMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); private SortedMap<CFSecuritySecGroupIncludeByClusterIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>> dictByClusterIdx = new TreeMap<CFSecuritySecGroupIncludeByClusterIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>>(); private SortedMap<CFSecuritySecGroupIncludeByGroupIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<CFSecuritySecGroupIncludeByGroupIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>>(); private SortedMap<CFSecuritySecGroupIncludeByIncludeIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<CFSecuritySecGroupIncludeByIncludeIdxKey, SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>>(); private SortedMap<CFSecuritySecGroupIncludeByUIncludeIdxKey, CFSecuritySecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<CFSecuritySecGroupIncludeByUIncludeIdxKey, CFSecuritySecGroupIncludeBuff>(); public CFSecurityRamSecGroupIncludeTable(CFSecurityRamSchema argSchema) { schema = argSchema; } public void createSecGroupInclude(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeBuff Buff) { CFSecuritySecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(((CFSecurityRamClusterTable) schema.getTableCluster()) .nextSecGroupIncludeIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecGroupIncludeId(pkey.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecuritySecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFSecuritySecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByUIncludeIdxKey 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<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictIncludeIdx; if (dictByIncludeIdx.containsKey(keyIncludeIdx)) { subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx); } else { subdictIncludeIdx = new TreeMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx); } subdictIncludeIdx.put(pkey, Buff); dictByUIncludeIdx.put(keyUIncludeIdx, Buff); } public CFSecuritySecGroupIncludeBuff readDerived(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerived() "; CFSecuritySecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff lockDerived(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerived() "; CFSecuritySecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readAllDerived() "; CFSecuritySecGroupIncludeBuff[] retList = new CFSecuritySecGroupIncludeBuff[dictByPKey.values().size()]; Iterator<CFSecuritySecGroupIncludeBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFSecuritySecGroupIncludeBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerivedByClusterIdx() "; CFSecuritySecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFSecuritySecGroupIncludeBuff[] recArray; if (dictByClusterIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); recArray = new CFSecuritySecGroupIncludeBuff[subdictClusterIdx.size()]; Iterator<CFSecuritySecGroupIncludeBuff> iter = subdictClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecuritySecGroupIncludeBuff[0]; } return (recArray); } public CFSecuritySecGroupIncludeBuff[] readDerivedByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerivedByGroupIdx() "; CFSecuritySecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); CFSecuritySecGroupIncludeBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); recArray = new CFSecuritySecGroupIncludeBuff[subdictGroupIdx.size()]; Iterator<CFSecuritySecGroupIncludeBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecuritySecGroupIncludeBuff[0]; } return (recArray); } public CFSecuritySecGroupIncludeBuff[] readDerivedByIncludeIdx(CFSecurityAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerivedByIncludeIdx() "; CFSecuritySecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); CFSecuritySecGroupIncludeBuff[] recArray; if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); recArray = new CFSecuritySecGroupIncludeBuff[subdictIncludeIdx.size()]; Iterator<CFSecuritySecGroupIncludeBuff> iter = subdictIncludeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecuritySecGroupIncludeBuff[0]; } return (recArray); } public CFSecuritySecGroupIncludeBuff readDerivedByUIncludeIdx(CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerivedByUIncludeIdx() "; CFSecuritySecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); key.setRequiredIncludeGroupId(IncludeGroupId); CFSecuritySecGroupIncludeBuff buff; if (dictByUIncludeIdx.containsKey(key)) { buff = dictByUIncludeIdx.get(key); } else { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readDerivedByIdIdx() "; CFSecuritySecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupIncludeId(SecGroupIncludeId); CFSecuritySecGroupIncludeBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff readBuff(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuff() "; CFSecuritySecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff lockBuff(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludePKey PKey) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuff() "; CFSecuritySecGroupIncludeBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) { buff = null; } return (buff); } public CFSecuritySecGroupIncludeBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readAllBuff() "; CFSecuritySecGroupIncludeBuff buff; ArrayList<CFSecuritySecGroupIncludeBuff> filteredList = new ArrayList<CFSecuritySecGroupIncludeBuff>(); CFSecuritySecGroupIncludeBuff[] 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 CFSecuritySecGroupIncludeBuff[0])); } public CFSecuritySecGroupIncludeBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long SecGroupIncludeId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuffByIdIdx() "; CFSecuritySecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecGroupIncludeId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFSecuritySecGroupIncludeBuff) buff); } else { return (null); } } public CFSecuritySecGroupIncludeBuff[] readBuffByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuffByClusterIdx() "; CFSecuritySecGroupIncludeBuff buff; ArrayList<CFSecuritySecGroupIncludeBuff> filteredList = new ArrayList<CFSecuritySecGroupIncludeBuff>(); CFSecuritySecGroupIncludeBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGNC")) { filteredList.add((CFSecuritySecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecuritySecGroupIncludeBuff[0])); } public CFSecuritySecGroupIncludeBuff[] readBuffByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuffByGroupIdx() "; CFSecuritySecGroupIncludeBuff buff; ArrayList<CFSecuritySecGroupIncludeBuff> filteredList = new ArrayList<CFSecuritySecGroupIncludeBuff>(); CFSecuritySecGroupIncludeBuff[] 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((CFSecuritySecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecuritySecGroupIncludeBuff[0])); } public CFSecuritySecGroupIncludeBuff[] readBuffByIncludeIdx(CFSecurityAuthorization Authorization, long ClusterId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuffByIncludeIdx() "; CFSecuritySecGroupIncludeBuff buff; ArrayList<CFSecuritySecGroupIncludeBuff> filteredList = new ArrayList<CFSecuritySecGroupIncludeBuff>(); CFSecuritySecGroupIncludeBuff[] 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((CFSecuritySecGroupIncludeBuff) buff); } } return (filteredList.toArray(new CFSecuritySecGroupIncludeBuff[0])); } public CFSecuritySecGroupIncludeBuff readBuffByUIncludeIdx(CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId, int IncludeGroupId) { final String S_ProcName = "CFSecurityRamSecGroupInclude.readBuffByUIncludeIdx() "; CFSecuritySecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, ClusterId, SecGroupId, IncludeGroupId); if ((buff != null) && buff.getClassCode().equals("SGNC")) { return ((CFSecuritySecGroupIncludeBuff) buff); } else { return (null); } } public void updateSecGroupInclude(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeBuff Buff) { CFSecuritySecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeBuff 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); CFSecuritySecGroupIncludeByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupIncludeByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFSecuritySecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude() .newGroupIdxKey(); existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFSecuritySecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFSecuritySecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); existingKeyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); newKeyIncludeIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); existingKeyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByUIncludeIdxKey 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<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> 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<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); 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<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); 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<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff>(); dictByIncludeIdx.put(newKeyIncludeIdx, subdict); } subdict.put(pkey, Buff); dictByUIncludeIdx.remove(existingKeyUIncludeIdx); dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff); } public void deleteSecGroupInclude(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeBuff Buff) { final String S_ProcName = "CFSecurityRamSecGroupIncludeTable.deleteSecGroupInclude() "; CFSecuritySecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId()); CFSecuritySecGroupIncludeBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupInclude", pkey); } CFSecuritySecGroupIncludeByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupInclude() .newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFSecuritySecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFSecuritySecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude() .newIncludeIdxKey(); keyIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); CFSecuritySecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude() .newUIncludeIdxKey(); keyUIncludeIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> 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(CFSecurityAuthorization Authorization, long argClusterId, long argSecGroupIncludeId) { CFSecuritySecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupIncludeId(argSecGroupIncludeId); deleteSecGroupIncludeByIdIdx(Authorization, key); } public void deleteSecGroupIncludeByIdIdx(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludePKey argKey) { CFSecuritySecGroupIncludeBuff cur; LinkedList<CFSecuritySecGroupIncludeBuff> matchSet = new LinkedList<CFSecuritySecGroupIncludeBuff>(); Iterator<CFSecuritySecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) { CFSecuritySecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSecGroupIncludeByClusterIdx(Authorization, key); } public void deleteSecGroupIncludeByClusterIdx(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeByClusterIdxKey argKey) { CFSecuritySecGroupIncludeBuff cur; LinkedList<CFSecuritySecGroupIncludeBuff> matchSet = new LinkedList<CFSecuritySecGroupIncludeBuff>(); Iterator<CFSecuritySecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByGroupIdx(CFSecurityAuthorization Authorization, long argClusterId, int argSecGroupId) { CFSecuritySecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); deleteSecGroupIncludeByGroupIdx(Authorization, key); } public void deleteSecGroupIncludeByGroupIdx(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeByGroupIdxKey argKey) { CFSecuritySecGroupIncludeBuff cur; LinkedList<CFSecuritySecGroupIncludeBuff> matchSet = new LinkedList<CFSecuritySecGroupIncludeBuff>(); Iterator<CFSecuritySecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByIncludeIdx(CFSecurityAuthorization Authorization, long argClusterId, int argIncludeGroupId) { CFSecuritySecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByIncludeIdx(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeByIncludeIdxKey argKey) { CFSecuritySecGroupIncludeBuff cur; LinkedList<CFSecuritySecGroupIncludeBuff> matchSet = new LinkedList<CFSecuritySecGroupIncludeBuff>(); Iterator<CFSecuritySecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public void deleteSecGroupIncludeByUIncludeIdx(CFSecurityAuthorization Authorization, long argClusterId, int argSecGroupId, int argIncludeGroupId) { CFSecuritySecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); key.setRequiredIncludeGroupId(argIncludeGroupId); deleteSecGroupIncludeByUIncludeIdx(Authorization, key); } public void deleteSecGroupIncludeByUIncludeIdx(CFSecurityAuthorization Authorization, CFSecuritySecGroupIncludeByUIncludeIdxKey argKey) { CFSecuritySecGroupIncludeBuff cur; LinkedList<CFSecuritySecGroupIncludeBuff> matchSet = new LinkedList<CFSecuritySecGroupIncludeBuff>(); Iterator<CFSecuritySecGroupIncludeBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecuritySecGroupIncludeBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupInclude(Authorization, cur); } } public CFSecurityCursor openSecGroupIncludeCursorAll(CFSecurityAuthorization Authorization) { CFSecurityCursor cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFSecurityCursor openSecGroupIncludeCursorByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { CFSecurityCursor cursor; CFSecuritySecGroupIncludeByClusterIdxKey key = schema.getFactorySecGroupInclude().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictByClusterIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictClusterIdx = dictByClusterIdx .get(key); cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, subdictClusterIdx.values()); } else { cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecuritySecGroupIncludeBuff>()); } return (cursor); } public CFSecurityCursor openSecGroupIncludeCursorByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId, int SecGroupId) { CFSecurityCursor cursor; CFSecuritySecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx .get(key); cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecuritySecGroupIncludeBuff>()); } return (cursor); } public CFSecurityCursor openSecGroupIncludeCursorByIncludeIdx(CFSecurityAuthorization Authorization, long ClusterId, int IncludeGroupId) { CFSecurityCursor cursor; CFSecuritySecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredIncludeGroupId(IncludeGroupId); if (dictByIncludeIdx.containsKey(key)) { SortedMap<CFSecuritySecGroupIncludePKey, CFSecuritySecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx .get(key); cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values()); } else { cursor = new CFSecurityRamSecGroupIncludeCursor(Authorization, schema, new ArrayList<CFSecuritySecGroupIncludeBuff>()); } return (cursor); } public void closeSecGroupIncludeCursor(CFSecurityCursor Cursor) { // Cursor.DataReader.Close(); } public CFSecuritySecGroupIncludeBuff nextSecGroupIncludeCursor(CFSecurityCursor Cursor) { CFSecurityRamSecGroupIncludeCursor cursor = (CFSecurityRamSecGroupIncludeCursor) Cursor; CFSecuritySecGroupIncludeBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFSecuritySecGroupIncludeBuff prevSecGroupIncludeCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFSecuritySecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFSecuritySecGroupIncludeBuff firstSecGroupIncludeCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFSecuritySecGroupIncludeBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public CFSecuritySecGroupIncludeBuff lastSecGroupIncludeCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecGroupIncludeCursor"); } public CFSecuritySecGroupIncludeBuff nthSecGroupIncludeCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFSecuritySecGroupIncludeBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupIncludeCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }