net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamISOCountryCurrencyTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamISOCountryCurrencyTable.java

Source

// Description: Java7 in-memory RAM DbIO implementation for ISOCountryCurrency.

/*
 *   CF Asterisk 11 Configuration Model
 *
 *   Copyright (c) 2013-2014 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *     
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.0-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and
 *      CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 1.11
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 1.11 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam;

import java.sql.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.*;

/*
 *   CFAstRamISOCountryCurrencyTable in-memory RAM DbIO implementation
 *   for ISOCountryCurrency.
 */
public class CFAstRamISOCountryCurrencyTable implements ICFAstISOCountryCurrencyTable {
    private CFAstRamSchema schema;
    private Map<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> dictByPKey = new HashMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>();
    private SortedMap<CFAstISOCountryCurrencyByCountryIdxKey, SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>> dictByCountryIdx = new TreeMap<CFAstISOCountryCurrencyByCountryIdxKey, SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>>();
    private SortedMap<CFAstISOCountryCurrencyByCurrencyIdxKey, SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>> dictByCurrencyIdx = new TreeMap<CFAstISOCountryCurrencyByCurrencyIdxKey, SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>>();

    public CFAstRamISOCountryCurrencyTable(CFAstRamSchema argSchema) {
        schema = argSchema;
    }

    public void createISOCountryCurrency(CFAstAuthorization Authorization, CFAstISOCountryCurrencyBuff Buff) {
        CFAstISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
        pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
        pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
        Buff.setRequiredISOCountryId(pkey.getRequiredISOCountryId());
        Buff.setRequiredISOCurrencyId(pkey.getRequiredISOCurrencyId());
        CFAstISOCountryCurrencyByCountryIdxKey keyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(Buff.getRequiredISOCountryId());

        CFAstISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx = schema.getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());

        // Validate unique indexes

        if (dictByPKey.containsKey(pkey)) {
            throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(),
                    "createISOCountryCurrency", pkey);
        }

        // Validate foreign keys

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableISOCountry().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredISOCountryId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createISOCountryCurrency", "Container", "ISOCountryCurrencyCountry", "ISOCountry",
                            null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCountryIdx;
        if (dictByCountryIdx.containsKey(keyCountryIdx)) {
            subdictCountryIdx = dictByCountryIdx.get(keyCountryIdx);
        } else {
            subdictCountryIdx = new TreeMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>();
            dictByCountryIdx.put(keyCountryIdx, subdictCountryIdx);
        }
        subdictCountryIdx.put(pkey, Buff);

        SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCurrencyIdx;
        if (dictByCurrencyIdx.containsKey(keyCurrencyIdx)) {
            subdictCurrencyIdx = dictByCurrencyIdx.get(keyCurrencyIdx);
        } else {
            subdictCurrencyIdx = new TreeMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>();
            dictByCurrencyIdx.put(keyCurrencyIdx, subdictCurrencyIdx);
        }
        subdictCurrencyIdx.put(pkey, Buff);

    }

    public CFAstISOCountryCurrencyBuff readDerived(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readDerived() ";
        CFAstISOCountryCurrencyPKey key = schema.getFactoryISOCountryCurrency().newPKey();
        key.setRequiredISOCountryId(PKey.getRequiredISOCountryId());
        key.setRequiredISOCurrencyId(PKey.getRequiredISOCurrencyId());
        CFAstISOCountryCurrencyBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAstISOCountryCurrencyBuff lockDerived(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readDerived() ";
        CFAstISOCountryCurrencyPKey key = schema.getFactoryISOCountryCurrency().newPKey();
        key.setRequiredISOCountryId(PKey.getRequiredISOCountryId());
        key.setRequiredISOCurrencyId(PKey.getRequiredISOCurrencyId());
        CFAstISOCountryCurrencyBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAstISOCountryCurrencyBuff[] readAllDerived(CFAstAuthorization Authorization) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readAllDerived() ";
        CFAstISOCountryCurrencyBuff[] retList = new CFAstISOCountryCurrencyBuff[dictByPKey.values().size()];
        Iterator<CFAstISOCountryCurrencyBuff> iter = dictByPKey.values().iterator();
        int idx = 0;
        while (iter.hasNext()) {
            retList[idx++] = iter.next();
        }
        return (retList);
    }

    public CFAstISOCountryCurrencyBuff[] readDerivedByCountryIdx(CFAstAuthorization Authorization,
            short ISOCountryId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readDerivedByCountryIdx() ";
        CFAstISOCountryCurrencyByCountryIdxKey key = schema.getFactoryISOCountryCurrency().newCountryIdxKey();
        key.setRequiredISOCountryId(ISOCountryId);

        CFAstISOCountryCurrencyBuff[] recArray;
        if (dictByCountryIdx.containsKey(key)) {
            SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCountryIdx = dictByCountryIdx
                    .get(key);
            recArray = new CFAstISOCountryCurrencyBuff[subdictCountryIdx.size()];
            Iterator<CFAstISOCountryCurrencyBuff> iter = subdictCountryIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new CFAstISOCountryCurrencyBuff[0];
        }
        return (recArray);
    }

    public CFAstISOCountryCurrencyBuff[] readDerivedByCurrencyIdx(CFAstAuthorization Authorization,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readDerivedByCurrencyIdx() ";
        CFAstISOCountryCurrencyByCurrencyIdxKey key = schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
        key.setRequiredISOCurrencyId(ISOCurrencyId);

        CFAstISOCountryCurrencyBuff[] recArray;
        if (dictByCurrencyIdx.containsKey(key)) {
            SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCurrencyIdx = dictByCurrencyIdx
                    .get(key);
            recArray = new CFAstISOCountryCurrencyBuff[subdictCurrencyIdx.size()];
            Iterator<CFAstISOCountryCurrencyBuff> iter = subdictCurrencyIdx.values().iterator();
            int idx = 0;
            while (iter.hasNext()) {
                recArray[idx++] = iter.next();
            }
        } else {
            recArray = new CFAstISOCountryCurrencyBuff[0];
        }
        return (recArray);
    }

    public CFAstISOCountryCurrencyBuff readDerivedByIdIdx(CFAstAuthorization Authorization, short ISOCountryId,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readDerivedByIdIdx() ";
        CFAstISOCountryCurrencyPKey key = schema.getFactoryISOCountryCurrency().newPKey();
        key.setRequiredISOCountryId(ISOCountryId);
        key.setRequiredISOCurrencyId(ISOCurrencyId);

        CFAstISOCountryCurrencyBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAstISOCountryCurrencyBuff readBuff(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readBuff() ";
        CFAstISOCountryCurrencyBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("ICCY"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAstISOCountryCurrencyBuff lockBuff(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readBuff() ";
        CFAstISOCountryCurrencyBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("ICCY"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAstISOCountryCurrencyBuff[] readAllBuff(CFAstAuthorization Authorization) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readAllBuff() ";
        CFAstISOCountryCurrencyBuff buff;
        ArrayList<CFAstISOCountryCurrencyBuff> filteredList = new ArrayList<CFAstISOCountryCurrencyBuff>();
        CFAstISOCountryCurrencyBuff[] buffList = readAllDerived(Authorization);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ICCY")) {
                filteredList.add(buff);
            }
        }
        return (filteredList.toArray(new CFAstISOCountryCurrencyBuff[0]));
    }

    public CFAstISOCountryCurrencyBuff readBuffByIdIdx(CFAstAuthorization Authorization, short ISOCountryId,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readBuffByIdIdx() ";
        CFAstISOCountryCurrencyBuff buff = readDerivedByIdIdx(Authorization, ISOCountryId, ISOCurrencyId);
        if ((buff != null) && buff.getClassCode().equals("ICCY")) {
            return ((CFAstISOCountryCurrencyBuff) buff);
        } else {
            return (null);
        }
    }

    public CFAstISOCountryCurrencyBuff[] readBuffByCountryIdx(CFAstAuthorization Authorization,
            short ISOCountryId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readBuffByCountryIdx() ";
        CFAstISOCountryCurrencyBuff buff;
        ArrayList<CFAstISOCountryCurrencyBuff> filteredList = new ArrayList<CFAstISOCountryCurrencyBuff>();
        CFAstISOCountryCurrencyBuff[] buffList = readDerivedByCountryIdx(Authorization, ISOCountryId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ICCY")) {
                filteredList.add((CFAstISOCountryCurrencyBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstISOCountryCurrencyBuff[0]));
    }

    public CFAstISOCountryCurrencyBuff[] readBuffByCurrencyIdx(CFAstAuthorization Authorization,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAstRamISOCountryCurrency.readBuffByCurrencyIdx() ";
        CFAstISOCountryCurrencyBuff buff;
        ArrayList<CFAstISOCountryCurrencyBuff> filteredList = new ArrayList<CFAstISOCountryCurrencyBuff>();
        CFAstISOCountryCurrencyBuff[] buffList = readDerivedByCurrencyIdx(Authorization, ISOCurrencyId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ICCY")) {
                filteredList.add((CFAstISOCountryCurrencyBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstISOCountryCurrencyBuff[0]));
    }

    public void updateISOCountryCurrency(CFAstAuthorization Authorization, CFAstISOCountryCurrencyBuff Buff) {
        CFAstISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
        pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
        pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
        CFAstISOCountryCurrencyBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateISOCountryCurrency", "Existing record not found", "ISOCountryCurrency", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "updateISOCountryCurrency", pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        CFAstISOCountryCurrencyByCountryIdxKey existingKeyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        existingKeyCountryIdx.setRequiredISOCountryId(existing.getRequiredISOCountryId());

        CFAstISOCountryCurrencyByCountryIdxKey newKeyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        newKeyCountryIdx.setRequiredISOCountryId(Buff.getRequiredISOCountryId());

        CFAstISOCountryCurrencyByCurrencyIdxKey existingKeyCurrencyIdx = schema.getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        existingKeyCurrencyIdx.setRequiredISOCurrencyId(existing.getRequiredISOCurrencyId());

        CFAstISOCountryCurrencyByCurrencyIdxKey newKeyCurrencyIdx = schema.getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        newKeyCurrencyIdx.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableISOCountry().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredISOCountryId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateISOCountryCurrency", "Container", "ISOCountryCurrencyCountry", "ISOCountry",
                            null);
                }
            }
        }

        // Update is valid

        SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdict;

        dictByPKey.remove(pkey);
        dictByPKey.put(pkey, Buff);

        subdict = dictByCountryIdx.get(existingKeyCountryIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByCountryIdx.containsKey(newKeyCountryIdx)) {
            subdict = dictByCountryIdx.get(newKeyCountryIdx);
        } else {
            subdict = new TreeMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>();
            dictByCountryIdx.put(newKeyCountryIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByCurrencyIdx.get(existingKeyCurrencyIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByCurrencyIdx.containsKey(newKeyCurrencyIdx)) {
            subdict = dictByCurrencyIdx.get(newKeyCurrencyIdx);
        } else {
            subdict = new TreeMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff>();
            dictByCurrencyIdx.put(newKeyCurrencyIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteISOCountryCurrency(CFAstAuthorization Authorization, CFAstISOCountryCurrencyBuff Buff) {
        final String S_ProcName = "CFAstRamISOCountryCurrencyTable.deleteISOCountryCurrency() ";
        CFAstISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
        pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
        pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
        CFAstISOCountryCurrencyBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteISOCountryCurrency", pkey);
        }
        CFAstISOCountryCurrencyByCountryIdxKey keyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(existing.getRequiredISOCountryId());

        CFAstISOCountryCurrencyByCurrencyIdxKey keyCurrencyIdx = schema.getFactoryISOCountryCurrency()
                .newCurrencyIdxKey();
        keyCurrencyIdx.setRequiredISOCurrencyId(existing.getRequiredISOCurrencyId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByCountryIdx.get(keyCountryIdx);
        subdict.remove(pkey);

        subdict = dictByCurrencyIdx.get(keyCurrencyIdx);
        subdict.remove(pkey);

    }

    public void deleteISOCountryCurrencyByIdIdx(CFAstAuthorization Authorization, short argISOCountryId,
            short argISOCurrencyId) {
        CFAstISOCountryCurrencyPKey key = schema.getFactoryISOCountryCurrency().newPKey();
        key.setRequiredISOCountryId(argISOCountryId);
        key.setRequiredISOCurrencyId(argISOCurrencyId);
        deleteISOCountryCurrencyByIdIdx(Authorization, key);
    }

    public void deleteISOCountryCurrencyByIdIdx(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyPKey argKey) {
        CFAstISOCountryCurrencyBuff cur;
        LinkedList<CFAstISOCountryCurrencyBuff> matchSet = new LinkedList<CFAstISOCountryCurrencyBuff>();
        Iterator<CFAstISOCountryCurrencyBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstISOCountryCurrencyBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteISOCountryCurrency(Authorization, cur);
        }
    }

    public void deleteISOCountryCurrencyByCountryIdx(CFAstAuthorization Authorization, short argISOCountryId) {
        CFAstISOCountryCurrencyByCountryIdxKey key = schema.getFactoryISOCountryCurrency().newCountryIdxKey();
        key.setRequiredISOCountryId(argISOCountryId);
        deleteISOCountryCurrencyByCountryIdx(Authorization, key);
    }

    public void deleteISOCountryCurrencyByCountryIdx(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyByCountryIdxKey argKey) {
        CFAstISOCountryCurrencyBuff cur;
        LinkedList<CFAstISOCountryCurrencyBuff> matchSet = new LinkedList<CFAstISOCountryCurrencyBuff>();
        Iterator<CFAstISOCountryCurrencyBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstISOCountryCurrencyBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteISOCountryCurrency(Authorization, cur);
        }
    }

    public void deleteISOCountryCurrencyByCurrencyIdx(CFAstAuthorization Authorization, short argISOCurrencyId) {
        CFAstISOCountryCurrencyByCurrencyIdxKey key = schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
        key.setRequiredISOCurrencyId(argISOCurrencyId);
        deleteISOCountryCurrencyByCurrencyIdx(Authorization, key);
    }

    public void deleteISOCountryCurrencyByCurrencyIdx(CFAstAuthorization Authorization,
            CFAstISOCountryCurrencyByCurrencyIdxKey argKey) {
        CFAstISOCountryCurrencyBuff cur;
        LinkedList<CFAstISOCountryCurrencyBuff> matchSet = new LinkedList<CFAstISOCountryCurrencyBuff>();
        Iterator<CFAstISOCountryCurrencyBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstISOCountryCurrencyBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteISOCountryCurrency(Authorization, cur);
        }
    }

    public CFAstCursor openISOCountryCurrencyCursorAll(CFAstAuthorization Authorization) {
        CFAstCursor cursor = new CFAstRamISOCountryCurrencyCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public CFAstCursor openISOCountryCurrencyCursorByCountryIdx(CFAstAuthorization Authorization,
            short ISOCountryId) {
        CFAstCursor cursor;
        CFAstISOCountryCurrencyByCountryIdxKey key = schema.getFactoryISOCountryCurrency().newCountryIdxKey();
        key.setRequiredISOCountryId(ISOCountryId);

        if (dictByCountryIdx.containsKey(key)) {
            SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCountryIdx = dictByCountryIdx
                    .get(key);
            cursor = new CFAstRamISOCountryCurrencyCursor(Authorization, schema, subdictCountryIdx.values());
        } else {
            cursor = new CFAstRamISOCountryCurrencyCursor(Authorization, schema,
                    new ArrayList<CFAstISOCountryCurrencyBuff>());
        }
        return (cursor);
    }

    public CFAstCursor openISOCountryCurrencyCursorByCurrencyIdx(CFAstAuthorization Authorization,
            short ISOCurrencyId) {
        CFAstCursor cursor;
        CFAstISOCountryCurrencyByCurrencyIdxKey key = schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
        key.setRequiredISOCurrencyId(ISOCurrencyId);

        if (dictByCurrencyIdx.containsKey(key)) {
            SortedMap<CFAstISOCountryCurrencyPKey, CFAstISOCountryCurrencyBuff> subdictCurrencyIdx = dictByCurrencyIdx
                    .get(key);
            cursor = new CFAstRamISOCountryCurrencyCursor(Authorization, schema, subdictCurrencyIdx.values());
        } else {
            cursor = new CFAstRamISOCountryCurrencyCursor(Authorization, schema,
                    new ArrayList<CFAstISOCountryCurrencyBuff>());
        }
        return (cursor);
    }

    public void closeISOCountryCurrencyCursor(CFAstCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public CFAstISOCountryCurrencyBuff nextISOCountryCurrencyCursor(CFAstCursor Cursor) {
        CFAstRamISOCountryCurrencyCursor cursor = (CFAstRamISOCountryCurrencyCursor) Cursor;
        CFAstISOCountryCurrencyBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public CFAstISOCountryCurrencyBuff prevISOCountryCurrencyCursor(CFAstCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFAstISOCountryCurrencyBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextISOCountryCurrencyCursor(Cursor);
        }
        return (rec);
    }

    public CFAstISOCountryCurrencyBuff firstISOCountryCurrencyCursor(CFAstCursor Cursor) {
        int targetRowIdx = 1;
        CFAstISOCountryCurrencyBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextISOCountryCurrencyCursor(Cursor);
        }
        return (rec);
    }

    public CFAstISOCountryCurrencyBuff lastISOCountryCurrencyCursor(CFAstCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(),
                "lastISOCountryCurrencyCursor");
    }

    public CFAstISOCountryCurrencyBuff nthISOCountryCurrencyCursor(CFAstCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFAstISOCountryCurrencyBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextISOCountryCurrencyCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}