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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamTableColTable in-memory RAM DbIO implementation
 *   for TableCol.
 */
public class MSSBamRamTableColTable implements IMSSBamTableColTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamTableColBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamTableColBuff>();
    private SortedMap<MSSBamTableColByCTableIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff>> dictByCTableIdx = new TreeMap<MSSBamTableColByCTableIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff>>();
    private SortedMap<MSSBamTableColByDataIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff>> dictByDataIdx = new TreeMap<MSSBamTableColByDataIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff>>();

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

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

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamTableColByCTableIdxKey keyCTableIdx = schema.getFactoryTableCol().newCTableIdxKey();
        keyCTableIdx.setRequiredTableId(Buff.getRequiredTableId());

        MSSBamTableColByDataIdxKey keyDataIdx = schema.getFactoryTableCol().newDataIdxKey();
        keyDataIdx.setRequiredDataId(Buff.getRequiredDataId());

        // Validate unique indexes

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

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableAtomDef().readDerivedByIdIdx(Authorization, Buff.getRequiredDataId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTableCol", "Lookup", "Data", "AtomDef", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableTable().readDerivedByIdIdx(Authorization, Buff.getRequiredTableId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createTableCol", "Container", "CTable", "Table", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdictCTableIdx;
        if (dictByCTableIdx.containsKey(keyCTableIdx)) {
            subdictCTableIdx = dictByCTableIdx.get(keyCTableIdx);
        } else {
            subdictCTableIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableColBuff>();
            dictByCTableIdx.put(keyCTableIdx, subdictCTableIdx);
        }
        subdictCTableIdx.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdictDataIdx;
        if (dictByDataIdx.containsKey(keyDataIdx)) {
            subdictDataIdx = dictByDataIdx.get(keyDataIdx);
        } else {
            subdictDataIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableColBuff>();
            dictByDataIdx.put(keyDataIdx, subdictDataIdx);
        }
        subdictDataIdx.put(pkey, Buff);

    }

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

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

    public MSSBamTableColBuff[] 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<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] 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<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] 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<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff 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 MSSBamTableColBuff) {
            return ((MSSBamTableColBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableColBuff[] readDerivedByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByVContIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByVContIdx(Authorization, ValueContainerId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByDataScopeIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByDataScopeIdx(Authorization, DataScopeId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByVAccSecIdx(MSSBamAuthorization Authorization,
            Short ViewAccessSecurityId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByVAccSecIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByVAccSecIdx(Authorization,
                ViewAccessSecurityId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByVAccFreqIdx(MSSBamAuthorization Authorization,
            Short ViewAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByVAccFreqIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByVAccFreqIdx(Authorization,
                ViewAccessFrequencyId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByEAccSecIdx(MSSBamAuthorization Authorization,
            Short EditAccessSecurityId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByEAccSecIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByEAccSecIdx(Authorization,
                EditAccessSecurityId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByEAccFreqIdx(MSSBamAuthorization Authorization,
            Short EditAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByEAccFreqIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByEAccFreqIdx(Authorization,
                EditAccessFrequencyId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByPrevIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByPrevIdx(Authorization, PrevId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByNextIdx(MSSBamAuthorization Authorization, Long NextId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByNextIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByNextIdx(Authorization, NextId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByContPrevIdx(MSSBamAuthorization Authorization, long ValueContainerId,
            Long PrevId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByContPrevIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByContPrevIdx(Authorization,
                ValueContainerId, PrevId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByContNextIdx(MSSBamAuthorization Authorization, long ValueContainerId,
            Long NextId) {
        final String S_ProcName = "MSSBamRamValue.readDerivedByContNextIdx() ";
        MSSBamValueBuff buffList[] = schema.getTableValue().readDerivedByContNextIdx(Authorization,
                ValueContainerId, NextId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamValueBuff buff;
            ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamTableColBuff)) {
                    filteredList.add((MSSBamTableColBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamTableColBuff[0]));
        }
    }

    public MSSBamTableColBuff[] readDerivedByCTableIdx(MSSBamAuthorization Authorization, long TableId) {
        final String S_ProcName = "MSSBamRamTableCol.readDerivedByCTableIdx() ";
        MSSBamTableColByCTableIdxKey key = schema.getFactoryTableCol().newCTableIdxKey();
        key.setRequiredTableId(TableId);

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

    public MSSBamTableColBuff[] readDerivedByDataIdx(MSSBamAuthorization Authorization, long DataId) {
        final String S_ProcName = "MSSBamRamTableCol.readDerivedByDataIdx() ";
        MSSBamTableColByDataIdxKey key = schema.getFactoryTableCol().newDataIdxKey();
        key.setRequiredDataId(DataId);

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

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

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

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

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

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

    public MSSBamTableColBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByTenantIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        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((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByScopeIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        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((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) {
        final String S_ProcName = "MSSBamRamAnyObj.readBuffByAuthorIdx() ";
        MSSBamAnyObjBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        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((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff 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 ((MSSBamTableColBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamTableColBuff[] readBuffByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByVContIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByVContIdx(Authorization, ValueContainerId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByDataScopeIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByDataScopeIdx(Authorization, DataScopeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByVAccSecIdx(MSSBamAuthorization Authorization,
            Short ViewAccessSecurityId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByVAccSecIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByVAccSecIdx(Authorization, ViewAccessSecurityId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByVAccFreqIdx(MSSBamAuthorization Authorization,
            Short ViewAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByVAccFreqIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByEAccSecIdx(MSSBamAuthorization Authorization,
            Short EditAccessSecurityId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByEAccSecIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByEAccSecIdx(Authorization, EditAccessSecurityId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByEAccFreqIdx(MSSBamAuthorization Authorization,
            Short EditAccessFrequencyId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByEAccFreqIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByEAccFreqIdx(Authorization, EditAccessFrequencyId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

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

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

    public MSSBamTableColBuff[] readBuffByContPrevIdx(MSSBamAuthorization Authorization, long ValueContainerId,
            Long PrevId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByContPrevIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByContPrevIdx(Authorization, ValueContainerId, PrevId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByContNextIdx(MSSBamAuthorization Authorization, long ValueContainerId,
            Long NextId) {
        final String S_ProcName = "MSSBamRamValue.readBuffByContNextIdx() ";
        MSSBamValueBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamValueBuff[] buffList = readDerivedByContNextIdx(Authorization, ValueContainerId, NextId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("VAL")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByCTableIdx(MSSBamAuthorization Authorization, long TableId) {
        final String S_ProcName = "MSSBamRamTableCol.readBuffByCTableIdx() ";
        MSSBamTableColBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamTableColBuff[] buffList = readDerivedByCTableIdx(Authorization, TableId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBC")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public MSSBamTableColBuff[] readBuffByDataIdx(MSSBamAuthorization Authorization, long DataId) {
        final String S_ProcName = "MSSBamRamTableCol.readBuffByDataIdx() ";
        MSSBamTableColBuff buff;
        ArrayList<MSSBamTableColBuff> filteredList = new ArrayList<MSSBamTableColBuff>();
        MSSBamTableColBuff[] buffList = readDerivedByDataIdx(Authorization, DataId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("TBC")) {
                filteredList.add((MSSBamTableColBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamTableColBuff[0]));
    }

    public void updateTableCol(MSSBamAuthorization Authorization, MSSBamTableColBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamTableColBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTableCol",
                    "Existing record not found", "TableCol", pkey);
        }
        MSSBamTableColByCTableIdxKey existingKeyCTableIdx = schema.getFactoryTableCol().newCTableIdxKey();
        existingKeyCTableIdx.setRequiredTableId(existing.getRequiredTableId());

        MSSBamTableColByCTableIdxKey newKeyCTableIdx = schema.getFactoryTableCol().newCTableIdxKey();
        newKeyCTableIdx.setRequiredTableId(Buff.getRequiredTableId());

        MSSBamTableColByDataIdxKey existingKeyDataIdx = schema.getFactoryTableCol().newDataIdxKey();
        existingKeyDataIdx.setRequiredDataId(existing.getRequiredDataId());

        MSSBamTableColByDataIdxKey newKeyDataIdx = schema.getFactoryTableCol().newDataIdxKey();
        newKeyDataIdx.setRequiredDataId(Buff.getRequiredDataId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableAtomDef().readDerivedByIdIdx(Authorization, Buff.getRequiredDataId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTableCol", "Lookup", "Data", "AtomDef", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableTable().readDerivedByIdIdx(Authorization, Buff.getRequiredTableId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateTableCol", "Container", "CTable", "Table", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdict;

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

        subdict = dictByCTableIdx.get(existingKeyCTableIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByCTableIdx.containsKey(newKeyCTableIdx)) {
            subdict = dictByCTableIdx.get(newKeyCTableIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableColBuff>();
            dictByCTableIdx.put(newKeyCTableIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByDataIdx.get(existingKeyDataIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByDataIdx.containsKey(newKeyDataIdx)) {
            subdict = dictByDataIdx.get(newKeyDataIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableColBuff>();
            dictByDataIdx.put(newKeyDataIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteTableCol(MSSBamAuthorization Authorization, MSSBamTableColBuff Buff) {
        final String S_ProcName = "MSSBamRamTableColTable.deleteTableCol() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamTableColBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteTableCol",
                    "Existing record not found", "TableCol", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTableCol",
                    pkey);
        }
        MSSBamTableColByCTableIdxKey keyCTableIdx = schema.getFactoryTableCol().newCTableIdxKey();
        keyCTableIdx.setRequiredTableId(existing.getRequiredTableId());

        MSSBamTableColByDataIdxKey keyDataIdx = schema.getFactoryTableCol().newDataIdxKey();
        keyDataIdx.setRequiredDataId(existing.getRequiredDataId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByCTableIdx.get(keyCTableIdx);
        subdict.remove(pkey);

        subdict = dictByDataIdx.get(keyDataIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openTableColCursorByCTableIdx(MSSBamAuthorization Authorization, long TableId) {
        MSSBamCursor cursor;
        MSSBamTableColByCTableIdxKey key = schema.getFactoryTableCol().newCTableIdxKey();
        key.setRequiredTableId(TableId);

        if (dictByCTableIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdictCTableIdx = dictByCTableIdx.get(key);
            cursor = new MSSBamRamTableColCursor(Authorization, schema, subdictCTableIdx.values());
        } else {
            cursor = new MSSBamRamTableColCursor(Authorization, schema, new ArrayList<MSSBamTableColBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openTableColCursorByDataIdx(MSSBamAuthorization Authorization, long DataId) {
        MSSBamCursor cursor;
        MSSBamTableColByDataIdxKey key = schema.getFactoryTableCol().newDataIdxKey();
        key.setRequiredDataId(DataId);

        if (dictByDataIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamTableColBuff> subdictDataIdx = dictByDataIdx.get(key);
            cursor = new MSSBamRamTableColCursor(Authorization, schema, subdictDataIdx.values());
        } else {
            cursor = new MSSBamRamTableColCursor(Authorization, schema, new ArrayList<MSSBamTableColBuff>());
        }
        return (cursor);
    }

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

    public MSSBamTableColBuff nextTableColCursor(MSSBamCursor Cursor) {
        MSSBamRamTableColCursor cursor = (MSSBamRamTableColCursor) Cursor;
        MSSBamTableColBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamTableColBuff firstTableColCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamTableColBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextTableColCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamTableColBuff nthTableColCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamTableColBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextTableColCursor(Cursor);
        }
        return (rec);
    }
}