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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamManufactureToolSetTable in-memory RAM DbIO implementation
 *   for ManufactureToolSet.
 */
public class MSSBamRamManufactureToolSetTable implements IMSSBamManufactureToolSetTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff>();
    private SortedMap<MSSBamManufactureToolSetByUTSNameIdxKey, MSSBamManufactureToolSetBuff> dictByUTSNameIdx = new TreeMap<MSSBamManufactureToolSetByUTSNameIdxKey, MSSBamManufactureToolSetBuff>();
    private SortedMap<MSSBamManufactureToolSetByManufacturedIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff>> dictByManufacturedIdx = new TreeMap<MSSBamManufactureToolSetByManufacturedIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff>>();

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

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

        pkey.setClassCode(Buff.getClassCode());

        pkey.setRequiredId(Buff.getRequiredId());

        MSSBamManufactureToolSetByUTSNameIdxKey keyUTSNameIdx = schema.getFactoryManufactureToolSet()
                .newUTSNameIdxKey();
        keyUTSNameIdx.setRequiredManufacturedId(Buff.getRequiredManufacturedId());
        keyUTSNameIdx.setRequiredToolSetName(Buff.getRequiredToolSetName());

        MSSBamManufactureToolSetByManufacturedIdxKey keyManufacturedIdx = schema.getFactoryManufactureToolSet()
                .newManufacturedIdxKey();
        keyManufacturedIdx.setRequiredManufacturedId(Buff.getRequiredManufacturedId());

        // Validate unique indexes

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

        if (dictByUTSNameIdx.containsKey(keyUTSNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createManufactureToolSet", "ManufactureToolSetUTSNameIdx", keyUTSNameIdx);
        }

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableScope().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredManufacturedId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createManufactureToolSet", "Container", "Manufactured", "Scope", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        dictByUTSNameIdx.put(keyUTSNameIdx, Buff);

        SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff> subdictManufacturedIdx;
        if (dictByManufacturedIdx.containsKey(keyManufacturedIdx)) {
            subdictManufacturedIdx = dictByManufacturedIdx.get(keyManufacturedIdx);
        } else {
            subdictManufacturedIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff>();
            dictByManufacturedIdx.put(keyManufacturedIdx, subdictManufacturedIdx);
        }
        subdictManufacturedIdx.put(pkey, Buff);

    }

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

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

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

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

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

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

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

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

    public MSSBamManufactureToolSetBuff readDerivedByUTSNameIdx(MSSBamAuthorization Authorization,
            long ManufacturedId, String ToolSetName) {
        final String S_ProcName = "MSSBamRamManufactureToolSet.readDerivedByUTSNameIdx() ";
        MSSBamManufactureToolSetByUTSNameIdxKey key = schema.getFactoryManufactureToolSet().newUTSNameIdxKey();
        key.setRequiredManufacturedId(ManufacturedId);
        key.setRequiredToolSetName(ToolSetName);

        MSSBamManufactureToolSetBuff buff;
        if (dictByUTSNameIdx.containsKey(key)) {
            buff = dictByUTSNameIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamManufactureToolSetBuff[] readDerivedByManufacturedIdx(MSSBamAuthorization Authorization,
            long ManufacturedId) {
        final String S_ProcName = "MSSBamRamManufactureToolSet.readDerivedByManufacturedIdx() ";
        MSSBamManufactureToolSetByManufacturedIdxKey key = schema.getFactoryManufactureToolSet()
                .newManufacturedIdxKey();
        key.setRequiredManufacturedId(ManufacturedId);

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

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

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

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

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

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

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

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

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

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

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

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

    public MSSBamManufactureToolSetBuff readBuffByUTSNameIdx(MSSBamAuthorization Authorization, long ManufacturedId,
            String ToolSetName) {
        final String S_ProcName = "MSSBamRamManufactureToolSet.readBuffByUTSNameIdx() ";
        MSSBamManufactureToolSetBuff buff = readDerivedByUTSNameIdx(Authorization, ManufacturedId, ToolSetName);
        if ((buff != null) && buff.getClassCode().equals("MFTS")) {
            return ((MSSBamManufactureToolSetBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamManufactureToolSetBuff[] readBuffByManufacturedIdx(MSSBamAuthorization Authorization,
            long ManufacturedId) {
        final String S_ProcName = "MSSBamRamManufactureToolSet.readBuffByManufacturedIdx() ";
        MSSBamManufactureToolSetBuff buff;
        ArrayList<MSSBamManufactureToolSetBuff> filteredList = new ArrayList<MSSBamManufactureToolSetBuff>();
        MSSBamManufactureToolSetBuff[] buffList = readDerivedByManufacturedIdx(Authorization, ManufacturedId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("MFTS")) {
                filteredList.add((MSSBamManufactureToolSetBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamManufactureToolSetBuff[0]));
    }

    public void updateManufactureToolSet(MSSBamAuthorization Authorization, MSSBamManufactureToolSetBuff Buff) {
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamManufactureToolSetBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateManufactureToolSet", "Existing record not found", "ManufactureToolSet", pkey);
        }
        MSSBamManufactureToolSetByUTSNameIdxKey existingKeyUTSNameIdx = schema.getFactoryManufactureToolSet()
                .newUTSNameIdxKey();
        existingKeyUTSNameIdx.setRequiredManufacturedId(existing.getRequiredManufacturedId());
        existingKeyUTSNameIdx.setRequiredToolSetName(existing.getRequiredToolSetName());

        MSSBamManufactureToolSetByUTSNameIdxKey newKeyUTSNameIdx = schema.getFactoryManufactureToolSet()
                .newUTSNameIdxKey();
        newKeyUTSNameIdx.setRequiredManufacturedId(Buff.getRequiredManufacturedId());
        newKeyUTSNameIdx.setRequiredToolSetName(Buff.getRequiredToolSetName());

        MSSBamManufactureToolSetByManufacturedIdxKey existingKeyManufacturedIdx = schema
                .getFactoryManufactureToolSet().newManufacturedIdxKey();
        existingKeyManufacturedIdx.setRequiredManufacturedId(existing.getRequiredManufacturedId());

        MSSBamManufactureToolSetByManufacturedIdxKey newKeyManufacturedIdx = schema.getFactoryManufactureToolSet()
                .newManufacturedIdxKey();
        newKeyManufacturedIdx.setRequiredManufacturedId(Buff.getRequiredManufacturedId());

        // Check unique indexes

        if (!existingKeyUTSNameIdx.equals(newKeyUTSNameIdx)) {
            if (dictByUTSNameIdx.containsKey(newKeyUTSNameIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateManufactureToolSet", "ManufactureToolSetUTSNameIdx", newKeyUTSNameIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableScope().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredManufacturedId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateManufactureToolSet", "Container", "Manufactured", "Scope", null);
                }
            }
        }

        // Update is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff> subdict;

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

        dictByUTSNameIdx.remove(existingKeyUTSNameIdx);
        dictByUTSNameIdx.put(newKeyUTSNameIdx, Buff);

        subdict = dictByManufacturedIdx.get(existingKeyManufacturedIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByManufacturedIdx.containsKey(newKeyManufacturedIdx)) {
            subdict = dictByManufacturedIdx.get(newKeyManufacturedIdx);
        } else {
            subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff>();
            dictByManufacturedIdx.put(newKeyManufacturedIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteManufactureToolSet(MSSBamAuthorization Authorization, MSSBamManufactureToolSetBuff Buff) {
        final String S_ProcName = "MSSBamRamManufactureToolSetTable.deleteManufactureToolSet() ";
        MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey();

        pkey.setRequiredId(schema.nextAnyObjIdGen());
        MSSBamManufactureToolSetBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "deleteManufactureToolSet", "Existing record not found", "ManufactureToolSet", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteManufactureToolSet", pkey);
        }
        MSSBamManufactureToolSetByUTSNameIdxKey keyUTSNameIdx = schema.getFactoryManufactureToolSet()
                .newUTSNameIdxKey();
        keyUTSNameIdx.setRequiredManufacturedId(existing.getRequiredManufacturedId());
        keyUTSNameIdx.setRequiredToolSetName(existing.getRequiredToolSetName());

        MSSBamManufactureToolSetByManufacturedIdxKey keyManufacturedIdx = schema.getFactoryManufactureToolSet()
                .newManufacturedIdxKey();
        keyManufacturedIdx.setRequiredManufacturedId(existing.getRequiredManufacturedId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff> subdict;

        dictByPKey.remove(pkey);

        dictByUTSNameIdx.remove(keyUTSNameIdx);

        subdict = dictByManufacturedIdx.get(keyManufacturedIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openManufactureToolSetCursorByManufacturedIdx(MSSBamAuthorization Authorization,
            long ManufacturedId) {
        MSSBamCursor cursor;
        MSSBamManufactureToolSetByManufacturedIdxKey key = schema.getFactoryManufactureToolSet()
                .newManufacturedIdxKey();
        key.setRequiredManufacturedId(ManufacturedId);

        if (dictByManufacturedIdx.containsKey(key)) {
            SortedMap<MSSBamAnyObjPKey, MSSBamManufactureToolSetBuff> subdictManufacturedIdx = dictByManufacturedIdx
                    .get(key);
            cursor = new MSSBamRamManufactureToolSetCursor(Authorization, schema, subdictManufacturedIdx.values());
        } else {
            cursor = new MSSBamRamManufactureToolSetCursor(Authorization, schema,
                    new ArrayList<MSSBamManufactureToolSetBuff>());
        }
        return (cursor);
    }

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

    public MSSBamManufactureToolSetBuff nextManufactureToolSetCursor(MSSBamCursor Cursor) {
        MSSBamRamManufactureToolSetCursor cursor = (MSSBamRamManufactureToolSetCursor) Cursor;
        MSSBamManufactureToolSetBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamManufactureToolSetBuff firstManufactureToolSetCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamManufactureToolSetBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextManufactureToolSetCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamManufactureToolSetBuff nthManufactureToolSetCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamManufactureToolSetBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextManufactureToolSetCursor(Cursor);
        }
        return (rec);
    }
}