net.sourceforge.msscodefactory.v1_10.MSSBamRam.MSSBamRamSecGroupIncludeTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.v1_10.MSSBamRam.MSSBamRamSecGroupIncludeTable.java

Source

// Description: Java6 in-memory RAM DbIO implementation for SecGroupInclude.

/*
 *   MSS Code Factory 1.10
 *
 *   Copyright (c) 2012 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/>.
 *   
 * ***********************************************************************
 *
 *   Code manufactured
 *   by MSS Code Factory version 1.9.3294
 *
 *   $Revision: 26 $
 */

package net.sourceforge.msscodefactory.v1_10.MSSBamRam;

import java.sql.*;
import java.util.*;
import net.sourceforge.msscodefactory.cflib.v1_9.CFLib.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.v1_10.MSSBam.*;
import net.sourceforge.msscodefactory.v1_10.MSSBamBL.*;
import net.sourceforge.msscodefactory.v1_10.MSSBamBLRam.*;

/*
 *   MSSBamRamSecGroupIncludeTable in-memory RAM DbIO implementation
 *   for SecGroupInclude.
 */
public class MSSBamRamSecGroupIncludeTable implements IMSSBamSecGroupIncludeTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> dictByPKey = new HashMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>();
    private SortedMap<MSSBamSecGroupIncludeByGroupIdxKey, SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>> dictByGroupIdx = new TreeMap<MSSBamSecGroupIncludeByGroupIdxKey, SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>>();
    private SortedMap<MSSBamSecGroupIncludeByIncludeIdxKey, SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>> dictByIncludeIdx = new TreeMap<MSSBamSecGroupIncludeByIncludeIdxKey, SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>>();
    private SortedMap<MSSBamSecGroupIncludeByUIncludeIdxKey, MSSBamSecGroupIncludeBuff> dictByUIncludeIdx = new TreeMap<MSSBamSecGroupIncludeByUIncludeIdxKey, MSSBamSecGroupIncludeBuff>();

    public MSSBamRamSecGroupIncludeTable(MSSBamBLRamSchema argSchema) {
        schema = argSchema;
    }

    public void createSecGroupInclude(MSSBamAuthorization Authorization, MSSBamSecGroupIncludeBuff Buff) {
        MSSBamSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey();

        pkey.setRequiredSecGroupIncludeId(schema.nextSecGroupIncludeIdGen());
        Buff.setRequiredSecGroupIncludeId(pkey.getRequiredSecGroupIncludeId());

        MSSBamSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
        keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        MSSBamSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey();
        keyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

        MSSBamSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude()
                .newUIncludeIdxKey();
        keyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        keyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

        // Validate unique indexes

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

        if (dictByUIncludeIdx.containsKey(keyUIncludeIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createSecGroupInclude", "SecGroupIncludeUIncludeIdx", keyUIncludeIdx);
        }

        // Validate foreign keys

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createSecGroupInclude", "Container", "SecGroupIncludeGroup", "SecGroup", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredIncludeGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createSecGroupInclude", "Lookup", "SecGroupIncludeSubGroup", "SecGroup", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdictGroupIdx;
        if (dictByGroupIdx.containsKey(keyGroupIdx)) {
            subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx);
        } else {
            subdictGroupIdx = new TreeMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>();
            dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx);
        }
        subdictGroupIdx.put(pkey, Buff);

        SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdictIncludeIdx;
        if (dictByIncludeIdx.containsKey(keyIncludeIdx)) {
            subdictIncludeIdx = dictByIncludeIdx.get(keyIncludeIdx);
        } else {
            subdictIncludeIdx = new TreeMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>();
            dictByIncludeIdx.put(keyIncludeIdx, subdictIncludeIdx);
        }
        subdictIncludeIdx.put(pkey, Buff);

        dictByUIncludeIdx.put(keyUIncludeIdx, Buff);

    }

    public MSSBamSecGroupIncludeBuff readDerived(MSSBamAuthorization Authorization,
            MSSBamSecGroupIncludePKey PKey) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readDerived() ";
        MSSBamSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey();
        key.setRequiredSecGroupIncludeId(PKey.getRequiredSecGroupIncludeId());
        MSSBamSecGroupIncludeBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamSecGroupIncludeBuff[] readDerivedByGroupIdx(MSSBamAuthorization Authorization, int SecGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readDerivedByGroupIdx() ";
        MSSBamSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey();
        key.setRequiredSecGroupId(SecGroupId);

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

    public MSSBamSecGroupIncludeBuff[] readDerivedByIncludeIdx(MSSBamAuthorization Authorization,
            int IncludeGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readDerivedByIncludeIdx() ";
        MSSBamSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey();
        key.setRequiredIncludeGroupId(IncludeGroupId);

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

    public MSSBamSecGroupIncludeBuff readDerivedByUIncludeIdx(MSSBamAuthorization Authorization, int SecGroupId,
            int IncludeGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readDerivedByUIncludeIdx() ";
        MSSBamSecGroupIncludeByUIncludeIdxKey key = schema.getFactorySecGroupInclude().newUIncludeIdxKey();
        key.setRequiredSecGroupId(SecGroupId);
        key.setRequiredIncludeGroupId(IncludeGroupId);

        MSSBamSecGroupIncludeBuff buff;
        if (dictByUIncludeIdx.containsKey(key)) {
            buff = dictByUIncludeIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamSecGroupIncludeBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long SecGroupIncludeId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readDerivedByIdIdx() ";
        MSSBamSecGroupIncludePKey key = schema.getFactorySecGroupInclude().newPKey();
        key.setRequiredSecGroupIncludeId(SecGroupIncludeId);

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

    public MSSBamSecGroupIncludeBuff readBuff(MSSBamAuthorization Authorization, MSSBamSecGroupIncludePKey PKey) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readBuff() ";
        MSSBamSecGroupIncludeBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SGNC"))) {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamSecGroupIncludeBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long SecGroupIncludeId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readBuffByIdIdx() ";
        MSSBamSecGroupIncludeBuff buff = readDerivedByIdIdx(Authorization, SecGroupIncludeId);
        if ((buff != null) && buff.getClassCode().equals("SGNC")) {
            return ((MSSBamSecGroupIncludeBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamSecGroupIncludeBuff[] readBuffByGroupIdx(MSSBamAuthorization Authorization, int SecGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readBuffByGroupIdx() ";
        MSSBamSecGroupIncludeBuff buff;
        ArrayList<MSSBamSecGroupIncludeBuff> filteredList = new ArrayList<MSSBamSecGroupIncludeBuff>();
        MSSBamSecGroupIncludeBuff[] buffList = readDerivedByGroupIdx(Authorization, SecGroupId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGNC")) {
                filteredList.add((MSSBamSecGroupIncludeBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamSecGroupIncludeBuff[0]));
    }

    public MSSBamSecGroupIncludeBuff[] readBuffByIncludeIdx(MSSBamAuthorization Authorization, int IncludeGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readBuffByIncludeIdx() ";
        MSSBamSecGroupIncludeBuff buff;
        ArrayList<MSSBamSecGroupIncludeBuff> filteredList = new ArrayList<MSSBamSecGroupIncludeBuff>();
        MSSBamSecGroupIncludeBuff[] buffList = readDerivedByIncludeIdx(Authorization, IncludeGroupId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGNC")) {
                filteredList.add((MSSBamSecGroupIncludeBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamSecGroupIncludeBuff[0]));
    }

    public MSSBamSecGroupIncludeBuff readBuffByUIncludeIdx(MSSBamAuthorization Authorization, int SecGroupId,
            int IncludeGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupInclude.readBuffByUIncludeIdx() ";
        MSSBamSecGroupIncludeBuff buff = readDerivedByUIncludeIdx(Authorization, SecGroupId, IncludeGroupId);
        if ((buff != null) && buff.getClassCode().equals("SGNC")) {
            return ((MSSBamSecGroupIncludeBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateSecGroupInclude(MSSBamAuthorization Authorization, MSSBamSecGroupIncludeBuff Buff) {
        MSSBamSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey();
        pkey.setRequiredSecGroupIncludeId(Buff.getRequiredSecGroupIncludeId());
        MSSBamSecGroupIncludeBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateSecGroupInclude", "Existing record not found", "SecGroupInclude", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "updateSecGroupInclude", pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        MSSBamSecGroupIncludeByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupInclude()
                .newGroupIdxKey();
        existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        MSSBamSecGroupIncludeByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
        newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        MSSBamSecGroupIncludeByIncludeIdxKey existingKeyIncludeIdx = schema.getFactorySecGroupInclude()
                .newIncludeIdxKey();
        existingKeyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

        MSSBamSecGroupIncludeByIncludeIdxKey newKeyIncludeIdx = schema.getFactorySecGroupInclude()
                .newIncludeIdxKey();
        newKeyIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

        MSSBamSecGroupIncludeByUIncludeIdxKey existingKeyUIncludeIdx = schema.getFactorySecGroupInclude()
                .newUIncludeIdxKey();
        existingKeyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        existingKeyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

        MSSBamSecGroupIncludeByUIncludeIdxKey newKeyUIncludeIdx = schema.getFactorySecGroupInclude()
                .newUIncludeIdxKey();
        newKeyUIncludeIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        newKeyUIncludeIdx.setRequiredIncludeGroupId(Buff.getRequiredIncludeGroupId());

        // Check unique indexes

        if (!existingKeyUIncludeIdx.equals(newKeyUIncludeIdx)) {
            if (dictByUIncludeIdx.containsKey(newKeyUIncludeIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateSecGroupInclude", "SecGroupIncludeUIncludeIdx", newKeyUIncludeIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateSecGroupInclude", "Container", "SecGroupIncludeGroup", "SecGroup", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredIncludeGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateSecGroupInclude", "Lookup", "SecGroupIncludeSubGroup", "SecGroup", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdict;

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

        subdict = dictByGroupIdx.get(existingKeyGroupIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
            subdict = dictByGroupIdx.get(newKeyGroupIdx);
        } else {
            subdict = new TreeMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>();
            dictByGroupIdx.put(newKeyGroupIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByIncludeIdx.get(existingKeyIncludeIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByIncludeIdx.containsKey(newKeyIncludeIdx)) {
            subdict = dictByIncludeIdx.get(newKeyIncludeIdx);
        } else {
            subdict = new TreeMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff>();
            dictByIncludeIdx.put(newKeyIncludeIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByUIncludeIdx.remove(existingKeyUIncludeIdx);
        dictByUIncludeIdx.put(newKeyUIncludeIdx, Buff);

    }

    public void deleteSecGroupInclude(MSSBamAuthorization Authorization, MSSBamSecGroupIncludeBuff Buff) {
        final String S_ProcName = "MSSBamRamSecGroupIncludeTable.deleteSecGroupInclude() ";
        MSSBamSecGroupIncludePKey pkey = schema.getFactorySecGroupInclude().newPKey();

        pkey.setRequiredSecGroupIncludeId(schema.nextSecGroupIncludeIdGen());
        MSSBamSecGroupIncludeBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "deleteSecGroupInclude", "Existing record not found", "SecGroupInclude", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteSecGroupInclude", pkey);
        }
        MSSBamSecGroupIncludeByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupInclude().newGroupIdxKey();
        keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        MSSBamSecGroupIncludeByIncludeIdxKey keyIncludeIdx = schema.getFactorySecGroupInclude().newIncludeIdxKey();
        keyIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

        MSSBamSecGroupIncludeByUIncludeIdxKey keyUIncludeIdx = schema.getFactorySecGroupInclude()
                .newUIncludeIdxKey();
        keyUIncludeIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        keyUIncludeIdx.setRequiredIncludeGroupId(existing.getRequiredIncludeGroupId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByGroupIdx.get(keyGroupIdx);
        subdict.remove(pkey);

        subdict = dictByIncludeIdx.get(keyIncludeIdx);
        subdict.remove(pkey);

        dictByUIncludeIdx.remove(keyUIncludeIdx);

    }

    public MSSBamCursor openSecGroupIncludeCursorAll(MSSBamAuthorization Authorization) {
        MSSBamCursor cursor = new MSSBamRamSecGroupIncludeCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public MSSBamCursor openSecGroupIncludeCursorByGroupIdx(MSSBamAuthorization Authorization, int SecGroupId) {
        MSSBamCursor cursor;
        MSSBamSecGroupIncludeByGroupIdxKey key = schema.getFactorySecGroupInclude().newGroupIdxKey();
        key.setRequiredSecGroupId(SecGroupId);

        if (dictByGroupIdx.containsKey(key)) {
            SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdictGroupIdx = dictByGroupIdx
                    .get(key);
            cursor = new MSSBamRamSecGroupIncludeCursor(Authorization, schema, subdictGroupIdx.values());
        } else {
            cursor = new MSSBamRamSecGroupIncludeCursor(Authorization, schema,
                    new ArrayList<MSSBamSecGroupIncludeBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openSecGroupIncludeCursorByIncludeIdx(MSSBamAuthorization Authorization,
            int IncludeGroupId) {
        MSSBamCursor cursor;
        MSSBamSecGroupIncludeByIncludeIdxKey key = schema.getFactorySecGroupInclude().newIncludeIdxKey();
        key.setRequiredIncludeGroupId(IncludeGroupId);

        if (dictByIncludeIdx.containsKey(key)) {
            SortedMap<MSSBamSecGroupIncludePKey, MSSBamSecGroupIncludeBuff> subdictIncludeIdx = dictByIncludeIdx
                    .get(key);
            cursor = new MSSBamRamSecGroupIncludeCursor(Authorization, schema, subdictIncludeIdx.values());
        } else {
            cursor = new MSSBamRamSecGroupIncludeCursor(Authorization, schema,
                    new ArrayList<MSSBamSecGroupIncludeBuff>());
        }
        return (cursor);
    }

    public void closeSecGroupIncludeCursor(MSSBamCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public MSSBamSecGroupIncludeBuff nextSecGroupIncludeCursor(MSSBamCursor Cursor) {
        MSSBamRamSecGroupIncludeCursor cursor = (MSSBamRamSecGroupIncludeCursor) Cursor;
        MSSBamSecGroupIncludeBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public MSSBamSecGroupIncludeBuff prevSecGroupIncludeCursor(MSSBamCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        MSSBamSecGroupIncludeBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupIncludeCursor(Cursor);
        }
        return (rec);
    }

    public MSSBamSecGroupIncludeBuff firstSecGroupIncludeCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamSecGroupIncludeBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupIncludeCursor(Cursor);
        }
        return (rec);
    }

    public MSSBamSecGroupIncludeBuff lastSecGroupIncludeCursor(MSSBamCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(),
                "lastSecGroupIncludeCursor");
    }

    public MSSBamSecGroupIncludeBuff nthSecGroupIncludeCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamSecGroupIncludeBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupIncludeCursor(Cursor);
        }
        return (rec);
    }
}