Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for SecGroupForm. /* * 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.*; /* * CFAccRamSecGroupFormTable in-memory RAM DbIO implementation * for SecGroupForm. */ public class CFAccRamSecGroupFormTable implements ICFAccSecGroupFormTable { private CFAccRamSchema schema; private Map<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> dictByPKey = new HashMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); private SortedMap<CFAccSecGroupFormByClusterIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>> dictByClusterIdx = new TreeMap<CFAccSecGroupFormByClusterIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>>(); private SortedMap<CFAccSecGroupFormByGroupIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>> dictByGroupIdx = new TreeMap<CFAccSecGroupFormByGroupIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>>(); private SortedMap<CFAccSecGroupFormByAppIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>> dictByAppIdx = new TreeMap<CFAccSecGroupFormByAppIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>>(); private SortedMap<CFAccSecGroupFormByFormIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>> dictByFormIdx = new TreeMap<CFAccSecGroupFormByFormIdxKey, SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>>(); private SortedMap<CFAccSecGroupFormByUFormIdxKey, CFAccSecGroupFormBuff> dictByUFormIdx = new TreeMap<CFAccSecGroupFormByUFormIdxKey, CFAccSecGroupFormBuff>(); public CFAccRamSecGroupFormTable(CFAccRamSchema argSchema) { schema = argSchema; } public void createSecGroupForm(CFAccAuthorization Authorization, CFAccSecGroupFormBuff Buff) { CFAccSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupFormId(((CFAccRamClusterTable) schema.getTableCluster()) .nextSecGroupFormIdGen(Authorization, Buff.getRequiredClusterId())); Buff.setRequiredClusterId(pkey.getRequiredClusterId()); Buff.setRequiredSecGroupFormId(pkey.getRequiredSecGroupFormId()); CFAccSecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAccSecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey(); keyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId()); CFAccSecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey(); keyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId()); CFAccSecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey(); keyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId()); keyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); keyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createSecGroupForm", pkey); } if (dictByUFormIdx.containsKey(keyUFormIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecGroupForm", "SecGroupFormUFormIdx", keyUFormIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createSecGroupForm", "Owner", "SecGroupFormCluster", "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(), "createSecGroupForm", "Container", "SecGroupFormGroup", "SecGroup", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictClusterIdx; if (dictByClusterIdx.containsKey(keyClusterIdx)) { subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx); } else { subdictClusterIdx = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx); } subdictClusterIdx.put(pkey, Buff); SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictAppIdx; if (dictByAppIdx.containsKey(keyAppIdx)) { subdictAppIdx = dictByAppIdx.get(keyAppIdx); } else { subdictAppIdx = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByAppIdx.put(keyAppIdx, subdictAppIdx); } subdictAppIdx.put(pkey, Buff); SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictFormIdx; if (dictByFormIdx.containsKey(keyFormIdx)) { subdictFormIdx = dictByFormIdx.get(keyFormIdx); } else { subdictFormIdx = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByFormIdx.put(keyFormIdx, subdictFormIdx); } subdictFormIdx.put(pkey, Buff); dictByUFormIdx.put(keyUFormIdx, Buff); } public CFAccSecGroupFormBuff readDerived(CFAccAuthorization Authorization, CFAccSecGroupFormPKey PKey) { final String S_ProcName = "CFAccRamSecGroupForm.readDerived() "; CFAccSecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupFormId(PKey.getRequiredSecGroupFormId()); CFAccSecGroupFormBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupFormBuff lockDerived(CFAccAuthorization Authorization, CFAccSecGroupFormPKey PKey) { final String S_ProcName = "CFAccRamSecGroupForm.readDerived() "; CFAccSecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredSecGroupFormId(PKey.getRequiredSecGroupFormId()); CFAccSecGroupFormBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupFormBuff[] readAllDerived(CFAccAuthorization Authorization) { final String S_ProcName = "CFAccRamSecGroupForm.readAllDerived() "; CFAccSecGroupFormBuff[] retList = new CFAccSecGroupFormBuff[dictByPKey.values().size()]; Iterator<CFAccSecGroupFormBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAccSecGroupFormBuff[] readDerivedByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByClusterIdx() "; CFAccSecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFAccSecGroupFormBuff[] recArray; if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictClusterIdx = dictByClusterIdx.get(key); recArray = new CFAccSecGroupFormBuff[subdictClusterIdx.size()]; Iterator<CFAccSecGroupFormBuff> iter = subdictClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupFormBuff[0]; } return (recArray); } public CFAccSecGroupFormBuff[] readDerivedByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByGroupIdx() "; CFAccSecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); CFAccSecGroupFormBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictGroupIdx = dictByGroupIdx.get(key); recArray = new CFAccSecGroupFormBuff[subdictGroupIdx.size()]; Iterator<CFAccSecGroupFormBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupFormBuff[0]; } return (recArray); } public CFAccSecGroupFormBuff[] readDerivedByAppIdx(CFAccAuthorization Authorization, long ClusterId, int SecAppId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByAppIdx() "; CFAccSecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecAppId(SecAppId); CFAccSecGroupFormBuff[] recArray; if (dictByAppIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictAppIdx = dictByAppIdx.get(key); recArray = new CFAccSecGroupFormBuff[subdictAppIdx.size()]; Iterator<CFAccSecGroupFormBuff> iter = subdictAppIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupFormBuff[0]; } return (recArray); } public CFAccSecGroupFormBuff[] readDerivedByFormIdx(CFAccAuthorization Authorization, long ClusterId, int SecFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByFormIdx() "; CFAccSecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecFormId(SecFormId); CFAccSecGroupFormBuff[] recArray; if (dictByFormIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictFormIdx = dictByFormIdx.get(key); recArray = new CFAccSecGroupFormBuff[subdictFormIdx.size()]; Iterator<CFAccSecGroupFormBuff> iter = subdictFormIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAccSecGroupFormBuff[0]; } return (recArray); } public CFAccSecGroupFormBuff readDerivedByUFormIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId, int SecFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByUFormIdx() "; CFAccSecGroupFormByUFormIdxKey key = schema.getFactorySecGroupForm().newUFormIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); key.setRequiredSecFormId(SecFormId); CFAccSecGroupFormBuff buff; if (dictByUFormIdx.containsKey(key)) { buff = dictByUFormIdx.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupFormBuff readDerivedByIdIdx(CFAccAuthorization Authorization, long ClusterId, long SecGroupFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readDerivedByIdIdx() "; CFAccSecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupFormId(SecGroupFormId); CFAccSecGroupFormBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAccSecGroupFormBuff readBuff(CFAccAuthorization Authorization, CFAccSecGroupFormPKey PKey) { final String S_ProcName = "CFAccRamSecGroupForm.readBuff() "; CFAccSecGroupFormBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGFM"))) { buff = null; } return (buff); } public CFAccSecGroupFormBuff lockBuff(CFAccAuthorization Authorization, CFAccSecGroupFormPKey PKey) { final String S_ProcName = "CFAccRamSecGroupForm.readBuff() "; CFAccSecGroupFormBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("SGFM"))) { buff = null; } return (buff); } public CFAccSecGroupFormBuff[] readAllBuff(CFAccAuthorization Authorization) { final String S_ProcName = "CFAccRamSecGroupForm.readAllBuff() "; CFAccSecGroupFormBuff buff; ArrayList<CFAccSecGroupFormBuff> filteredList = new ArrayList<CFAccSecGroupFormBuff>(); CFAccSecGroupFormBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGFM")) { filteredList.add(buff); } } return (filteredList.toArray(new CFAccSecGroupFormBuff[0])); } public CFAccSecGroupFormBuff readBuffByIdIdx(CFAccAuthorization Authorization, long ClusterId, long SecGroupFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByIdIdx() "; CFAccSecGroupFormBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecGroupFormId); if ((buff != null) && buff.getClassCode().equals("SGFM")) { return ((CFAccSecGroupFormBuff) buff); } else { return (null); } } public CFAccSecGroupFormBuff[] readBuffByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByClusterIdx() "; CFAccSecGroupFormBuff buff; ArrayList<CFAccSecGroupFormBuff> filteredList = new ArrayList<CFAccSecGroupFormBuff>(); CFAccSecGroupFormBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGFM")) { filteredList.add((CFAccSecGroupFormBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupFormBuff[0])); } public CFAccSecGroupFormBuff[] readBuffByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByGroupIdx() "; CFAccSecGroupFormBuff buff; ArrayList<CFAccSecGroupFormBuff> filteredList = new ArrayList<CFAccSecGroupFormBuff>(); CFAccSecGroupFormBuff[] buffList = readDerivedByGroupIdx(Authorization, ClusterId, SecGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGFM")) { filteredList.add((CFAccSecGroupFormBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupFormBuff[0])); } public CFAccSecGroupFormBuff[] readBuffByAppIdx(CFAccAuthorization Authorization, long ClusterId, int SecAppId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByAppIdx() "; CFAccSecGroupFormBuff buff; ArrayList<CFAccSecGroupFormBuff> filteredList = new ArrayList<CFAccSecGroupFormBuff>(); CFAccSecGroupFormBuff[] buffList = readDerivedByAppIdx(Authorization, ClusterId, SecAppId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGFM")) { filteredList.add((CFAccSecGroupFormBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupFormBuff[0])); } public CFAccSecGroupFormBuff[] readBuffByFormIdx(CFAccAuthorization Authorization, long ClusterId, int SecFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByFormIdx() "; CFAccSecGroupFormBuff buff; ArrayList<CFAccSecGroupFormBuff> filteredList = new ArrayList<CFAccSecGroupFormBuff>(); CFAccSecGroupFormBuff[] buffList = readDerivedByFormIdx(Authorization, ClusterId, SecFormId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("SGFM")) { filteredList.add((CFAccSecGroupFormBuff) buff); } } return (filteredList.toArray(new CFAccSecGroupFormBuff[0])); } public CFAccSecGroupFormBuff readBuffByUFormIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId, int SecFormId) { final String S_ProcName = "CFAccRamSecGroupForm.readBuffByUFormIdx() "; CFAccSecGroupFormBuff buff = readDerivedByUFormIdx(Authorization, ClusterId, SecGroupId, SecFormId); if ((buff != null) && buff.getClassCode().equals("SGFM")) { return ((CFAccSecGroupFormBuff) buff); } else { return (null); } } public void updateSecGroupForm(CFAccAuthorization Authorization, CFAccSecGroupFormBuff Buff) { CFAccSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId()); CFAccSecGroupFormBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupForm", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFAccSecGroupFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey(); existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAccSecGroupFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey(); newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); CFAccSecGroupFormByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey(); existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAccSecGroupFormByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey(); newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); CFAccSecGroupFormByAppIdxKey existingKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey(); existingKeyAppIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId()); CFAccSecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey(); newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId()); CFAccSecGroupFormByFormIdxKey existingKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey(); existingKeyFormIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId()); CFAccSecGroupFormByFormIdxKey newKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey(); newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId()); CFAccSecGroupFormByUFormIdxKey existingKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey(); existingKeyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId()); existingKeyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); existingKeyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId()); CFAccSecGroupFormByUFormIdxKey newKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey(); newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId()); newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId()); newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId()); // Check unique indexes if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) { if (dictByUFormIdx.containsKey(newKeyUFormIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSecGroupForm", "Owner", "SecGroupFormCluster", "Cluster", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateSecGroupForm", "Container", "SecGroupFormGroup", "SecGroup", null); } } } // Update is valid SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> 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<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); 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<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByGroupIdx.put(newKeyGroupIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByAppIdx.get(existingKeyAppIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByAppIdx.containsKey(newKeyAppIdx)) { subdict = dictByAppIdx.get(newKeyAppIdx); } else { subdict = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByAppIdx.put(newKeyAppIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByFormIdx.get(existingKeyFormIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByFormIdx.containsKey(newKeyFormIdx)) { subdict = dictByFormIdx.get(newKeyFormIdx); } else { subdict = new TreeMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff>(); dictByFormIdx.put(newKeyFormIdx, subdict); } subdict.put(pkey, Buff); dictByUFormIdx.remove(existingKeyUFormIdx); dictByUFormIdx.put(newKeyUFormIdx, Buff); } public void deleteSecGroupForm(CFAccAuthorization Authorization, CFAccSecGroupFormBuff Buff) { final String S_ProcName = "CFAccRamSecGroupFormTable.deleteSecGroupForm() "; CFAccSecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId()); CFAccSecGroupFormBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupForm", pkey); } CFAccSecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey(); keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAccSecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey(); keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); CFAccSecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey(); keyAppIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId()); CFAccSecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey(); keyFormIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId()); CFAccSecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey(); keyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId()); keyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId()); keyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdict; dictByPKey.remove(pkey); subdict = dictByClusterIdx.get(keyClusterIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByAppIdx.get(keyAppIdx); subdict.remove(pkey); subdict = dictByFormIdx.get(keyFormIdx); subdict.remove(pkey); dictByUFormIdx.remove(keyUFormIdx); } public void deleteSecGroupFormByIdIdx(CFAccAuthorization Authorization, long argClusterId, long argSecGroupFormId) { CFAccSecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupFormId(argSecGroupFormId); deleteSecGroupFormByIdIdx(Authorization, key); } public void deleteSecGroupFormByIdIdx(CFAccAuthorization Authorization, CFAccSecGroupFormPKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public void deleteSecGroupFormByClusterIdx(CFAccAuthorization Authorization, long argClusterId) { CFAccSecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteSecGroupFormByClusterIdx(Authorization, key); } public void deleteSecGroupFormByClusterIdx(CFAccAuthorization Authorization, CFAccSecGroupFormByClusterIdxKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public void deleteSecGroupFormByGroupIdx(CFAccAuthorization Authorization, long argClusterId, int argSecGroupId) { CFAccSecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); deleteSecGroupFormByGroupIdx(Authorization, key); } public void deleteSecGroupFormByGroupIdx(CFAccAuthorization Authorization, CFAccSecGroupFormByGroupIdxKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public void deleteSecGroupFormByAppIdx(CFAccAuthorization Authorization, long argClusterId, int argSecAppId) { CFAccSecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecAppId(argSecAppId); deleteSecGroupFormByAppIdx(Authorization, key); } public void deleteSecGroupFormByAppIdx(CFAccAuthorization Authorization, CFAccSecGroupFormByAppIdxKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public void deleteSecGroupFormByFormIdx(CFAccAuthorization Authorization, long argClusterId, int argSecFormId) { CFAccSecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecFormId(argSecFormId); deleteSecGroupFormByFormIdx(Authorization, key); } public void deleteSecGroupFormByFormIdx(CFAccAuthorization Authorization, CFAccSecGroupFormByFormIdxKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public void deleteSecGroupFormByUFormIdx(CFAccAuthorization Authorization, long argClusterId, int argSecGroupId, int argSecFormId) { CFAccSecGroupFormByUFormIdxKey key = schema.getFactorySecGroupForm().newUFormIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredSecGroupId(argSecGroupId); key.setRequiredSecFormId(argSecFormId); deleteSecGroupFormByUFormIdx(Authorization, key); } public void deleteSecGroupFormByUFormIdx(CFAccAuthorization Authorization, CFAccSecGroupFormByUFormIdxKey argKey) { CFAccSecGroupFormBuff cur; LinkedList<CFAccSecGroupFormBuff> matchSet = new LinkedList<CFAccSecGroupFormBuff>(); Iterator<CFAccSecGroupFormBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAccSecGroupFormBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteSecGroupForm(Authorization, cur); } } public CFAccCursor openSecGroupFormCursorAll(CFAccAuthorization Authorization) { CFAccCursor cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFAccCursor openSecGroupFormCursorByClusterIdx(CFAccAuthorization Authorization, long ClusterId) { CFAccCursor cursor; CFAccSecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictByClusterIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictClusterIdx = dictByClusterIdx.get(key); cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, subdictClusterIdx.values()); } else { cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, new ArrayList<CFAccSecGroupFormBuff>()); } return (cursor); } public CFAccCursor openSecGroupFormCursorByGroupIdx(CFAccAuthorization Authorization, long ClusterId, int SecGroupId) { CFAccCursor cursor; CFAccSecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecGroupId(SecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictGroupIdx = dictByGroupIdx.get(key); cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, new ArrayList<CFAccSecGroupFormBuff>()); } return (cursor); } public CFAccCursor openSecGroupFormCursorByAppIdx(CFAccAuthorization Authorization, long ClusterId, int SecAppId) { CFAccCursor cursor; CFAccSecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecAppId(SecAppId); if (dictByAppIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictAppIdx = dictByAppIdx.get(key); cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, subdictAppIdx.values()); } else { cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, new ArrayList<CFAccSecGroupFormBuff>()); } return (cursor); } public CFAccCursor openSecGroupFormCursorByFormIdx(CFAccAuthorization Authorization, long ClusterId, int SecFormId) { CFAccCursor cursor; CFAccSecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey(); key.setRequiredClusterId(ClusterId); key.setRequiredSecFormId(SecFormId); if (dictByFormIdx.containsKey(key)) { SortedMap<CFAccSecGroupFormPKey, CFAccSecGroupFormBuff> subdictFormIdx = dictByFormIdx.get(key); cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, subdictFormIdx.values()); } else { cursor = new CFAccRamSecGroupFormCursor(Authorization, schema, new ArrayList<CFAccSecGroupFormBuff>()); } return (cursor); } public void closeSecGroupFormCursor(CFAccCursor Cursor) { // Cursor.DataReader.Close(); } public CFAccSecGroupFormBuff nextSecGroupFormCursor(CFAccCursor Cursor) { CFAccRamSecGroupFormCursor cursor = (CFAccRamSecGroupFormCursor) Cursor; CFAccSecGroupFormBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAccSecGroupFormBuff prevSecGroupFormCursor(CFAccCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAccSecGroupFormBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupFormCursor(Cursor); } return (rec); } public CFAccSecGroupFormBuff firstSecGroupFormCursor(CFAccCursor Cursor) { int targetRowIdx = 1; CFAccSecGroupFormBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupFormCursor(Cursor); } return (rec); } public CFAccSecGroupFormBuff lastSecGroupFormCursor(CFAccCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecGroupFormCursor"); } public CFAccSecGroupFormBuff nthSecGroupFormCursor(CFAccCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAccSecGroupFormBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextSecGroupFormCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }