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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamDelSubDep3Table in-memory RAM DbIO implementation
 *   for DelSubDep3.
 */
public class MSSBamRamDelSubDep3Table implements IMSSBamDelSubDep3Table {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff>();
    private SortedMap<MSSBamDelSubDep3ByContDelDep2IdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff>> dictByContDelDep2Idx = new TreeMap<MSSBamDelSubDep3ByContDelDep2IdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff>>();

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

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

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamDelSubDep3ByContDelDep2IdxKey keyContDelDep2Idx = schema.getFactoryDelSubDep3()
                .newContDelDep2IdxKey();
        keyContDelDep2Idx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());

        // Validate unique indexes

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

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableDelSubDep2().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredContDelDep2Id())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createDelSubDep3", "Container", "ContDelSubDep3", "DelSubDep2", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff> subdictContDelDep2Idx;
        if (dictByContDelDep2Idx.containsKey(keyContDelDep2Idx)) {
            subdictContDelDep2Idx = dictByContDelDep2Idx.get(keyContDelDep2Idx);
        } else {
            subdictContDelDep2Idx = new TreeMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff>();
            dictByContDelDep2Idx.put(keyContDelDep2Idx, subdictContDelDep2Idx);
        }
        subdictContDelDep2Idx.put(pkey, Buff);

    }

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

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

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

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

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

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

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

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

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

    public MSSBamDelSubDep3Buff[] readDerivedByContDelDep2Idx(MSSBamAuthorization Authorization,
            long ContDelDep2Id) {
        final String S_ProcName = "MSSBamRamDelSubDep3.readDerivedByContDelDep2Idx() ";
        MSSBamDelSubDep3ByContDelDep2IdxKey key = schema.getFactoryDelSubDep3().newContDelDep2IdxKey();
        key.setRequiredContDelDep2Id(ContDelDep2Id);

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

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

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

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

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

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

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

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

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

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

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

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

    public MSSBamDelSubDep3Buff[] readBuffByTableIdx(MSSBamAuthorization Authorization, long RelationId) {
        final String S_ProcName = "MSSBamRamDelDep.readBuffByTableIdx() ";
        MSSBamDelDepBuff buff;
        ArrayList<MSSBamDelSubDep3Buff> filteredList = new ArrayList<MSSBamDelSubDep3Buff>();
        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((MSSBamDelSubDep3Buff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamDelSubDep3Buff[0]));
    }

    public MSSBamDelSubDep3Buff[] readBuffByContDelDep2Idx(MSSBamAuthorization Authorization, long ContDelDep2Id) {
        final String S_ProcName = "MSSBamRamDelSubDep3.readBuffByContDelDep2Idx() ";
        MSSBamDelSubDep3Buff buff;
        ArrayList<MSSBamDelSubDep3Buff> filteredList = new ArrayList<MSSBamDelSubDep3Buff>();
        MSSBamDelSubDep3Buff[] buffList = readDerivedByContDelDep2Idx(Authorization, ContDelDep2Id);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("DEL3")) {
                filteredList.add((MSSBamDelSubDep3Buff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamDelSubDep3Buff[0]));
    }

    public void updateDelSubDep3(MSSBamAuthorization Authorization, MSSBamDelSubDep3Buff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamDelSubDep3Buff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateDelSubDep3",
                    "Existing record not found", "DelSubDep3", pkey);
        }
        MSSBamDelSubDep3ByContDelDep2IdxKey existingKeyContDelDep2Idx = schema.getFactoryDelSubDep3()
                .newContDelDep2IdxKey();
        existingKeyContDelDep2Idx.setRequiredContDelDep2Id(existing.getRequiredContDelDep2Id());

        MSSBamDelSubDep3ByContDelDep2IdxKey newKeyContDelDep2Idx = schema.getFactoryDelSubDep3()
                .newContDelDep2IdxKey();
        newKeyContDelDep2Idx.setRequiredContDelDep2Id(Buff.getRequiredContDelDep2Id());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableDelSubDep2().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredContDelDep2Id())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateDelSubDep3", "Container", "ContDelSubDep3", "DelSubDep2", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff> subdict;

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

        subdict = dictByContDelDep2Idx.get(existingKeyContDelDep2Idx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByContDelDep2Idx.containsKey(newKeyContDelDep2Idx)) {
            subdict = dictByContDelDep2Idx.get(newKeyContDelDep2Idx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff>();
            dictByContDelDep2Idx.put(newKeyContDelDep2Idx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteDelSubDep3(MSSBamAuthorization Authorization, MSSBamDelSubDep3Buff Buff) {
        final String S_ProcName = "MSSBamRamDelSubDep3Table.deleteDelSubDep3() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamDelSubDep3Buff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteDelSubDep3",
                    "Existing record not found", "DelSubDep3", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteDelSubDep3",
                    pkey);
        }
        MSSBamDelSubDep3ByContDelDep2IdxKey keyContDelDep2Idx = schema.getFactoryDelSubDep3()
                .newContDelDep2IdxKey();
        keyContDelDep2Idx.setRequiredContDelDep2Id(existing.getRequiredContDelDep2Id());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByContDelDep2Idx.get(keyContDelDep2Idx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openDelSubDep3CursorByContDelDep2Idx(MSSBamAuthorization Authorization,
            long ContDelDep2Id) {
        MSSBamCursor cursor;
        MSSBamDelSubDep3ByContDelDep2IdxKey key = schema.getFactoryDelSubDep3().newContDelDep2IdxKey();
        key.setRequiredContDelDep2Id(ContDelDep2Id);

        if (dictByContDelDep2Idx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamDelSubDep3Buff> subdictContDelDep2Idx = dictByContDelDep2Idx.get(key);
            cursor = new MSSBamRamDelSubDep3Cursor(Authorization, schema, subdictContDelDep2Idx.values());
        } else {
            cursor = new MSSBamRamDelSubDep3Cursor(Authorization, schema, new ArrayList<MSSBamDelSubDep3Buff>());
        }
        return (cursor);
    }

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

    public MSSBamDelSubDep3Buff nextDelSubDep3Cursor(MSSBamCursor Cursor) {
        MSSBamRamDelSubDep3Cursor cursor = (MSSBamRamDelSubDep3Cursor) Cursor;
        MSSBamDelSubDep3Buff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamDelSubDep3Buff firstDelSubDep3Cursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamDelSubDep3Buff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextDelSubDep3Cursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamDelSubDep3Buff nthDelSubDep3Cursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamDelSubDep3Buff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextDelSubDep3Cursor(Cursor);
        }
        return (rec);
    }
}