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

Java tutorial

Introduction

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

Source

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

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

/*
 *   CFAccRamMinorVersionTable in-memory RAM DbIO implementation
 *   for MinorVersion.
 */
public class CFAccRamMinorVersionTable implements ICFAccMinorVersionTable {
    private CFAccRamSchema schema;
    private Map<CFAccDomainBasePKey, CFAccMinorVersionBuff> dictByPKey = new HashMap<CFAccDomainBasePKey, CFAccMinorVersionBuff>();
    private SortedMap<CFAccMinorVersionByMajorIdxKey, SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff>> dictByMajorIdx = new TreeMap<CFAccMinorVersionByMajorIdxKey, SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff>>();
    private SortedMap<CFAccMinorVersionByNameIdxKey, CFAccMinorVersionBuff> dictByNameIdx = new TreeMap<CFAccMinorVersionByNameIdxKey, CFAccMinorVersionBuff>();

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

    public void createMinorVersion(CFAccAuthorization Authorization, CFAccMinorVersionBuff Buff) {
        schema.getTableVersion().createVersion(Authorization, Buff);
        CFAccDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey();
        pkey.setClassCode(Buff.getClassCode());
        pkey.setRequiredTenantId(Buff.getRequiredTenantId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAccMinorVersionByMajorIdxKey keyMajorIdx = schema.getFactoryMinorVersion().newMajorIdxKey();
        keyMajorIdx.setRequiredTenantId(Buff.getRequiredTenantId());
        keyMajorIdx.setRequiredMajorId(Buff.getRequiredMajorId());

        CFAccMinorVersionByNameIdxKey keyNameIdx = schema.getFactoryMinorVersion().newNameIdxKey();
        keyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
        keyNameIdx.setRequiredMajorId(Buff.getRequiredMajorId());
        keyNameIdx.setRequiredName(Buff.getRequiredName());

        // Validate unique indexes

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

        if (dictByNameIdx.containsKey(keyNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createMinorVersion", "MinorVersionNameIdx", keyNameIdx);
        }

        // Validate foreign keys

        {
            boolean allNull = true;
            allNull = false;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableVersion().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                        Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createMinorVersion", "Superclass", "SuperClass", "Version", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableMajorVersion().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredTenantId(), Buff.getRequiredMajorId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createMinorVersion", "Container", "MajorVersion", "MajorVersion", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff> subdictMajorIdx;
        if (dictByMajorIdx.containsKey(keyMajorIdx)) {
            subdictMajorIdx = dictByMajorIdx.get(keyMajorIdx);
        } else {
            subdictMajorIdx = new TreeMap<CFAccDomainBasePKey, CFAccMinorVersionBuff>();
            dictByMajorIdx.put(keyMajorIdx, subdictMajorIdx);
        }
        subdictMajorIdx.put(pkey, Buff);

        dictByNameIdx.put(keyNameIdx, Buff);

    }

    public CFAccMinorVersionBuff readDerived(CFAccAuthorization Authorization, CFAccDomainBasePKey PKey) {
        final String S_ProcName = "CFAccRamMinorVersion.readDerived() ";
        CFAccDomainBasePKey key = schema.getFactoryDomainBase().newPKey();
        key.setRequiredTenantId(PKey.getRequiredTenantId());
        key.setRequiredId(PKey.getRequiredId());
        CFAccMinorVersionBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAccMinorVersionBuff lockDerived(CFAccAuthorization Authorization, CFAccDomainBasePKey PKey) {
        final String S_ProcName = "CFAccRamMinorVersion.readDerived() ";
        CFAccDomainBasePKey key = schema.getFactoryDomainBase().newPKey();
        key.setRequiredTenantId(PKey.getRequiredTenantId());
        key.setRequiredId(PKey.getRequiredId());
        CFAccMinorVersionBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public CFAccMinorVersionBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
        final String S_ProcName = "CFAccRamDomainBase.readDerivedByTenantIdx() ";
        CFAccDomainBaseBuff buffList[] = schema.getTableDomainBase().readDerivedByTenantIdx(Authorization,
                TenantId);
        if (buffList == null) {
            return (null);
        } else {
            CFAccDomainBaseBuff buff;
            ArrayList<CFAccMinorVersionBuff> filteredList = new ArrayList<CFAccMinorVersionBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof CFAccMinorVersionBuff)) {
                    filteredList.add((CFAccMinorVersionBuff) buff);
                }
            }
            return (filteredList.toArray(new CFAccMinorVersionBuff[0]));
        }
    }

    public CFAccMinorVersionBuff[] readDerivedByMajorIdx(CFAccAuthorization Authorization, long TenantId,
            long MajorId) {
        final String S_ProcName = "CFAccRamMinorVersion.readDerivedByMajorIdx() ";
        CFAccMinorVersionByMajorIdxKey key = schema.getFactoryMinorVersion().newMajorIdxKey();
        key.setRequiredTenantId(TenantId);
        key.setRequiredMajorId(MajorId);

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

    public CFAccMinorVersionBuff readDerivedByNameIdx(CFAccAuthorization Authorization, long TenantId, long MajorId,
            String Name) {
        final String S_ProcName = "CFAccRamMinorVersion.readDerivedByNameIdx() ";
        CFAccMinorVersionByNameIdxKey key = schema.getFactoryMinorVersion().newNameIdxKey();
        key.setRequiredTenantId(TenantId);
        key.setRequiredMajorId(MajorId);
        key.setRequiredName(Name);

        CFAccMinorVersionBuff buff;
        if (dictByNameIdx.containsKey(key)) {
            buff = dictByNameIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAccMinorVersionBuff readDerivedByIdIdx(CFAccAuthorization Authorization, long TenantId, long Id) {
        final String S_ProcName = "CFAccRamDomainBase.readDerivedByIdIdx() ";
        CFAccDomainBasePKey key = schema.getFactoryDomainBase().newPKey();
        key.setRequiredTenantId(TenantId);
        key.setRequiredId(Id);

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

    public CFAccMinorVersionBuff readBuff(CFAccAuthorization Authorization, CFAccDomainBasePKey PKey) {
        final String S_ProcName = "CFAccRamMinorVersion.readBuff() ";
        CFAccMinorVersionBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("MNVR"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAccMinorVersionBuff lockBuff(CFAccAuthorization Authorization, CFAccDomainBasePKey PKey) {
        final String S_ProcName = "CFAccRamMinorVersion.readBuff() ";
        CFAccMinorVersionBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("MNVR"))) {
            buff = null;
        }
        return (buff);
    }

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

    public CFAccMinorVersionBuff readBuffByIdIdx(CFAccAuthorization Authorization, long TenantId, long Id) {
        final String S_ProcName = "CFAccRamDomainBase.readBuffByIdIdx() ";
        CFAccDomainBaseBuff buff = readDerivedByIdIdx(Authorization, TenantId, Id);
        if ((buff != null) && buff.getClassCode().equals("BDOM")) {
            return ((CFAccMinorVersionBuff) buff);
        } else {
            return (null);
        }
    }

    public CFAccMinorVersionBuff[] readBuffByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
        final String S_ProcName = "CFAccRamDomainBase.readBuffByTenantIdx() ";
        CFAccDomainBaseBuff buff;
        ArrayList<CFAccMinorVersionBuff> filteredList = new ArrayList<CFAccMinorVersionBuff>();
        CFAccDomainBaseBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("BDOM")) {
                filteredList.add((CFAccMinorVersionBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAccMinorVersionBuff[0]));
    }

    public CFAccMinorVersionBuff[] readBuffByMajorIdx(CFAccAuthorization Authorization, long TenantId,
            long MajorId) {
        final String S_ProcName = "CFAccRamMinorVersion.readBuffByMajorIdx() ";
        CFAccMinorVersionBuff buff;
        ArrayList<CFAccMinorVersionBuff> filteredList = new ArrayList<CFAccMinorVersionBuff>();
        CFAccMinorVersionBuff[] buffList = readDerivedByMajorIdx(Authorization, TenantId, MajorId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("MNVR")) {
                filteredList.add((CFAccMinorVersionBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAccMinorVersionBuff[0]));
    }

    public CFAccMinorVersionBuff readBuffByNameIdx(CFAccAuthorization Authorization, long TenantId, long MajorId,
            String Name) {
        final String S_ProcName = "CFAccRamMinorVersion.readBuffByNameIdx() ";
        CFAccMinorVersionBuff buff = readDerivedByNameIdx(Authorization, TenantId, MajorId, Name);
        if ((buff != null) && buff.getClassCode().equals("MNVR")) {
            return ((CFAccMinorVersionBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateMinorVersion(CFAccAuthorization Authorization, CFAccMinorVersionBuff Buff) {
        schema.getTableVersion().updateVersion(Authorization, Buff);
        CFAccDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey();
        pkey.setRequiredTenantId(Buff.getRequiredTenantId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAccMinorVersionBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateMinorVersion", "Existing record not found", "MinorVersion", pkey);
        }
        CFAccMinorVersionByMajorIdxKey existingKeyMajorIdx = schema.getFactoryMinorVersion().newMajorIdxKey();
        existingKeyMajorIdx.setRequiredTenantId(existing.getRequiredTenantId());
        existingKeyMajorIdx.setRequiredMajorId(existing.getRequiredMajorId());

        CFAccMinorVersionByMajorIdxKey newKeyMajorIdx = schema.getFactoryMinorVersion().newMajorIdxKey();
        newKeyMajorIdx.setRequiredTenantId(Buff.getRequiredTenantId());
        newKeyMajorIdx.setRequiredMajorId(Buff.getRequiredMajorId());

        CFAccMinorVersionByNameIdxKey existingKeyNameIdx = schema.getFactoryMinorVersion().newNameIdxKey();
        existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
        existingKeyNameIdx.setRequiredMajorId(existing.getRequiredMajorId());
        existingKeyNameIdx.setRequiredName(existing.getRequiredName());

        CFAccMinorVersionByNameIdxKey newKeyNameIdx = schema.getFactoryMinorVersion().newNameIdxKey();
        newKeyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId());
        newKeyNameIdx.setRequiredMajorId(Buff.getRequiredMajorId());
        newKeyNameIdx.setRequiredName(Buff.getRequiredName());

        // Check unique indexes

        if (!existingKeyNameIdx.equals(newKeyNameIdx)) {
            if (dictByNameIdx.containsKey(newKeyNameIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateMinorVersion", "MinorVersionNameIdx", newKeyNameIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableVersion().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(),
                        Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateMinorVersion", "Superclass", "SuperClass", "Version", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableMajorVersion().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredTenantId(), Buff.getRequiredMajorId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateMinorVersion", "Container", "MajorVersion", "MajorVersion", null);
                }
            }
        }

        // Update is valid

        SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff> subdict;

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

        subdict = dictByMajorIdx.get(existingKeyMajorIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByMajorIdx.containsKey(newKeyMajorIdx)) {
            subdict = dictByMajorIdx.get(newKeyMajorIdx);
        } else {
            subdict = new TreeMap<CFAccDomainBasePKey, CFAccMinorVersionBuff>();
            dictByMajorIdx.put(newKeyMajorIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByNameIdx.remove(existingKeyNameIdx);
        dictByNameIdx.put(newKeyNameIdx, Buff);

    }

    public void deleteMinorVersion(CFAccAuthorization Authorization, CFAccMinorVersionBuff Buff) {
        final String S_ProcName = "CFAccRamMinorVersionTable.deleteMinorVersion() ";
        CFAccDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey();
        pkey.setRequiredTenantId(Buff.getRequiredTenantId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAccMinorVersionBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteMinorVersion",
                    pkey);
        }
        CFAccMinorVersionByMajorIdxKey keyMajorIdx = schema.getFactoryMinorVersion().newMajorIdxKey();
        keyMajorIdx.setRequiredTenantId(existing.getRequiredTenantId());
        keyMajorIdx.setRequiredMajorId(existing.getRequiredMajorId());

        CFAccMinorVersionByNameIdxKey keyNameIdx = schema.getFactoryMinorVersion().newNameIdxKey();
        keyNameIdx.setRequiredTenantId(existing.getRequiredTenantId());
        keyNameIdx.setRequiredMajorId(existing.getRequiredMajorId());
        keyNameIdx.setRequiredName(existing.getRequiredName());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByMajorIdx.get(keyMajorIdx);
        subdict.remove(pkey);

        dictByNameIdx.remove(keyNameIdx);

        schema.getTableVersion().deleteVersion(Authorization, Buff);
    }

    public void deleteMinorVersionByMajorIdx(CFAccAuthorization Authorization, long argTenantId, long argMajorId) {
        CFAccMinorVersionByMajorIdxKey key = schema.getFactoryMinorVersion().newMajorIdxKey();
        key.setRequiredTenantId(argTenantId);
        key.setRequiredMajorId(argMajorId);
        deleteMinorVersionByMajorIdx(Authorization, key);
    }

    public void deleteMinorVersionByMajorIdx(CFAccAuthorization Authorization,
            CFAccMinorVersionByMajorIdxKey argKey) {
        CFAccMinorVersionBuff cur;
        LinkedList<CFAccMinorVersionBuff> matchSet = new LinkedList<CFAccMinorVersionBuff>();
        Iterator<CFAccMinorVersionBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAccMinorVersionBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteMinorVersion(Authorization, cur);
        }
    }

    public void deleteMinorVersionByNameIdx(CFAccAuthorization Authorization, long argTenantId, long argMajorId,
            String argName) {
        CFAccMinorVersionByNameIdxKey key = schema.getFactoryMinorVersion().newNameIdxKey();
        key.setRequiredTenantId(argTenantId);
        key.setRequiredMajorId(argMajorId);
        key.setRequiredName(argName);
        deleteMinorVersionByNameIdx(Authorization, key);
    }

    public void deleteMinorVersionByNameIdx(CFAccAuthorization Authorization,
            CFAccMinorVersionByNameIdxKey argKey) {
        CFAccMinorVersionBuff cur;
        LinkedList<CFAccMinorVersionBuff> matchSet = new LinkedList<CFAccMinorVersionBuff>();
        Iterator<CFAccMinorVersionBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAccMinorVersionBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteMinorVersion(Authorization, cur);
        }
    }

    public void deleteMinorVersionByIdIdx(CFAccAuthorization Authorization, long argTenantId, long argId) {
        CFAccDomainBasePKey key = schema.getFactoryDomainBase().newPKey();
        key.setRequiredTenantId(argTenantId);
        key.setRequiredId(argId);
        deleteMinorVersionByIdIdx(Authorization, key);
    }

    public void deleteMinorVersionByIdIdx(CFAccAuthorization Authorization, CFAccDomainBasePKey argKey) {
        CFAccMinorVersionBuff cur;
        LinkedList<CFAccMinorVersionBuff> matchSet = new LinkedList<CFAccMinorVersionBuff>();
        Iterator<CFAccMinorVersionBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAccMinorVersionBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteMinorVersion(Authorization, cur);
        }
    }

    public void deleteMinorVersionByTenantIdx(CFAccAuthorization Authorization, long argTenantId) {
        CFAccDomainBaseByTenantIdxKey key = schema.getFactoryDomainBase().newTenantIdxKey();
        key.setRequiredTenantId(argTenantId);
        deleteMinorVersionByTenantIdx(Authorization, key);
    }

    public void deleteMinorVersionByTenantIdx(CFAccAuthorization Authorization,
            CFAccDomainBaseByTenantIdxKey argKey) {
        CFAccMinorVersionBuff cur;
        LinkedList<CFAccMinorVersionBuff> matchSet = new LinkedList<CFAccMinorVersionBuff>();
        Iterator<CFAccMinorVersionBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAccMinorVersionBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteMinorVersion(Authorization, cur);
        }
    }

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

    public CFAccCursor openMinorVersionCursorByMajorIdx(CFAccAuthorization Authorization, long TenantId,
            long MajorId) {
        CFAccCursor cursor;
        CFAccMinorVersionByMajorIdxKey key = schema.getFactoryMinorVersion().newMajorIdxKey();
        key.setRequiredTenantId(TenantId);
        key.setRequiredMajorId(MajorId);

        if (dictByMajorIdx.containsKey(key)) {
            SortedMap<CFAccDomainBasePKey, CFAccMinorVersionBuff> subdictMajorIdx = dictByMajorIdx.get(key);
            cursor = new CFAccRamMinorVersionCursor(Authorization, schema, subdictMajorIdx.values());
        } else {
            cursor = new CFAccRamMinorVersionCursor(Authorization, schema, new ArrayList<CFAccMinorVersionBuff>());
        }
        return (cursor);
    }

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

    public CFAccMinorVersionBuff nextMinorVersionCursor(CFAccCursor Cursor) {
        CFAccRamMinorVersionCursor cursor = (CFAccRamMinorVersionCursor) Cursor;
        CFAccMinorVersionBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public CFAccMinorVersionBuff firstMinorVersionCursor(CFAccCursor Cursor) {
        int targetRowIdx = 1;
        CFAccMinorVersionBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextMinorVersionCursor(Cursor);
        }
        return (rec);
    }

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

    public CFAccMinorVersionBuff nthMinorVersionCursor(CFAccCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFAccMinorVersionBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextMinorVersionCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}