net.sourceforge.msscodefactory.v1_11.MSSBamRam.MSSBamRamPopTopDepTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.v1_11.MSSBamRam.MSSBamRamPopTopDepTable.java

Source

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

/*
 *   MSS Code Factory 1.11
 *
 *   Copyright (c) 2012-2014 Mark Sobkow
 *   
 *   This program is available as free software under the GNU GPL v3, or
 *   under a commercial license from Mark Sobkow.  For commercial licensing
 *   details, please contact msobkow@sasktel.net.
 *   
 *   Under the terms of the GPL:
 *   
 *      This program is free software: you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation, either version 3 of the License, or
 *      (at your option) any later version.
 *     
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *     
 *      You should have received a copy of the GNU General Public License
 *      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *   
 * ***********************************************************************
 *
 *   $Revision$
 */

package net.sourceforge.msscodefactory.v1_11.MSSBamRam;

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

/*
 *   MSSBamRamPopTopDepTable in-memory RAM DbIO implementation
 *   for PopTopDep.
 */
public class MSSBamRamPopTopDepTable implements IMSSBamPopTopDepTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamPopTopDepBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff>();
    private SortedMap<MSSBamPopTopDepByContRelIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff>> dictByContRelIdx = new TreeMap<MSSBamPopTopDepByContRelIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff>>();

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

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

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamPopTopDepByContRelIdxKey keyContRelIdx = schema.getFactoryPopTopDep().newContRelIdxKey();
        keyContRelIdx.setRequiredContRelationId(Buff.getRequiredContRelationId());

        // Validate unique indexes

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

        // Validate foreign keys

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

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

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff> subdictContRelIdx;
        if (dictByContRelIdx.containsKey(keyContRelIdx)) {
            subdictContRelIdx = dictByContRelIdx.get(keyContRelIdx);
        } else {
            subdictContRelIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff>();
            dictByContRelIdx.put(keyContRelIdx, subdictContRelIdx);
        }
        subdictContRelIdx.put(pkey, Buff);

    }

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

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

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

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

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

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

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

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

    public MSSBamPopTopDepBuff[] readDerivedByRelationIdx(MSSBamAuthorization Authorization, long RelationId) {
        final String S_ProcName = "MSSBamRamPopDep.readDerivedByRelationIdx() ";
        MSSBamPopDepBuff buffList[] = schema.getTablePopDep().readDerivedByRelationIdx(Authorization, RelationId);
        if (buffList == null) {
            return (null);
        } else {
            MSSBamPopDepBuff buff;
            ArrayList<MSSBamPopTopDepBuff> filteredList = new ArrayList<MSSBamPopTopDepBuff>();
            for (int idx = 0; idx < buffList.length; idx++) {
                buff = buffList[idx];
                if ((buff != null) && (buff instanceof MSSBamPopTopDepBuff)) {
                    filteredList.add((MSSBamPopTopDepBuff) buff);
                }
            }
            return (filteredList.toArray(new MSSBamPopTopDepBuff[0]));
        }
    }

    public MSSBamPopTopDepBuff[] readDerivedByContRelIdx(MSSBamAuthorization Authorization, long ContRelationId) {
        final String S_ProcName = "MSSBamRamPopTopDep.readDerivedByContRelIdx() ";
        MSSBamPopTopDepByContRelIdxKey key = schema.getFactoryPopTopDep().newContRelIdxKey();
        key.setRequiredContRelationId(ContRelationId);

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

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

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

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

    public MSSBamPopTopDepBuff lockBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) {
        final String S_ProcName = "MSSBamRamPopTopDep.readBuff() ";
        MSSBamPopTopDepBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("POPT"))) {
            buff = null;
        }
        return (buff);
    }

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

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

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

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

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

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

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

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

    public MSSBamPopTopDepBuff[] readBuffByContRelIdx(MSSBamAuthorization Authorization, long ContRelationId) {
        final String S_ProcName = "MSSBamRamPopTopDep.readBuffByContRelIdx() ";
        MSSBamPopTopDepBuff buff;
        ArrayList<MSSBamPopTopDepBuff> filteredList = new ArrayList<MSSBamPopTopDepBuff>();
        MSSBamPopTopDepBuff[] buffList = readDerivedByContRelIdx(Authorization, ContRelationId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("POPT")) {
                filteredList.add((MSSBamPopTopDepBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamPopTopDepBuff[0]));
    }

    public void updatePopTopDep(MSSBamAuthorization Authorization, MSSBamPopTopDepBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamPopTopDepBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updatePopTopDep",
                    "Existing record not found", "PopTopDep", pkey);
        }
        MSSBamPopTopDepByContRelIdxKey existingKeyContRelIdx = schema.getFactoryPopTopDep().newContRelIdxKey();
        existingKeyContRelIdx.setRequiredContRelationId(existing.getRequiredContRelationId());

        MSSBamPopTopDepByContRelIdxKey newKeyContRelIdx = schema.getFactoryPopTopDep().newContRelIdxKey();
        newKeyContRelIdx.setRequiredContRelationId(Buff.getRequiredContRelationId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

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

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff> subdict;

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

        subdict = dictByContRelIdx.get(existingKeyContRelIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByContRelIdx.containsKey(newKeyContRelIdx)) {
            subdict = dictByContRelIdx.get(newKeyContRelIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff>();
            dictByContRelIdx.put(newKeyContRelIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deletePopTopDep(MSSBamAuthorization Authorization, MSSBamPopTopDepBuff Buff) {
        final String S_ProcName = "MSSBamRamPopTopDepTable.deletePopTopDep() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamPopTopDepBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deletePopTopDep",
                    "Existing record not found", "PopTopDep", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deletePopTopDep",
                    pkey);
        }
        MSSBamPopTopDepByContRelIdxKey keyContRelIdx = schema.getFactoryPopTopDep().newContRelIdxKey();
        keyContRelIdx.setRequiredContRelationId(existing.getRequiredContRelationId());

        // Validate reverse foreign keys

        if (schema.getTablePopSubDep1().readDerivedByContPopTopIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deletePopTopDep",
                    "Container", "ContPopTopDep", "PopSubDep1", pkey);
        }

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByContRelIdx.get(keyContRelIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openPopTopDepCursorByContRelIdx(MSSBamAuthorization Authorization, long ContRelationId) {
        MSSBamCursor cursor;
        MSSBamPopTopDepByContRelIdxKey key = schema.getFactoryPopTopDep().newContRelIdxKey();
        key.setRequiredContRelationId(ContRelationId);

        if (dictByContRelIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamPopTopDepBuff> subdictContRelIdx = dictByContRelIdx.get(key);
            cursor = new MSSBamRamPopTopDepCursor(Authorization, schema, subdictContRelIdx.values());
        } else {
            cursor = new MSSBamRamPopTopDepCursor(Authorization, schema, new ArrayList<MSSBamPopTopDepBuff>());
        }
        return (cursor);
    }

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

    public MSSBamPopTopDepBuff nextPopTopDepCursor(MSSBamCursor Cursor) {
        MSSBamRamPopTopDepCursor cursor = (MSSBamRamPopTopDepCursor) Cursor;
        MSSBamPopTopDepBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamPopTopDepBuff firstPopTopDepCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamPopTopDepBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextPopTopDepCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamPopTopDepBuff nthPopTopDepCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamPopTopDepBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextPopTopDepCursor(Cursor);
        }
        return (rec);
    }
}