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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamDelSubDep1Table in-memory RAM DbIO implementation
 *   for DelSubDep1.
 */
public class MSSBamRamDelSubDep1Table implements IMSSBamDelSubDep1Table {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff>();
    private SortedMap<MSSBamDelSubDep1ByContDelTopIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff>> dictByContDelTopIdx = new TreeMap<MSSBamDelSubDep1ByContDelTopIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff>>();

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

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

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamDelSubDep1ByContDelTopIdxKey keyContDelTopIdx = schema.getFactoryDelSubDep1().newContDelTopIdxKey();
        keyContDelTopIdx.setRequiredContDelTopDepId(Buff.getRequiredContDelTopDepId());

        // Validate unique indexes

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

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableDelTopDep().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredContDelTopDepId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createDelSubDep1", "Container", "ContDelTopDep", "DelTopDep", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff> subdictContDelTopIdx;
        if (dictByContDelTopIdx.containsKey(keyContDelTopIdx)) {
            subdictContDelTopIdx = dictByContDelTopIdx.get(keyContDelTopIdx);
        } else {
            subdictContDelTopIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff>();
            dictByContDelTopIdx.put(keyContDelTopIdx, subdictContDelTopIdx);
        }
        subdictContDelTopIdx.put(pkey, Buff);

    }

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

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

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

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

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

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

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

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

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

    public MSSBamDelSubDep1Buff[] readDerivedByContDelTopIdx(MSSBamAuthorization Authorization,
            long ContDelTopDepId) {
        final String S_ProcName = "MSSBamRamDelSubDep1.readDerivedByContDelTopIdx() ";
        MSSBamDelSubDep1ByContDelTopIdxKey key = schema.getFactoryDelSubDep1().newContDelTopIdxKey();
        key.setRequiredContDelTopDepId(ContDelTopDepId);

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

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

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

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

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

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

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

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

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

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

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

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

    public MSSBamDelSubDep1Buff[] readBuffByTableIdx(MSSBamAuthorization Authorization, long RelationId) {
        final String S_ProcName = "MSSBamRamDelDep.readBuffByTableIdx() ";
        MSSBamDelDepBuff buff;
        ArrayList<MSSBamDelSubDep1Buff> filteredList = new ArrayList<MSSBamDelSubDep1Buff>();
        MSSBamDelDepBuff[] buffList = readDerivedByTableIdx(Authorization, RelationId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("DELD")) {
                filteredList.add((MSSBamDelSubDep1Buff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamDelSubDep1Buff[0]));
    }

    public MSSBamDelSubDep1Buff[] readBuffByContDelTopIdx(MSSBamAuthorization Authorization, long ContDelTopDepId) {
        final String S_ProcName = "MSSBamRamDelSubDep1.readBuffByContDelTopIdx() ";
        MSSBamDelSubDep1Buff buff;
        ArrayList<MSSBamDelSubDep1Buff> filteredList = new ArrayList<MSSBamDelSubDep1Buff>();
        MSSBamDelSubDep1Buff[] buffList = readDerivedByContDelTopIdx(Authorization, ContDelTopDepId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("DEL1")) {
                filteredList.add((MSSBamDelSubDep1Buff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamDelSubDep1Buff[0]));
    }

    public void updateDelSubDep1(MSSBamAuthorization Authorization, MSSBamDelSubDep1Buff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamDelSubDep1Buff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateDelSubDep1",
                    "Existing record not found", "DelSubDep1", pkey);
        }
        MSSBamDelSubDep1ByContDelTopIdxKey existingKeyContDelTopIdx = schema.getFactoryDelSubDep1()
                .newContDelTopIdxKey();
        existingKeyContDelTopIdx.setRequiredContDelTopDepId(existing.getRequiredContDelTopDepId());

        MSSBamDelSubDep1ByContDelTopIdxKey newKeyContDelTopIdx = schema.getFactoryDelSubDep1()
                .newContDelTopIdxKey();
        newKeyContDelTopIdx.setRequiredContDelTopDepId(Buff.getRequiredContDelTopDepId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableDelTopDep().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredContDelTopDepId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateDelSubDep1", "Container", "ContDelTopDep", "DelTopDep", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff> subdict;

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

        subdict = dictByContDelTopIdx.get(existingKeyContDelTopIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByContDelTopIdx.containsKey(newKeyContDelTopIdx)) {
            subdict = dictByContDelTopIdx.get(newKeyContDelTopIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff>();
            dictByContDelTopIdx.put(newKeyContDelTopIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteDelSubDep1(MSSBamAuthorization Authorization, MSSBamDelSubDep1Buff Buff) {
        final String S_ProcName = "MSSBamRamDelSubDep1Table.deleteDelSubDep1() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamDelSubDep1Buff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteDelSubDep1",
                    "Existing record not found", "DelSubDep1", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteDelSubDep1",
                    pkey);
        }
        MSSBamDelSubDep1ByContDelTopIdxKey keyContDelTopIdx = schema.getFactoryDelSubDep1().newContDelTopIdxKey();
        keyContDelTopIdx.setRequiredContDelTopDepId(existing.getRequiredContDelTopDepId());

        // Validate reverse foreign keys

        if (schema.getTableDelSubDep2().readDerivedByContDelDep1Idx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteDelSubDep1",
                    "Container", "ContDelSubDep1", "DelSubDep2", pkey);
        }

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByContDelTopIdx.get(keyContDelTopIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openDelSubDep1CursorByContDelTopIdx(MSSBamAuthorization Authorization,
            long ContDelTopDepId) {
        MSSBamCursor cursor;
        MSSBamDelSubDep1ByContDelTopIdxKey key = schema.getFactoryDelSubDep1().newContDelTopIdxKey();
        key.setRequiredContDelTopDepId(ContDelTopDepId);

        if (dictByContDelTopIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep1Buff> subdictContDelTopIdx = dictByContDelTopIdx.get(key);
            cursor = new MSSBamRamDelSubDep1Cursor(Authorization, schema, subdictContDelTopIdx.values());
        } else {
            cursor = new MSSBamRamDelSubDep1Cursor(Authorization, schema, new ArrayList<MSSBamDelSubDep1Buff>());
        }
        return (cursor);
    }

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

    public MSSBamDelSubDep1Buff nextDelSubDep1Cursor(MSSBamCursor Cursor) {
        MSSBamRamDelSubDep1Cursor cursor = (MSSBamRamDelSubDep1Cursor) Cursor;
        MSSBamDelSubDep1Buff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamDelSubDep1Buff firstDelSubDep1Cursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamDelSubDep1Buff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextDelSubDep1Cursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamDelSubDep1Buff nthDelSubDep1Cursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamDelSubDep1Buff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextDelSubDep1Cursor(Cursor);
        }
        return (rec);
    }
}