net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamISOCountryCurrencyTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamISOCountryCurrencyTable.java

Source

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

/*
 *   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.*;

/*
 *   CFAccRamISOCountryCurrencyTable in-memory RAM DbIO implementation
 *   for ISOCountryCurrency.
 */
public class CFAccRamISOCountryCurrencyTable implements ICFAccISOCountryCurrencyTable {
    private CFAccRamSchema schema;
    private Map<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff> dictByPKey = new HashMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>();
    private SortedMap<CFAccISOCountryCurrencyByCountryIdxKey, SortedMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>> dictByCountryIdx = new TreeMap<CFAccISOCountryCurrencyByCountryIdxKey, SortedMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>>();
    private SortedMap<CFAccISOCountryCurrencyByCurrencyIdxKey, SortedMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>> dictByCurrencyIdx = new TreeMap<CFAccISOCountryCurrencyByCurrencyIdxKey, SortedMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>>();

    public CFAccRamISOCountryCurrencyTable(CFAccRamSchema argSchema) {
        schema = argSchema;
    }

    public void createISOCountryCurrency(CFAccAuthorization Authorization, CFAccISOCountryCurrencyBuff Buff) {
        CFAccISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
        pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
        pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
        Buff.setRequiredISOCountryId(pkey.getRequiredISOCountryId());
        Buff.setRequiredISOCurrencyId(pkey.getRequiredISOCurrencyId());
        CFAccISOCountryCurrencyByCountryIdxKey keyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        keyCountryIdx.setRequiredISOCountryId(Buff.getRequiredISOCountryId());

        CFAccISOCountryCurrencyByCurrencyIdxKey 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<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff> subdictCountryIdx;
        if (dictByCountryIdx.containsKey(keyCountryIdx)) {
            subdictCountryIdx = dictByCountryIdx.get(keyCountryIdx);
        } else {
            subdictCountryIdx = new TreeMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>();
            dictByCountryIdx.put(keyCountryIdx, subdictCountryIdx);
        }
        subdictCountryIdx.put(pkey, Buff);

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

    }

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

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

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

    public CFAccISOCountryCurrencyBuff[] readDerivedByCountryIdx(CFAccAuthorization Authorization,
            short ISOCountryId) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readDerivedByCountryIdx() ";
        CFAccISOCountryCurrencyByCountryIdxKey key = schema.getFactoryISOCountryCurrency().newCountryIdxKey();
        key.setRequiredISOCountryId(ISOCountryId);

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

    public CFAccISOCountryCurrencyBuff[] readDerivedByCurrencyIdx(CFAccAuthorization Authorization,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readDerivedByCurrencyIdx() ";
        CFAccISOCountryCurrencyByCurrencyIdxKey key = schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
        key.setRequiredISOCurrencyId(ISOCurrencyId);

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

    public CFAccISOCountryCurrencyBuff readDerivedByIdIdx(CFAccAuthorization Authorization, short ISOCountryId,
            short ISOCurrencyId) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readDerivedByIdIdx() ";
        CFAccISOCountryCurrencyPKey key = schema.getFactoryISOCountryCurrency().newPKey();
        key.setRequiredISOCountryId(ISOCountryId);
        key.setRequiredISOCurrencyId(ISOCurrencyId);

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

    public CFAccISOCountryCurrencyBuff readBuff(CFAccAuthorization Authorization,
            CFAccISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readBuff() ";
        CFAccISOCountryCurrencyBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("ICCY"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAccISOCountryCurrencyBuff lockBuff(CFAccAuthorization Authorization,
            CFAccISOCountryCurrencyPKey PKey) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readBuff() ";
        CFAccISOCountryCurrencyBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("ICCY"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAccISOCountryCurrencyBuff[] readAllBuff(CFAccAuthorization Authorization) {
        final String S_ProcName = "CFAccRamISOCountryCurrency.readAllBuff() ";
        CFAccISOCountryCurrencyBuff buff;
        ArrayList<CFAccISOCountryCurrencyBuff> filteredList = new ArrayList<CFAccISOCountryCurrencyBuff>();
        CFAccISOCountryCurrencyBuff[] 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 CFAccISOCountryCurrencyBuff[0]));
    }

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

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

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

    public void updateISOCountryCurrency(CFAccAuthorization Authorization, CFAccISOCountryCurrencyBuff Buff) {
        CFAccISOCountryCurrencyPKey pkey = schema.getFactoryISOCountryCurrency().newPKey();
        pkey.setRequiredISOCountryId(Buff.getRequiredISOCountryId());
        pkey.setRequiredISOCurrencyId(Buff.getRequiredISOCurrencyId());
        CFAccISOCountryCurrencyBuff 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);
        CFAccISOCountryCurrencyByCountryIdxKey existingKeyCountryIdx = schema.getFactoryISOCountryCurrency()
                .newCountryIdxKey();
        existingKeyCountryIdx.setRequiredISOCountryId(existing.getRequiredISOCountryId());

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

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

        CFAccISOCountryCurrencyByCurrencyIdxKey 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<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff> 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<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>();
            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<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff>();
            dictByCurrencyIdx.put(newKeyCurrencyIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

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

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

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFAccISOCountryCurrencyPKey, CFAccISOCountryCurrencyBuff> subdict;

        dictByPKey.remove(pkey);

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

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

    }

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

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

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

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

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

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

    public CFAccCursor openISOCountryCurrencyCursorAll(CFAccAuthorization Authorization) {
        CFAccCursor cursor = new CFAccRamISOCountryCurrencyCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public CFAccCursor openISOCountryCurrencyCursorByCountryIdx(CFAccAuthorization Authorization,
            short ISOCountryId) {
        CFAccCursor cursor;
        CFAccISOCountryCurrencyByCountryIdxKey key = schema.getFactoryISOCountryCurrency().newCountryIdxKey();
        key.setRequiredISOCountryId(ISOCountryId);

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

    public CFAccCursor openISOCountryCurrencyCursorByCurrencyIdx(CFAccAuthorization Authorization,
            short ISOCurrencyId) {
        CFAccCursor cursor;
        CFAccISOCountryCurrencyByCurrencyIdxKey key = schema.getFactoryISOCountryCurrency().newCurrencyIdxKey();
        key.setRequiredISOCurrencyId(ISOCurrencyId);

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

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

    public CFAccISOCountryCurrencyBuff nextISOCountryCurrencyCursor(CFAccCursor Cursor) {
        CFAccRamISOCountryCurrencyCursor cursor = (CFAccRamISOCountryCurrencyCursor) Cursor;
        CFAccISOCountryCurrencyBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

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

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

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

    public void releasePreparedStatements() {
    }
}