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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamRelationColTable in-memory RAM DbIO implementation
 *   for RelationCol.
 */
public class MSSBamRamRelationColTable implements IMSSBamRelationColTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamRelationColBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
    private SortedMap<MSSBamRelationColByRelationIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByRelationIdx = new TreeMap<MSSBamRelationColByRelationIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByFromColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByFromColIdx = new TreeMap<MSSBamRelationColByFromColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByToColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByToColIdx = new TreeMap<MSSBamRelationColByToColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByPrevIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByPrevIdx = new TreeMap<MSSBamRelationColByPrevIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByNextIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByNextIdx = new TreeMap<MSSBamRelationColByNextIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByRelPrevIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByRelPrevIdx = new TreeMap<MSSBamRelationColByRelPrevIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();
    private SortedMap<MSSBamRelationColByRelNextIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>> dictByRelNextIdx = new TreeMap<MSSBamRelationColByRelNextIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>>();

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

    public void createRelationCol(MSSBamAuthorization Authorization, MSSBamRelationColBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamRelationColByRelationIdxKey keyRelationIdx = schema.getFactoryRelationCol().newRelationIdxKey();
        keyRelationIdx.setRequiredRelationId(Buff.getRequiredRelationId());

        MSSBamRelationColByFromColIdxKey keyFromColIdx = schema.getFactoryRelationCol().newFromColIdxKey();
        keyFromColIdx.setRequiredFromColId(Buff.getRequiredFromColId());

        MSSBamRelationColByToColIdxKey keyToColIdx = schema.getFactoryRelationCol().newToColIdxKey();
        keyToColIdx.setRequiredToColId(Buff.getRequiredToColId());

        MSSBamRelationColByPrevIdxKey keyPrevIdx = schema.getFactoryRelationCol().newPrevIdxKey();
        keyPrevIdx.setOptionalPrevId(Buff.getOptionalPrevId());

        MSSBamRelationColByNextIdxKey keyNextIdx = schema.getFactoryRelationCol().newNextIdxKey();
        keyNextIdx.setOptionalNextId(Buff.getOptionalNextId());

        MSSBamRelationColByRelPrevIdxKey keyRelPrevIdx = schema.getFactoryRelationCol().newRelPrevIdxKey();
        keyRelPrevIdx.setRequiredRelationId(Buff.getRequiredRelationId());
        keyRelPrevIdx.setOptionalPrevId(Buff.getOptionalPrevId());

        MSSBamRelationColByRelNextIdxKey keyRelNextIdx = schema.getFactoryRelationCol().newRelNextIdxKey();
        keyRelNextIdx.setRequiredRelationId(Buff.getRequiredRelationId());
        keyRelNextIdx.setOptionalNextId(Buff.getOptionalNextId());

        // Validate unique indexes

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

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableRelation().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredRelationId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createRelationCol", "Container", "Relation", "Relation", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredFromColId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createRelationCol", "Lookup", "LookupFromCol", "Value", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredToColId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createRelationCol", "Lookup", "LookupToCol", "Value", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelationIdx;
        if (dictByRelationIdx.containsKey(keyRelationIdx)) {
            subdictRelationIdx = dictByRelationIdx.get(keyRelationIdx);
        } else {
            subdictRelationIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelationIdx.put(keyRelationIdx, subdictRelationIdx);
        }
        subdictRelationIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictFromColIdx;
        if (dictByFromColIdx.containsKey(keyFromColIdx)) {
            subdictFromColIdx = dictByFromColIdx.get(keyFromColIdx);
        } else {
            subdictFromColIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByFromColIdx.put(keyFromColIdx, subdictFromColIdx);
        }
        subdictFromColIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictToColIdx;
        if (dictByToColIdx.containsKey(keyToColIdx)) {
            subdictToColIdx = dictByToColIdx.get(keyToColIdx);
        } else {
            subdictToColIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByToColIdx.put(keyToColIdx, subdictToColIdx);
        }
        subdictToColIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictPrevIdx;
        if (dictByPrevIdx.containsKey(keyPrevIdx)) {
            subdictPrevIdx = dictByPrevIdx.get(keyPrevIdx);
        } else {
            subdictPrevIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByPrevIdx.put(keyPrevIdx, subdictPrevIdx);
        }
        subdictPrevIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictNextIdx;
        if (dictByNextIdx.containsKey(keyNextIdx)) {
            subdictNextIdx = dictByNextIdx.get(keyNextIdx);
        } else {
            subdictNextIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByNextIdx.put(keyNextIdx, subdictNextIdx);
        }
        subdictNextIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelPrevIdx;
        if (dictByRelPrevIdx.containsKey(keyRelPrevIdx)) {
            subdictRelPrevIdx = dictByRelPrevIdx.get(keyRelPrevIdx);
        } else {
            subdictRelPrevIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelPrevIdx.put(keyRelPrevIdx, subdictRelPrevIdx);
        }
        subdictRelPrevIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelNextIdx;
        if (dictByRelNextIdx.containsKey(keyRelNextIdx)) {
            subdictRelNextIdx = dictByRelNextIdx.get(keyRelNextIdx);
        } else {
            subdictRelNextIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelNextIdx.put(keyRelNextIdx, subdictRelNextIdx);
        }
        subdictRelNextIdx.put(pkey, Buff);

    }

    public MSSBamRelationColBuff readDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerived() ";
        MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey();
        key.setRequiredId(PKey.getRequiredId());
        MSSBamRelationColBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

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

    public MSSBamRelationColBuff[] readDerivedByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByScopeIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByScopeIdx(Authorization, ScopeId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamRelationColBuff)) {
                    filteredList.add((MSSBamRelationColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamRelationColBuff[0]));
        }
    }

    public MSSBamRelationColBuff[] readDerivedByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByAuthorIdx() ";
        MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByAuthorIdx(Authorization, AuthorId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamAnyObjBuff buff;
            ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamRelationColBuff)) {
                    filteredList.add((MSSBamRelationColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamRelationColBuff[0]));
        }
    }

    public MSSBamRelationColBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId,
            String Name) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByUNameIdx() ";
        MSSBamAnyObjBuff buff = schema.getTableAnyObj().readDerivedByUNameIdx(Authorization, ScopeId, Name);
        if (buff == null) {
            return (null);
        } else if (buff instanceof MSSBamRelationColBuff) {
            return ((MSSBamRelationColBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamRelationColBuff[] readDerivedByRelationIdx(MSSBamAuthorization Authorization, long RelationId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByRelationIdx() ";
        MSSBamRelationColByRelationIdxKey key = schema.getFactoryRelationCol().newRelationIdxKey();
        key.setRequiredRelationId(RelationId);

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

    public MSSBamRelationColBuff[] readDerivedByFromColIdx(MSSBamAuthorization Authorization, long FromColId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByFromColIdx() ";
        MSSBamRelationColByFromColIdxKey key = schema.getFactoryRelationCol().newFromColIdxKey();
        key.setRequiredFromColId(FromColId);

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

    public MSSBamRelationColBuff[] readDerivedByToColIdx(MSSBamAuthorization Authorization, long ToColId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByToColIdx() ";
        MSSBamRelationColByToColIdxKey key = schema.getFactoryRelationCol().newToColIdxKey();
        key.setRequiredToColId(ToColId);

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

    public MSSBamRelationColBuff[] readDerivedByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByPrevIdx() ";
        MSSBamRelationColByPrevIdxKey key = schema.getFactoryRelationCol().newPrevIdxKey();
        key.setOptionalPrevId(PrevId);

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

    public MSSBamRelationColBuff[] readDerivedByNextIdx(MSSBamAuthorization Authorization, Long NextId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByNextIdx() ";
        MSSBamRelationColByNextIdxKey key = schema.getFactoryRelationCol().newNextIdxKey();
        key.setOptionalNextId(NextId);

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

    public MSSBamRelationColBuff[] readDerivedByRelPrevIdx(MSSBamAuthorization Authorization, long RelationId,
            Long PrevId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByRelPrevIdx() ";
        MSSBamRelationColByRelPrevIdxKey key = schema.getFactoryRelationCol().newRelPrevIdxKey();
        key.setRequiredRelationId(RelationId);
        key.setOptionalPrevId(PrevId);

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

    public MSSBamRelationColBuff[] readDerivedByRelNextIdx(MSSBamAuthorization Authorization, long RelationId,
            Long NextId) {
        final String S_ProcName = "MSSBamRamRelationCol.readDerivedByRelNextIdx() ";
        MSSBamRelationColByRelNextIdxKey key = schema.getFactoryRelationCol().newRelNextIdxKey();
        key.setRequiredRelationId(RelationId);
        key.setOptionalNextId(NextId);

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

    public MSSBamRelationColBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long Id) {
        final String S_ProcName = "MSSBamRamAnyObj.readDerivedByIdIdx() ";
        MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey();
        key.setRequiredId(Id);

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

    public MSSBamRelationColBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuff() ";
        MSSBamRelationColBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("RLC"))) {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamRelationColBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long Id) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByIdIdx() ";
        MSSBamAnyObjBuff buff = readDerivedByIdIdx(Authorization, Id);
        if ((buff != null) && buff.getClassCode().equals("ANYO")) {
            return ((MSSBamRelationColBuff) buff);
        } else {
            return (null);
        }
    }

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

    public MSSBamRelationColBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByScopeIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByScopeIdx(Authorization, ScopeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByAuthorIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamAnyObjBuff[] buffList = readDerivedByAuthorIdx(Authorization, AuthorId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("ANYO")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByUNameIdx() ";
        MSSBamAnyObjBuff buff = readDerivedByUNameIdx(Authorization, ScopeId, Name);
        if ((buff != null) && buff.getClassCode().equals("ANYO")) {
            return ((MSSBamRelationColBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamRelationColBuff[] readBuffByRelationIdx(MSSBamAuthorization Authorization, long RelationId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByRelationIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByRelationIdx(Authorization, RelationId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByFromColIdx(MSSBamAuthorization Authorization, long FromColId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByFromColIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByFromColIdx(Authorization, FromColId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByToColIdx(MSSBamAuthorization Authorization, long ToColId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByToColIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByToColIdx(Authorization, ToColId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByPrevIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByPrevIdx(Authorization, PrevId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByNextIdx(MSSBamAuthorization Authorization, Long NextId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByNextIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByNextIdx(Authorization, NextId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByRelPrevIdx(MSSBamAuthorization Authorization, long RelationId,
            Long PrevId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByRelPrevIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByRelPrevIdx(Authorization, RelationId, PrevId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public MSSBamRelationColBuff[] readBuffByRelNextIdx(MSSBamAuthorization Authorization, long RelationId,
            Long NextId) {
        final String S_ProcName = "MSSBamRamRelationCol.readBuffByRelNextIdx() ";
        MSSBamRelationColBuff buff;
        ArrayList<MSSBamRelationColBuff> filteredList = new ArrayList<MSSBamRelationColBuff>();
        MSSBamRelationColBuff[] buffList = readDerivedByRelNextIdx(Authorization, RelationId, NextId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("RLC")) {
                filteredList.add((MSSBamRelationColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamRelationColBuff[0]));
    }

    public void updateRelationCol(MSSBamAuthorization Authorization, MSSBamRelationColBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamRelationColBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateRelationCol",
                    "Existing record not found", "RelationCol", pkey);
        }
        MSSBamRelationColByRelationIdxKey existingKeyRelationIdx = schema.getFactoryRelationCol()
                .newRelationIdxKey();
        existingKeyRelationIdx.setRequiredRelationId(existing.getRequiredRelationId());

        MSSBamRelationColByRelationIdxKey newKeyRelationIdx = schema.getFactoryRelationCol().newRelationIdxKey();
        newKeyRelationIdx.setRequiredRelationId(Buff.getRequiredRelationId());

        MSSBamRelationColByFromColIdxKey existingKeyFromColIdx = schema.getFactoryRelationCol().newFromColIdxKey();
        existingKeyFromColIdx.setRequiredFromColId(existing.getRequiredFromColId());

        MSSBamRelationColByFromColIdxKey newKeyFromColIdx = schema.getFactoryRelationCol().newFromColIdxKey();
        newKeyFromColIdx.setRequiredFromColId(Buff.getRequiredFromColId());

        MSSBamRelationColByToColIdxKey existingKeyToColIdx = schema.getFactoryRelationCol().newToColIdxKey();
        existingKeyToColIdx.setRequiredToColId(existing.getRequiredToColId());

        MSSBamRelationColByToColIdxKey newKeyToColIdx = schema.getFactoryRelationCol().newToColIdxKey();
        newKeyToColIdx.setRequiredToColId(Buff.getRequiredToColId());

        MSSBamRelationColByPrevIdxKey existingKeyPrevIdx = schema.getFactoryRelationCol().newPrevIdxKey();
        existingKeyPrevIdx.setOptionalPrevId(existing.getOptionalPrevId());

        MSSBamRelationColByPrevIdxKey newKeyPrevIdx = schema.getFactoryRelationCol().newPrevIdxKey();
        newKeyPrevIdx.setOptionalPrevId(Buff.getOptionalPrevId());

        MSSBamRelationColByNextIdxKey existingKeyNextIdx = schema.getFactoryRelationCol().newNextIdxKey();
        existingKeyNextIdx.setOptionalNextId(existing.getOptionalNextId());

        MSSBamRelationColByNextIdxKey newKeyNextIdx = schema.getFactoryRelationCol().newNextIdxKey();
        newKeyNextIdx.setOptionalNextId(Buff.getOptionalNextId());

        MSSBamRelationColByRelPrevIdxKey existingKeyRelPrevIdx = schema.getFactoryRelationCol().newRelPrevIdxKey();
        existingKeyRelPrevIdx.setRequiredRelationId(existing.getRequiredRelationId());
        existingKeyRelPrevIdx.setOptionalPrevId(existing.getOptionalPrevId());

        MSSBamRelationColByRelPrevIdxKey newKeyRelPrevIdx = schema.getFactoryRelationCol().newRelPrevIdxKey();
        newKeyRelPrevIdx.setRequiredRelationId(Buff.getRequiredRelationId());
        newKeyRelPrevIdx.setOptionalPrevId(Buff.getOptionalPrevId());

        MSSBamRelationColByRelNextIdxKey existingKeyRelNextIdx = schema.getFactoryRelationCol().newRelNextIdxKey();
        existingKeyRelNextIdx.setRequiredRelationId(existing.getRequiredRelationId());
        existingKeyRelNextIdx.setOptionalNextId(existing.getOptionalNextId());

        MSSBamRelationColByRelNextIdxKey newKeyRelNextIdx = schema.getFactoryRelationCol().newRelNextIdxKey();
        newKeyRelNextIdx.setRequiredRelationId(Buff.getRequiredRelationId());
        newKeyRelNextIdx.setOptionalNextId(Buff.getOptionalNextId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableAnyObj().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateRelationCol", "Superclass", "SuperClass", "AnyObj", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableRelation().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredRelationId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateRelationCol", "Container", "Relation", "Relation", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredFromColId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateRelationCol", "Lookup", "LookupFromCol", "Value", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredToColId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateRelationCol", "Lookup", "LookupToCol", "Value", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdict;

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

        subdict = dictByRelationIdx.get(existingKeyRelationIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByRelationIdx.containsKey(newKeyRelationIdx)) {
            subdict = dictByRelationIdx.get(newKeyRelationIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelationIdx.put(newKeyRelationIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByFromColIdx.get(existingKeyFromColIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByFromColIdx.containsKey(newKeyFromColIdx)) {
            subdict = dictByFromColIdx.get(newKeyFromColIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByFromColIdx.put(newKeyFromColIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByToColIdx.get(existingKeyToColIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByToColIdx.containsKey(newKeyToColIdx)) {
            subdict = dictByToColIdx.get(newKeyToColIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByToColIdx.put(newKeyToColIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByPrevIdx.get(existingKeyPrevIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByPrevIdx.containsKey(newKeyPrevIdx)) {
            subdict = dictByPrevIdx.get(newKeyPrevIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByPrevIdx.put(newKeyPrevIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByNextIdx.get(existingKeyNextIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByNextIdx.containsKey(newKeyNextIdx)) {
            subdict = dictByNextIdx.get(newKeyNextIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByNextIdx.put(newKeyNextIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByRelPrevIdx.get(existingKeyRelPrevIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByRelPrevIdx.containsKey(newKeyRelPrevIdx)) {
            subdict = dictByRelPrevIdx.get(newKeyRelPrevIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelPrevIdx.put(newKeyRelPrevIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByRelNextIdx.get(existingKeyRelNextIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByRelNextIdx.containsKey(newKeyRelNextIdx)) {
            subdict = dictByRelNextIdx.get(newKeyRelNextIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelationColBuff>();
            dictByRelNextIdx.put(newKeyRelNextIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteRelationCol(MSSBamAuthorization Authorization, MSSBamRelationColBuff Buff) {
        final String S_ProcName = "MSSBamRamRelationColTable.deleteRelationCol() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamRelationColBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteRelationCol",
                    "Existing record not found", "RelationCol", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteRelationCol",
                    pkey);
        }
        MSSBamRelationColByRelationIdxKey keyRelationIdx = schema.getFactoryRelationCol().newRelationIdxKey();
        keyRelationIdx.setRequiredRelationId(existing.getRequiredRelationId());

        MSSBamRelationColByFromColIdxKey keyFromColIdx = schema.getFactoryRelationCol().newFromColIdxKey();
        keyFromColIdx.setRequiredFromColId(existing.getRequiredFromColId());

        MSSBamRelationColByToColIdxKey keyToColIdx = schema.getFactoryRelationCol().newToColIdxKey();
        keyToColIdx.setRequiredToColId(existing.getRequiredToColId());

        MSSBamRelationColByPrevIdxKey keyPrevIdx = schema.getFactoryRelationCol().newPrevIdxKey();
        keyPrevIdx.setOptionalPrevId(existing.getOptionalPrevId());

        MSSBamRelationColByNextIdxKey keyNextIdx = schema.getFactoryRelationCol().newNextIdxKey();
        keyNextIdx.setOptionalNextId(existing.getOptionalNextId());

        MSSBamRelationColByRelPrevIdxKey keyRelPrevIdx = schema.getFactoryRelationCol().newRelPrevIdxKey();
        keyRelPrevIdx.setRequiredRelationId(existing.getRequiredRelationId());
        keyRelPrevIdx.setOptionalPrevId(existing.getOptionalPrevId());

        MSSBamRelationColByRelNextIdxKey keyRelNextIdx = schema.getFactoryRelationCol().newRelNextIdxKey();
        keyRelNextIdx.setRequiredRelationId(existing.getRequiredRelationId());
        keyRelNextIdx.setOptionalNextId(existing.getOptionalNextId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByRelationIdx.get(keyRelationIdx);
        subdict.remove(pkey);

        subdict = dictByFromColIdx.get(keyFromColIdx);
        subdict.remove(pkey);

        subdict = dictByToColIdx.get(keyToColIdx);
        subdict.remove(pkey);

        subdict = dictByPrevIdx.get(keyPrevIdx);
        subdict.remove(pkey);

        subdict = dictByNextIdx.get(keyNextIdx);
        subdict.remove(pkey);

        subdict = dictByRelPrevIdx.get(keyRelPrevIdx);
        subdict.remove(pkey);

        subdict = dictByRelNextIdx.get(keyRelNextIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openRelationColCursorByRelationIdx(MSSBamAuthorization Authorization, long RelationId) {
        MSSBamCursor cursor;
        MSSBamRelationColByRelationIdxKey key = schema.getFactoryRelationCol().newRelationIdxKey();
        key.setRequiredRelationId(RelationId);

        if (dictByRelationIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelationIdx = dictByRelationIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictRelationIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByFromColIdx(MSSBamAuthorization Authorization, long FromColId) {
        MSSBamCursor cursor;
        MSSBamRelationColByFromColIdxKey key = schema.getFactoryRelationCol().newFromColIdxKey();
        key.setRequiredFromColId(FromColId);

        if (dictByFromColIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictFromColIdx = dictByFromColIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictFromColIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByToColIdx(MSSBamAuthorization Authorization, long ToColId) {
        MSSBamCursor cursor;
        MSSBamRelationColByToColIdxKey key = schema.getFactoryRelationCol().newToColIdxKey();
        key.setRequiredToColId(ToColId);

        if (dictByToColIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictToColIdx = dictByToColIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictToColIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) {
        MSSBamCursor cursor;
        MSSBamRelationColByPrevIdxKey key = schema.getFactoryRelationCol().newPrevIdxKey();
        key.setOptionalPrevId(PrevId);

        if (dictByPrevIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictPrevIdx = dictByPrevIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictPrevIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByNextIdx(MSSBamAuthorization Authorization, Long NextId) {
        MSSBamCursor cursor;
        MSSBamRelationColByNextIdxKey key = schema.getFactoryRelationCol().newNextIdxKey();
        key.setOptionalNextId(NextId);

        if (dictByNextIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictNextIdx = dictByNextIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictNextIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByRelPrevIdx(MSSBamAuthorization Authorization, long RelationId,
            Long PrevId) {
        MSSBamCursor cursor;
        MSSBamRelationColByRelPrevIdxKey key = schema.getFactoryRelationCol().newRelPrevIdxKey();
        key.setRequiredRelationId(RelationId);
        key.setOptionalPrevId(PrevId);

        if (dictByRelPrevIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelPrevIdx = dictByRelPrevIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictRelPrevIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openRelationColCursorByRelNextIdx(MSSBamAuthorization Authorization, long RelationId,
            Long NextId) {
        MSSBamCursor cursor;
        MSSBamRelationColByRelNextIdxKey key = schema.getFactoryRelationCol().newRelNextIdxKey();
        key.setRequiredRelationId(RelationId);
        key.setOptionalNextId(NextId);

        if (dictByRelNextIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamRelationColBuff> subdictRelNextIdx = dictByRelNextIdx.get(key);
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, subdictRelNextIdx.values());
        } else {
            cursor = new MSSBamRamRelationColCursor(Authorization, schema, new ArrayList<MSSBamRelationColBuff>());
        }
        return (cursor);
    }

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

    public MSSBamRelationColBuff nextRelationColCursor(MSSBamCursor Cursor) {
        MSSBamRamRelationColCursor cursor = (MSSBamRamRelationColCursor) Cursor;
        MSSBamRelationColBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamRelationColBuff firstRelationColCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamRelationColBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextRelationColCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamRelationColBuff nthRelationColCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamRelationColBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextRelationColCursor(Cursor);
        }
        return (rec);
    }
}