Java tutorial
// Description: Java6 in-memory RAM DbIO implementation for ISOCountry. /* * MSS Code Factory 1.11 * * Copyright (c) 2012-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/>. * * *********************************************************************** * * $Revision$ */ package net.sourceforge.msscodefactory.v1_11.MSSBamRam; 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.v1_11.MSSBam.*; import net.sourceforge.msscodefactory.v1_11.MSSBamBL.*; import net.sourceforge.msscodefactory.v1_11.MSSBamBLRam.*; /* * MSSBamRamISOCountryTable in-memory RAM DbIO implementation * for ISOCountry. */ public class MSSBamRamISOCountryTable implements IMSSBamISOCountryTable { private MSSBamBLRamSchema schema; private Map<MSSBamISOCountryPKey, MSSBamISOCountryBuff> dictByPKey = new HashMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); private SortedMap<MSSBamISOCountryByISOCodeIdxKey, MSSBamISOCountryBuff> dictByISOCodeIdx = new TreeMap<MSSBamISOCountryByISOCodeIdxKey, MSSBamISOCountryBuff>(); private SortedMap<MSSBamISOCountryByISOCode3IdxKey, MSSBamISOCountryBuff> dictByISOCode3Idx = new TreeMap<MSSBamISOCountryByISOCode3IdxKey, MSSBamISOCountryBuff>(); private SortedMap<MSSBamISOCountryByIANACodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>> dictByIANACodeIdx = new TreeMap<MSSBamISOCountryByIANACodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>>(); private SortedMap<MSSBamISOCountryByIOCCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>> dictByIOCCodeIdx = new TreeMap<MSSBamISOCountryByIOCCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>>(); private SortedMap<MSSBamISOCountryByUNVCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>> dictByUNVCodeIdx = new TreeMap<MSSBamISOCountryByUNVCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>>(); private SortedMap<MSSBamISOCountryByUNISOCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>> dictByUNISOCodeIdx = new TreeMap<MSSBamISOCountryByUNISOCodeIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>>(); private SortedMap<MSSBamISOCountryByITUCallPrefixIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>> dictByITUCallPrefixIdx = new TreeMap<MSSBamISOCountryByITUCallPrefixIdxKey, SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>>(); public MSSBamRamISOCountryTable(MSSBamBLRamSchema argSchema) { schema = argSchema; } public void createISOCountry(MSSBamAuthorization Authorization, MSSBamISOCountryBuff Buff) { MSSBamISOCountryPKey pkey = schema.getFactoryISOCountry().newPKey(); pkey.setRequiredId(schema.nextISOCountryIdGen()); Buff.setRequiredId(pkey.getRequiredId()); MSSBamISOCountryByISOCodeIdxKey keyISOCodeIdx = schema.getFactoryISOCountry().newISOCodeIdxKey(); keyISOCodeIdx.setRequiredISOCode(Buff.getRequiredISOCode()); MSSBamISOCountryByISOCode3IdxKey keyISOCode3Idx = schema.getFactoryISOCountry().newISOCode3IdxKey(); keyISOCode3Idx.setRequiredISOCode3(Buff.getRequiredISOCode3()); MSSBamISOCountryByIANACodeIdxKey keyIANACodeIdx = schema.getFactoryISOCountry().newIANACodeIdxKey(); keyIANACodeIdx.setOptionalIANACode(Buff.getOptionalIANACode()); MSSBamISOCountryByIOCCodeIdxKey keyIOCCodeIdx = schema.getFactoryISOCountry().newIOCCodeIdxKey(); keyIOCCodeIdx.setOptionalIOCCode(Buff.getOptionalIOCCode()); MSSBamISOCountryByUNVCodeIdxKey keyUNVCodeIdx = schema.getFactoryISOCountry().newUNVCodeIdxKey(); keyUNVCodeIdx.setOptionalUNVCode(Buff.getOptionalUNVCode()); MSSBamISOCountryByUNISOCodeIdxKey keyUNISOCodeIdx = schema.getFactoryISOCountry().newUNISOCodeIdxKey(); keyUNISOCodeIdx.setOptionalUNISOCode(Buff.getOptionalUNISOCode()); MSSBamISOCountryByITUCallPrefixIdxKey keyITUCallPrefixIdx = schema.getFactoryISOCountry() .newITUCallPrefixIdxKey(); keyITUCallPrefixIdx.setOptionalITUCallPrefix(Buff.getOptionalITUCallPrefix()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createISOCountry", pkey); } if (dictByISOCodeIdx.containsKey(keyISOCodeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createISOCountry", "ISOCountryCodeIdx", keyISOCodeIdx); } if (dictByISOCode3Idx.containsKey(keyISOCode3Idx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createISOCountry", "ISOCountryCode3Idx", keyISOCode3Idx); } // Validate foreign keys // Proceed with adding the new record dictByPKey.put(pkey, Buff); dictByISOCodeIdx.put(keyISOCodeIdx, Buff); dictByISOCode3Idx.put(keyISOCode3Idx, Buff); SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIANACodeIdx; if (dictByIANACodeIdx.containsKey(keyIANACodeIdx)) { subdictIANACodeIdx = dictByIANACodeIdx.get(keyIANACodeIdx); } else { subdictIANACodeIdx = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByIANACodeIdx.put(keyIANACodeIdx, subdictIANACodeIdx); } subdictIANACodeIdx.put(pkey, Buff); SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIOCCodeIdx; if (dictByIOCCodeIdx.containsKey(keyIOCCodeIdx)) { subdictIOCCodeIdx = dictByIOCCodeIdx.get(keyIOCCodeIdx); } else { subdictIOCCodeIdx = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByIOCCodeIdx.put(keyIOCCodeIdx, subdictIOCCodeIdx); } subdictIOCCodeIdx.put(pkey, Buff); SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNVCodeIdx; if (dictByUNVCodeIdx.containsKey(keyUNVCodeIdx)) { subdictUNVCodeIdx = dictByUNVCodeIdx.get(keyUNVCodeIdx); } else { subdictUNVCodeIdx = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByUNVCodeIdx.put(keyUNVCodeIdx, subdictUNVCodeIdx); } subdictUNVCodeIdx.put(pkey, Buff); SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNISOCodeIdx; if (dictByUNISOCodeIdx.containsKey(keyUNISOCodeIdx)) { subdictUNISOCodeIdx = dictByUNISOCodeIdx.get(keyUNISOCodeIdx); } else { subdictUNISOCodeIdx = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByUNISOCodeIdx.put(keyUNISOCodeIdx, subdictUNISOCodeIdx); } subdictUNISOCodeIdx.put(pkey, Buff); SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictITUCallPrefixIdx; if (dictByITUCallPrefixIdx.containsKey(keyITUCallPrefixIdx)) { subdictITUCallPrefixIdx = dictByITUCallPrefixIdx.get(keyITUCallPrefixIdx); } else { subdictITUCallPrefixIdx = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByITUCallPrefixIdx.put(keyITUCallPrefixIdx, subdictITUCallPrefixIdx); } subdictITUCallPrefixIdx.put(pkey, Buff); } public MSSBamISOCountryBuff readDerived(MSSBamAuthorization Authorization, MSSBamISOCountryPKey PKey) { final String S_ProcName = "MSSBamRamISOCountry.readDerived() "; MSSBamISOCountryPKey key = schema.getFactoryISOCountry().newPKey(); key.setRequiredId(PKey.getRequiredId()); MSSBamISOCountryBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamISOCountryBuff lockDerived(MSSBamAuthorization Authorization, MSSBamISOCountryPKey PKey) { final String S_ProcName = "MSSBamRamISOCountry.readDerived() "; MSSBamISOCountryPKey key = schema.getFactoryISOCountry().newPKey(); key.setRequiredId(PKey.getRequiredId()); MSSBamISOCountryBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamISOCountryBuff[] readAllDerived(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamISOCountry.readAllDerived() "; MSSBamISOCountryBuff[] retList = new MSSBamISOCountryBuff[dictByPKey.values().size()]; Iterator<MSSBamISOCountryBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public MSSBamISOCountryBuff readDerivedByISOCodeIdx(MSSBamAuthorization Authorization, String ISOCode) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByISOCodeIdx() "; MSSBamISOCountryByISOCodeIdxKey key = schema.getFactoryISOCountry().newISOCodeIdxKey(); key.setRequiredISOCode(ISOCode); MSSBamISOCountryBuff buff; if (dictByISOCodeIdx.containsKey(key)) { buff = dictByISOCodeIdx.get(key); } else { buff = null; } return (buff); } public MSSBamISOCountryBuff readDerivedByISOCode3Idx(MSSBamAuthorization Authorization, String ISOCode3) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByISOCode3Idx() "; MSSBamISOCountryByISOCode3IdxKey key = schema.getFactoryISOCountry().newISOCode3IdxKey(); key.setRequiredISOCode3(ISOCode3); MSSBamISOCountryBuff buff; if (dictByISOCode3Idx.containsKey(key)) { buff = dictByISOCode3Idx.get(key); } else { buff = null; } return (buff); } public MSSBamISOCountryBuff[] readDerivedByIANACodeIdx(MSSBamAuthorization Authorization, String IANACode) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByIANACodeIdx() "; MSSBamISOCountryByIANACodeIdxKey key = schema.getFactoryISOCountry().newIANACodeIdxKey(); key.setOptionalIANACode(IANACode); MSSBamISOCountryBuff[] recArray; if (dictByIANACodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIANACodeIdx = dictByIANACodeIdx.get(key); recArray = new MSSBamISOCountryBuff[subdictIANACodeIdx.size()]; Iterator<MSSBamISOCountryBuff> iter = subdictIANACodeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamISOCountryBuff[0]; } return (recArray); } public MSSBamISOCountryBuff[] readDerivedByIOCCodeIdx(MSSBamAuthorization Authorization, String IOCCode) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByIOCCodeIdx() "; MSSBamISOCountryByIOCCodeIdxKey key = schema.getFactoryISOCountry().newIOCCodeIdxKey(); key.setOptionalIOCCode(IOCCode); MSSBamISOCountryBuff[] recArray; if (dictByIOCCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIOCCodeIdx = dictByIOCCodeIdx.get(key); recArray = new MSSBamISOCountryBuff[subdictIOCCodeIdx.size()]; Iterator<MSSBamISOCountryBuff> iter = subdictIOCCodeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamISOCountryBuff[0]; } return (recArray); } public MSSBamISOCountryBuff[] readDerivedByUNVCodeIdx(MSSBamAuthorization Authorization, String UNVCode) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByUNVCodeIdx() "; MSSBamISOCountryByUNVCodeIdxKey key = schema.getFactoryISOCountry().newUNVCodeIdxKey(); key.setOptionalUNVCode(UNVCode); MSSBamISOCountryBuff[] recArray; if (dictByUNVCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNVCodeIdx = dictByUNVCodeIdx.get(key); recArray = new MSSBamISOCountryBuff[subdictUNVCodeIdx.size()]; Iterator<MSSBamISOCountryBuff> iter = subdictUNVCodeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamISOCountryBuff[0]; } return (recArray); } public MSSBamISOCountryBuff[] readDerivedByUNISOCodeIdx(MSSBamAuthorization Authorization, Short UNISOCode) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByUNISOCodeIdx() "; MSSBamISOCountryByUNISOCodeIdxKey key = schema.getFactoryISOCountry().newUNISOCodeIdxKey(); key.setOptionalUNISOCode(UNISOCode); MSSBamISOCountryBuff[] recArray; if (dictByUNISOCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNISOCodeIdx = dictByUNISOCodeIdx.get(key); recArray = new MSSBamISOCountryBuff[subdictUNISOCodeIdx.size()]; Iterator<MSSBamISOCountryBuff> iter = subdictUNISOCodeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamISOCountryBuff[0]; } return (recArray); } public MSSBamISOCountryBuff[] readDerivedByITUCallPrefixIdx(MSSBamAuthorization Authorization, String ITUCallPrefix) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByITUCallPrefixIdx() "; MSSBamISOCountryByITUCallPrefixIdxKey key = schema.getFactoryISOCountry().newITUCallPrefixIdxKey(); key.setOptionalITUCallPrefix(ITUCallPrefix); MSSBamISOCountryBuff[] recArray; if (dictByITUCallPrefixIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictITUCallPrefixIdx = dictByITUCallPrefixIdx .get(key); recArray = new MSSBamISOCountryBuff[subdictITUCallPrefixIdx.size()]; Iterator<MSSBamISOCountryBuff> iter = subdictITUCallPrefixIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamISOCountryBuff[0]; } return (recArray); } public MSSBamISOCountryBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, short Id) { final String S_ProcName = "MSSBamRamISOCountry.readDerivedByIdIdx() "; MSSBamISOCountryPKey key = schema.getFactoryISOCountry().newPKey(); key.setRequiredId(Id); MSSBamISOCountryBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamISOCountryBuff readBuff(MSSBamAuthorization Authorization, MSSBamISOCountryPKey PKey) { final String S_ProcName = "MSSBamRamISOCountry.readBuff() "; MSSBamISOCountryBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("ISOC"))) { buff = null; } return (buff); } public MSSBamISOCountryBuff lockBuff(MSSBamAuthorization Authorization, MSSBamISOCountryPKey PKey) { final String S_ProcName = "MSSBamRamISOCountry.readBuff() "; MSSBamISOCountryBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("ISOC"))) { buff = null; } return (buff); } public MSSBamISOCountryBuff[] readAllBuff(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamISOCountry.readAllBuff() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add(buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public MSSBamISOCountryBuff readBuffByIdIdx(MSSBamAuthorization Authorization, short Id) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByIdIdx() "; MSSBamISOCountryBuff buff = readDerivedByIdIdx(Authorization, Id); if ((buff != null) && buff.getClassCode().equals("ISOC")) { return ((MSSBamISOCountryBuff) buff); } else { return (null); } } public MSSBamISOCountryBuff readBuffByISOCodeIdx(MSSBamAuthorization Authorization, String ISOCode) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByISOCodeIdx() "; MSSBamISOCountryBuff buff = readDerivedByISOCodeIdx(Authorization, ISOCode); if ((buff != null) && buff.getClassCode().equals("ISOC")) { return ((MSSBamISOCountryBuff) buff); } else { return (null); } } public MSSBamISOCountryBuff readBuffByISOCode3Idx(MSSBamAuthorization Authorization, String ISOCode3) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByISOCode3Idx() "; MSSBamISOCountryBuff buff = readDerivedByISOCode3Idx(Authorization, ISOCode3); if ((buff != null) && buff.getClassCode().equals("ISOC")) { return ((MSSBamISOCountryBuff) buff); } else { return (null); } } public MSSBamISOCountryBuff[] readBuffByIANACodeIdx(MSSBamAuthorization Authorization, String IANACode) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByIANACodeIdx() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readDerivedByIANACodeIdx(Authorization, IANACode); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add((MSSBamISOCountryBuff) buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public MSSBamISOCountryBuff[] readBuffByIOCCodeIdx(MSSBamAuthorization Authorization, String IOCCode) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByIOCCodeIdx() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readDerivedByIOCCodeIdx(Authorization, IOCCode); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add((MSSBamISOCountryBuff) buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public MSSBamISOCountryBuff[] readBuffByUNVCodeIdx(MSSBamAuthorization Authorization, String UNVCode) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByUNVCodeIdx() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readDerivedByUNVCodeIdx(Authorization, UNVCode); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add((MSSBamISOCountryBuff) buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public MSSBamISOCountryBuff[] readBuffByUNISOCodeIdx(MSSBamAuthorization Authorization, Short UNISOCode) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByUNISOCodeIdx() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readDerivedByUNISOCodeIdx(Authorization, UNISOCode); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add((MSSBamISOCountryBuff) buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public MSSBamISOCountryBuff[] readBuffByITUCallPrefixIdx(MSSBamAuthorization Authorization, String ITUCallPrefix) { final String S_ProcName = "MSSBamRamISOCountry.readBuffByITUCallPrefixIdx() "; MSSBamISOCountryBuff buff; ArrayList<MSSBamISOCountryBuff> filteredList = new ArrayList<MSSBamISOCountryBuff>(); MSSBamISOCountryBuff[] buffList = readDerivedByITUCallPrefixIdx(Authorization, ITUCallPrefix); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ISOC")) { filteredList.add((MSSBamISOCountryBuff) buff); } } return (filteredList.toArray(new MSSBamISOCountryBuff[0])); } public void updateISOCountry(MSSBamAuthorization Authorization, MSSBamISOCountryBuff Buff) { MSSBamISOCountryPKey pkey = schema.getFactoryISOCountry().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); MSSBamISOCountryBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateISOCountry", "Existing record not found", "ISOCountry", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateISOCountry", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); MSSBamISOCountryByISOCodeIdxKey existingKeyISOCodeIdx = schema.getFactoryISOCountry().newISOCodeIdxKey(); existingKeyISOCodeIdx.setRequiredISOCode(existing.getRequiredISOCode()); MSSBamISOCountryByISOCodeIdxKey newKeyISOCodeIdx = schema.getFactoryISOCountry().newISOCodeIdxKey(); newKeyISOCodeIdx.setRequiredISOCode(Buff.getRequiredISOCode()); MSSBamISOCountryByISOCode3IdxKey existingKeyISOCode3Idx = schema.getFactoryISOCountry().newISOCode3IdxKey(); existingKeyISOCode3Idx.setRequiredISOCode3(existing.getRequiredISOCode3()); MSSBamISOCountryByISOCode3IdxKey newKeyISOCode3Idx = schema.getFactoryISOCountry().newISOCode3IdxKey(); newKeyISOCode3Idx.setRequiredISOCode3(Buff.getRequiredISOCode3()); MSSBamISOCountryByIANACodeIdxKey existingKeyIANACodeIdx = schema.getFactoryISOCountry().newIANACodeIdxKey(); existingKeyIANACodeIdx.setOptionalIANACode(existing.getOptionalIANACode()); MSSBamISOCountryByIANACodeIdxKey newKeyIANACodeIdx = schema.getFactoryISOCountry().newIANACodeIdxKey(); newKeyIANACodeIdx.setOptionalIANACode(Buff.getOptionalIANACode()); MSSBamISOCountryByIOCCodeIdxKey existingKeyIOCCodeIdx = schema.getFactoryISOCountry().newIOCCodeIdxKey(); existingKeyIOCCodeIdx.setOptionalIOCCode(existing.getOptionalIOCCode()); MSSBamISOCountryByIOCCodeIdxKey newKeyIOCCodeIdx = schema.getFactoryISOCountry().newIOCCodeIdxKey(); newKeyIOCCodeIdx.setOptionalIOCCode(Buff.getOptionalIOCCode()); MSSBamISOCountryByUNVCodeIdxKey existingKeyUNVCodeIdx = schema.getFactoryISOCountry().newUNVCodeIdxKey(); existingKeyUNVCodeIdx.setOptionalUNVCode(existing.getOptionalUNVCode()); MSSBamISOCountryByUNVCodeIdxKey newKeyUNVCodeIdx = schema.getFactoryISOCountry().newUNVCodeIdxKey(); newKeyUNVCodeIdx.setOptionalUNVCode(Buff.getOptionalUNVCode()); MSSBamISOCountryByUNISOCodeIdxKey existingKeyUNISOCodeIdx = schema.getFactoryISOCountry() .newUNISOCodeIdxKey(); existingKeyUNISOCodeIdx.setOptionalUNISOCode(existing.getOptionalUNISOCode()); MSSBamISOCountryByUNISOCodeIdxKey newKeyUNISOCodeIdx = schema.getFactoryISOCountry().newUNISOCodeIdxKey(); newKeyUNISOCodeIdx.setOptionalUNISOCode(Buff.getOptionalUNISOCode()); MSSBamISOCountryByITUCallPrefixIdxKey existingKeyITUCallPrefixIdx = schema.getFactoryISOCountry() .newITUCallPrefixIdxKey(); existingKeyITUCallPrefixIdx.setOptionalITUCallPrefix(existing.getOptionalITUCallPrefix()); MSSBamISOCountryByITUCallPrefixIdxKey newKeyITUCallPrefixIdx = schema.getFactoryISOCountry() .newITUCallPrefixIdxKey(); newKeyITUCallPrefixIdx.setOptionalITUCallPrefix(Buff.getOptionalITUCallPrefix()); // Check unique indexes if (!existingKeyISOCodeIdx.equals(newKeyISOCodeIdx)) { if (dictByISOCodeIdx.containsKey(newKeyISOCodeIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateISOCountry", "ISOCountryCodeIdx", newKeyISOCodeIdx); } } if (!existingKeyISOCode3Idx.equals(newKeyISOCode3Idx)) { if (dictByISOCode3Idx.containsKey(newKeyISOCode3Idx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateISOCountry", "ISOCountryCode3Idx", newKeyISOCode3Idx); } } // Validate foreign keys // Update is valid SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByISOCodeIdx.remove(existingKeyISOCodeIdx); dictByISOCodeIdx.put(newKeyISOCodeIdx, Buff); dictByISOCode3Idx.remove(existingKeyISOCode3Idx); dictByISOCode3Idx.put(newKeyISOCode3Idx, Buff); subdict = dictByIANACodeIdx.get(existingKeyIANACodeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByIANACodeIdx.containsKey(newKeyIANACodeIdx)) { subdict = dictByIANACodeIdx.get(newKeyIANACodeIdx); } else { subdict = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByIANACodeIdx.put(newKeyIANACodeIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByIOCCodeIdx.get(existingKeyIOCCodeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByIOCCodeIdx.containsKey(newKeyIOCCodeIdx)) { subdict = dictByIOCCodeIdx.get(newKeyIOCCodeIdx); } else { subdict = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByIOCCodeIdx.put(newKeyIOCCodeIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByUNVCodeIdx.get(existingKeyUNVCodeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByUNVCodeIdx.containsKey(newKeyUNVCodeIdx)) { subdict = dictByUNVCodeIdx.get(newKeyUNVCodeIdx); } else { subdict = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByUNVCodeIdx.put(newKeyUNVCodeIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByUNISOCodeIdx.get(existingKeyUNISOCodeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByUNISOCodeIdx.containsKey(newKeyUNISOCodeIdx)) { subdict = dictByUNISOCodeIdx.get(newKeyUNISOCodeIdx); } else { subdict = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByUNISOCodeIdx.put(newKeyUNISOCodeIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByITUCallPrefixIdx.get(existingKeyITUCallPrefixIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByITUCallPrefixIdx.containsKey(newKeyITUCallPrefixIdx)) { subdict = dictByITUCallPrefixIdx.get(newKeyITUCallPrefixIdx); } else { subdict = new TreeMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff>(); dictByITUCallPrefixIdx.put(newKeyITUCallPrefixIdx, subdict); } subdict.put(pkey, Buff); } public void deleteISOCountry(MSSBamAuthorization Authorization, MSSBamISOCountryBuff Buff) { final String S_ProcName = "MSSBamRamISOCountryTable.deleteISOCountry() "; MSSBamISOCountryPKey pkey = schema.getFactoryISOCountry().newPKey(); pkey.setRequiredId(schema.nextISOCountryIdGen()); MSSBamISOCountryBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteISOCountry", "Existing record not found", "ISOCountry", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteISOCountry", pkey); } MSSBamISOCountryByISOCodeIdxKey keyISOCodeIdx = schema.getFactoryISOCountry().newISOCodeIdxKey(); keyISOCodeIdx.setRequiredISOCode(existing.getRequiredISOCode()); MSSBamISOCountryByISOCode3IdxKey keyISOCode3Idx = schema.getFactoryISOCountry().newISOCode3IdxKey(); keyISOCode3Idx.setRequiredISOCode3(existing.getRequiredISOCode3()); MSSBamISOCountryByIANACodeIdxKey keyIANACodeIdx = schema.getFactoryISOCountry().newIANACodeIdxKey(); keyIANACodeIdx.setOptionalIANACode(existing.getOptionalIANACode()); MSSBamISOCountryByIOCCodeIdxKey keyIOCCodeIdx = schema.getFactoryISOCountry().newIOCCodeIdxKey(); keyIOCCodeIdx.setOptionalIOCCode(existing.getOptionalIOCCode()); MSSBamISOCountryByUNVCodeIdxKey keyUNVCodeIdx = schema.getFactoryISOCountry().newUNVCodeIdxKey(); keyUNVCodeIdx.setOptionalUNVCode(existing.getOptionalUNVCode()); MSSBamISOCountryByUNISOCodeIdxKey keyUNISOCodeIdx = schema.getFactoryISOCountry().newUNISOCodeIdxKey(); keyUNISOCodeIdx.setOptionalUNISOCode(existing.getOptionalUNISOCode()); MSSBamISOCountryByITUCallPrefixIdxKey keyITUCallPrefixIdx = schema.getFactoryISOCountry() .newITUCallPrefixIdxKey(); keyITUCallPrefixIdx.setOptionalITUCallPrefix(existing.getOptionalITUCallPrefix()); // Validate reverse foreign keys if (schema.getTableISOCountryLanguage().readDerivedByCountryIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteISOCountry", "Container", "ISOCountryLanguageCountry", "ISOCountryLanguage", pkey); } if (schema.getTableISOCountryCurrency().readDerivedByCountryIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteISOCountry", "Container", "ISOCountryCurrencyCountry", "ISOCountryCurrency", pkey); } // Delete is valid SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdict; dictByPKey.remove(pkey); dictByISOCodeIdx.remove(keyISOCodeIdx); dictByISOCode3Idx.remove(keyISOCode3Idx); subdict = dictByIANACodeIdx.get(keyIANACodeIdx); subdict.remove(pkey); subdict = dictByIOCCodeIdx.get(keyIOCCodeIdx); subdict.remove(pkey); subdict = dictByUNVCodeIdx.get(keyUNVCodeIdx); subdict.remove(pkey); subdict = dictByUNISOCodeIdx.get(keyUNISOCodeIdx); subdict.remove(pkey); subdict = dictByITUCallPrefixIdx.get(keyITUCallPrefixIdx); subdict.remove(pkey); } public MSSBamCursor openISOCountryCursorAll(MSSBamAuthorization Authorization) { MSSBamCursor cursor = new MSSBamRamISOCountryCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public MSSBamCursor openISOCountryCursorByIANACodeIdx(MSSBamAuthorization Authorization, String IANACode) { MSSBamCursor cursor; MSSBamISOCountryByIANACodeIdxKey key = schema.getFactoryISOCountry().newIANACodeIdxKey(); key.setOptionalIANACode(IANACode); if (dictByIANACodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIANACodeIdx = dictByIANACodeIdx.get(key); cursor = new MSSBamRamISOCountryCursor(Authorization, schema, subdictIANACodeIdx.values()); } else { cursor = new MSSBamRamISOCountryCursor(Authorization, schema, new ArrayList<MSSBamISOCountryBuff>()); } return (cursor); } public MSSBamCursor openISOCountryCursorByIOCCodeIdx(MSSBamAuthorization Authorization, String IOCCode) { MSSBamCursor cursor; MSSBamISOCountryByIOCCodeIdxKey key = schema.getFactoryISOCountry().newIOCCodeIdxKey(); key.setOptionalIOCCode(IOCCode); if (dictByIOCCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictIOCCodeIdx = dictByIOCCodeIdx.get(key); cursor = new MSSBamRamISOCountryCursor(Authorization, schema, subdictIOCCodeIdx.values()); } else { cursor = new MSSBamRamISOCountryCursor(Authorization, schema, new ArrayList<MSSBamISOCountryBuff>()); } return (cursor); } public MSSBamCursor openISOCountryCursorByUNVCodeIdx(MSSBamAuthorization Authorization, String UNVCode) { MSSBamCursor cursor; MSSBamISOCountryByUNVCodeIdxKey key = schema.getFactoryISOCountry().newUNVCodeIdxKey(); key.setOptionalUNVCode(UNVCode); if (dictByUNVCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNVCodeIdx = dictByUNVCodeIdx.get(key); cursor = new MSSBamRamISOCountryCursor(Authorization, schema, subdictUNVCodeIdx.values()); } else { cursor = new MSSBamRamISOCountryCursor(Authorization, schema, new ArrayList<MSSBamISOCountryBuff>()); } return (cursor); } public MSSBamCursor openISOCountryCursorByUNISOCodeIdx(MSSBamAuthorization Authorization, Short UNISOCode) { MSSBamCursor cursor; MSSBamISOCountryByUNISOCodeIdxKey key = schema.getFactoryISOCountry().newUNISOCodeIdxKey(); key.setOptionalUNISOCode(UNISOCode); if (dictByUNISOCodeIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictUNISOCodeIdx = dictByUNISOCodeIdx.get(key); cursor = new MSSBamRamISOCountryCursor(Authorization, schema, subdictUNISOCodeIdx.values()); } else { cursor = new MSSBamRamISOCountryCursor(Authorization, schema, new ArrayList<MSSBamISOCountryBuff>()); } return (cursor); } public MSSBamCursor openISOCountryCursorByITUCallPrefixIdx(MSSBamAuthorization Authorization, String ITUCallPrefix) { MSSBamCursor cursor; MSSBamISOCountryByITUCallPrefixIdxKey key = schema.getFactoryISOCountry().newITUCallPrefixIdxKey(); key.setOptionalITUCallPrefix(ITUCallPrefix); if (dictByITUCallPrefixIdx.containsKey(key)) { SortedMap<MSSBamISOCountryPKey, MSSBamISOCountryBuff> subdictITUCallPrefixIdx = dictByITUCallPrefixIdx .get(key); cursor = new MSSBamRamISOCountryCursor(Authorization, schema, subdictITUCallPrefixIdx.values()); } else { cursor = new MSSBamRamISOCountryCursor(Authorization, schema, new ArrayList<MSSBamISOCountryBuff>()); } return (cursor); } public void closeISOCountryCursor(MSSBamCursor Cursor) { // Cursor.DataReader.Close(); } public MSSBamISOCountryBuff nextISOCountryCursor(MSSBamCursor Cursor) { MSSBamRamISOCountryCursor cursor = (MSSBamRamISOCountryCursor) Cursor; MSSBamISOCountryBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public MSSBamISOCountryBuff prevISOCountryCursor(MSSBamCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; MSSBamISOCountryBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextISOCountryCursor(Cursor); } return (rec); } public MSSBamISOCountryBuff firstISOCountryCursor(MSSBamCursor Cursor) { int targetRowIdx = 1; MSSBamISOCountryBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextISOCountryCursor(Cursor); } return (rec); } public MSSBamISOCountryBuff lastISOCountryCursor(MSSBamCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastISOCountryCursor"); } public MSSBamISOCountryBuff nthISOCountryCursor(MSSBamCursor Cursor, int Idx) { int targetRowIdx = Idx; MSSBamISOCountryBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextISOCountryCursor(Cursor); } return (rec); } }