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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamSecGroupMemberTable in-memory RAM DbIO implementation
 *   for SecGroupMember.
 */
public class MSSBamRamSecGroupMemberTable implements IMSSBamSecGroupMemberTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff> dictByPKey = new HashMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>();
    private SortedMap<MSSBamSecGroupMemberByGroupIdxKey, SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>> dictByGroupIdx = new TreeMap<MSSBamSecGroupMemberByGroupIdxKey, SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>>();
    private SortedMap<MSSBamSecGroupMemberByUserIdxKey, SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>> dictByUserIdx = new TreeMap<MSSBamSecGroupMemberByUserIdxKey, SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>>();
    private SortedMap<MSSBamSecGroupMemberByUUserIdxKey, MSSBamSecGroupMemberBuff> dictByUUserIdx = new TreeMap<MSSBamSecGroupMemberByUUserIdxKey, MSSBamSecGroupMemberBuff>();

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

    public void createSecGroupMember(MSSBamAuthorization Authorization, MSSBamSecGroupMemberBuff Buff) {
        MSSBamSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();

        pkey.setRequiredSecGroupMemberId(schema.nextSecGroupMemberIdGen());
        Buff.setRequiredSecGroupMemberId(pkey.getRequiredSecGroupMemberId());

        MSSBamSecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        MSSBamSecGroupMemberByUserIdxKey keyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

        MSSBamSecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        keyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

        // Validate unique indexes

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

        if (dictByUUserIdx.containsKey(keyUUserIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createSecGroupMember", "SecGroupMemberUUserIdx", keyUUserIdx);
        }

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecUser().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecUserId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createSecGroupMember", "Lookup", "SecGroupMemberUser", "SecUser", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

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

        SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff> subdictUserIdx;
        if (dictByUserIdx.containsKey(keyUserIdx)) {
            subdictUserIdx = dictByUserIdx.get(keyUserIdx);
        } else {
            subdictUserIdx = new TreeMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>();
            dictByUserIdx.put(keyUserIdx, subdictUserIdx);
        }
        subdictUserIdx.put(pkey, Buff);

        dictByUUserIdx.put(keyUUserIdx, Buff);

    }

    public MSSBamSecGroupMemberBuff readDerived(MSSBamAuthorization Authorization, MSSBamSecGroupMemberPKey PKey) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readDerived() ";
        MSSBamSecGroupMemberPKey key = schema.getFactorySecGroupMember().newPKey();
        key.setRequiredSecGroupMemberId(PKey.getRequiredSecGroupMemberId());
        MSSBamSecGroupMemberBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamSecGroupMemberBuff[] readDerivedByGroupIdx(MSSBamAuthorization Authorization, int SecGroupId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readDerivedByGroupIdx() ";
        MSSBamSecGroupMemberByGroupIdxKey key = schema.getFactorySecGroupMember().newGroupIdxKey();
        key.setRequiredSecGroupId(SecGroupId);

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

    public MSSBamSecGroupMemberBuff[] readDerivedByUserIdx(MSSBamAuthorization Authorization, long SecUserId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readDerivedByUserIdx() ";
        MSSBamSecGroupMemberByUserIdxKey key = schema.getFactorySecGroupMember().newUserIdxKey();
        key.setRequiredSecUserId(SecUserId);

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

    public MSSBamSecGroupMemberBuff readDerivedByUUserIdx(MSSBamAuthorization Authorization, int SecGroupId,
            long SecUserId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readDerivedByUUserIdx() ";
        MSSBamSecGroupMemberByUUserIdxKey key = schema.getFactorySecGroupMember().newUUserIdxKey();
        key.setRequiredSecGroupId(SecGroupId);
        key.setRequiredSecUserId(SecUserId);

        MSSBamSecGroupMemberBuff buff;
        if (dictByUUserIdx.containsKey(key)) {
            buff = dictByUUserIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamSecGroupMemberBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long SecGroupMemberId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readDerivedByIdIdx() ";
        MSSBamSecGroupMemberPKey key = schema.getFactorySecGroupMember().newPKey();
        key.setRequiredSecGroupMemberId(SecGroupMemberId);

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

    public MSSBamSecGroupMemberBuff readBuff(MSSBamAuthorization Authorization, MSSBamSecGroupMemberPKey PKey) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readBuff() ";
        MSSBamSecGroupMemberBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SGMB"))) {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamSecGroupMemberBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long SecGroupMemberId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readBuffByIdIdx() ";
        MSSBamSecGroupMemberBuff buff = readDerivedByIdIdx(Authorization, SecGroupMemberId);
        if ((buff != null) && buff.getClassCode().equals("SGMB")) {
            return ((MSSBamSecGroupMemberBuff) buff);
        } else {
            return (null);
        }
    }

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

    public MSSBamSecGroupMemberBuff[] readBuffByUserIdx(MSSBamAuthorization Authorization, long SecUserId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readBuffByUserIdx() ";
        MSSBamSecGroupMemberBuff buff;
        ArrayList<MSSBamSecGroupMemberBuff> filteredList = new ArrayList<MSSBamSecGroupMemberBuff>();
        MSSBamSecGroupMemberBuff[] buffList = readDerivedByUserIdx(Authorization, SecUserId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGMB")) {
                filteredList.add((MSSBamSecGroupMemberBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamSecGroupMemberBuff[0]));
    }

    public MSSBamSecGroupMemberBuff readBuffByUUserIdx(MSSBamAuthorization Authorization, int SecGroupId,
            long SecUserId) {
        final String S_ProcName = "MSSBamRamSecGroupMember.readBuffByUUserIdx() ";
        MSSBamSecGroupMemberBuff buff = readDerivedByUUserIdx(Authorization, SecGroupId, SecUserId);
        if ((buff != null) && buff.getClassCode().equals("SGMB")) {
            return ((MSSBamSecGroupMemberBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateSecGroupMember(MSSBamAuthorization Authorization, MSSBamSecGroupMemberBuff Buff) {
        MSSBamSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();
        pkey.setRequiredSecGroupMemberId(Buff.getRequiredSecGroupMemberId());
        MSSBamSecGroupMemberBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateSecGroupMember", "Existing record not found", "SecGroupMember", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "updateSecGroupMember", pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        MSSBamSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
        existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        MSSBamSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
        newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        MSSBamSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
        existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

        MSSBamSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
        newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

        MSSBamSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
        existingKeyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

        MSSBamSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
        newKeyUUserIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId());

        // Check unique indexes

        if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) {
            if (dictByUUserIdx.containsKey(newKeyUUserIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateSecGroupMember", "SecGroupMemberUUserIdx", newKeyUUserIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecUser().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredSecUserId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateSecGroupMember", "Lookup", "SecGroupMemberUser", "SecUser", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff> 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<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>();
            dictByGroupIdx.put(newKeyGroupIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByUserIdx.get(existingKeyUserIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByUserIdx.containsKey(newKeyUserIdx)) {
            subdict = dictByUserIdx.get(newKeyUserIdx);
        } else {
            subdict = new TreeMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff>();
            dictByUserIdx.put(newKeyUserIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByUUserIdx.remove(existingKeyUUserIdx);
        dictByUUserIdx.put(newKeyUUserIdx, Buff);

    }

    public void deleteSecGroupMember(MSSBamAuthorization Authorization, MSSBamSecGroupMemberBuff Buff) {
        final String S_ProcName = "MSSBamRamSecGroupMemberTable.deleteSecGroupMember() ";
        MSSBamSecGroupMemberPKey pkey = schema.getFactorySecGroupMember().newPKey();

        pkey.setRequiredSecGroupMemberId(schema.nextSecGroupMemberIdGen());
        MSSBamSecGroupMemberBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "deleteSecGroupMember", "Existing record not found", "SecGroupMember", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteSecGroupMember", pkey);
        }
        MSSBamSecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupMember().newGroupIdxKey();
        keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        MSSBamSecGroupMemberByUserIdxKey keyUserIdx = schema.getFactorySecGroupMember().newUserIdxKey();
        keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

        MSSBamSecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactorySecGroupMember().newUUserIdxKey();
        keyUUserIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        keyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff> subdict;

        dictByPKey.remove(pkey);

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

        subdict = dictByUserIdx.get(keyUserIdx);
        subdict.remove(pkey);

        dictByUUserIdx.remove(keyUUserIdx);

    }

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

    public MSSBamCursor openSecGroupMemberCursorByGroupIdx(MSSBamAuthorization Authorization, int SecGroupId) {
        MSSBamCursor cursor;
        MSSBamSecGroupMemberByGroupIdxKey key = schema.getFactorySecGroupMember().newGroupIdxKey();
        key.setRequiredSecGroupId(SecGroupId);

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

    public MSSBamCursor openSecGroupMemberCursorByUserIdx(MSSBamAuthorization Authorization, long SecUserId) {
        MSSBamCursor cursor;
        MSSBamSecGroupMemberByUserIdxKey key = schema.getFactorySecGroupMember().newUserIdxKey();
        key.setRequiredSecUserId(SecUserId);

        if (dictByUserIdx.containsKey(key)) {
            SortedMap<MSSBamSecGroupMemberPKey, MSSBamSecGroupMemberBuff> subdictUserIdx = dictByUserIdx.get(key);
            cursor = new MSSBamRamSecGroupMemberCursor(Authorization, schema, subdictUserIdx.values());
        } else {
            cursor = new MSSBamRamSecGroupMemberCursor(Authorization, schema,
                    new ArrayList<MSSBamSecGroupMemberBuff>());
        }
        return (cursor);
    }

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

    public MSSBamSecGroupMemberBuff nextSecGroupMemberCursor(MSSBamCursor Cursor) {
        MSSBamRamSecGroupMemberCursor cursor = (MSSBamRamSecGroupMemberCursor) Cursor;
        MSSBamSecGroupMemberBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamSecGroupMemberBuff firstSecGroupMemberCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamSecGroupMemberBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupMemberCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamSecGroupMemberBuff nthSecGroupMemberCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamSecGroupMemberBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupMemberCursor(Cursor);
        }
        return (rec);
    }
}