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

Java tutorial

Introduction

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

Source

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

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

/*
 *   MSSBamRamGroupOperatorTable in-memory RAM DbIO implementation
 *   for GroupOperator.
 */
public class MSSBamRamGroupOperatorTable implements IMSSBamGroupOperatorTable {
    private MSSBamBLRamSchema schema;
    private Map<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> dictByPKey = new HashMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
    private SortedMap<MSSBamGroupOperatorByUNameIdxKey, MSSBamGroupOperatorBuff> dictByUNameIdx = new TreeMap<MSSBamGroupOperatorByUNameIdxKey, MSSBamGroupOperatorBuff>();
    private SortedMap<MSSBamGroupOperatorByApplOptIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>> dictByApplOptIdx = new TreeMap<MSSBamGroupOperatorByApplOptIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>>();
    private SortedMap<MSSBamGroupOperatorByApplStrIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>> dictByApplStrIdx = new TreeMap<MSSBamGroupOperatorByApplStrIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>>();
    private SortedMap<MSSBamGroupOperatorByApplNumIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>> dictByApplNumIdx = new TreeMap<MSSBamGroupOperatorByApplNumIdxKey, SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>>();

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

    public void createGroupOperator(MSSBamAuthorization Authorization, MSSBamGroupOperatorBuff Buff) {
        MSSBamGroupOperatorPKey pkey = schema.getFactoryGroupOperator().newPKey();

        pkey.setRequiredId(Buff.getRequiredId());
        Buff.setRequiredId(pkey.getRequiredId());

        MSSBamGroupOperatorByUNameIdxKey keyUNameIdx = schema.getFactoryGroupOperator().newUNameIdxKey();
        keyUNameIdx.setRequiredName(Buff.getRequiredName());

        MSSBamGroupOperatorByApplOptIdxKey keyApplOptIdx = schema.getFactoryGroupOperator().newApplOptIdxKey();
        keyApplOptIdx.setRequiredAppliesToOptional(Buff.getRequiredAppliesToOptional());

        MSSBamGroupOperatorByApplStrIdxKey keyApplStrIdx = schema.getFactoryGroupOperator().newApplStrIdxKey();
        keyApplStrIdx.setRequiredAppliesToString(Buff.getRequiredAppliesToString());

        MSSBamGroupOperatorByApplNumIdxKey keyApplNumIdx = schema.getFactoryGroupOperator().newApplNumIdxKey();
        keyApplNumIdx.setRequiredAppliesToNumeric(Buff.getRequiredAppliesToNumeric());

        // Validate unique indexes

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

        if (dictByUNameIdx.containsKey(keyUNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createGroupOperator", "GroupOperatorUNameIdx", keyUNameIdx);
        }

        // Validate foreign keys

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        dictByUNameIdx.put(keyUNameIdx, Buff);

        SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplOptIdx;
        if (dictByApplOptIdx.containsKey(keyApplOptIdx)) {
            subdictApplOptIdx = dictByApplOptIdx.get(keyApplOptIdx);
        } else {
            subdictApplOptIdx = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplOptIdx.put(keyApplOptIdx, subdictApplOptIdx);
        }
        subdictApplOptIdx.put(pkey, Buff);

        SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplStrIdx;
        if (dictByApplStrIdx.containsKey(keyApplStrIdx)) {
            subdictApplStrIdx = dictByApplStrIdx.get(keyApplStrIdx);
        } else {
            subdictApplStrIdx = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplStrIdx.put(keyApplStrIdx, subdictApplStrIdx);
        }
        subdictApplStrIdx.put(pkey, Buff);

        SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplNumIdx;
        if (dictByApplNumIdx.containsKey(keyApplNumIdx)) {
            subdictApplNumIdx = dictByApplNumIdx.get(keyApplNumIdx);
        } else {
            subdictApplNumIdx = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplNumIdx.put(keyApplNumIdx, subdictApplNumIdx);
        }
        subdictApplNumIdx.put(pkey, Buff);

    }

    public MSSBamGroupOperatorBuff readDerived(MSSBamAuthorization Authorization, MSSBamGroupOperatorPKey PKey) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerived() ";
        MSSBamGroupOperatorPKey key = schema.getFactoryGroupOperator().newPKey();
        key.setRequiredId(PKey.getRequiredId());
        MSSBamGroupOperatorBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamGroupOperatorBuff lockDerived(MSSBamAuthorization Authorization, MSSBamGroupOperatorPKey PKey) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerived() ";
        MSSBamGroupOperatorPKey key = schema.getFactoryGroupOperator().newPKey();
        key.setRequiredId(PKey.getRequiredId());
        MSSBamGroupOperatorBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamGroupOperatorBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, String Name) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerivedByUNameIdx() ";
        MSSBamGroupOperatorByUNameIdxKey key = schema.getFactoryGroupOperator().newUNameIdxKey();
        key.setRequiredName(Name);

        MSSBamGroupOperatorBuff buff;
        if (dictByUNameIdx.containsKey(key)) {
            buff = dictByUNameIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public MSSBamGroupOperatorBuff[] readDerivedByApplOptIdx(MSSBamAuthorization Authorization,
            boolean AppliesToOptional) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerivedByApplOptIdx() ";
        MSSBamGroupOperatorByApplOptIdxKey key = schema.getFactoryGroupOperator().newApplOptIdxKey();
        key.setRequiredAppliesToOptional(AppliesToOptional);

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

    public MSSBamGroupOperatorBuff[] readDerivedByApplStrIdx(MSSBamAuthorization Authorization,
            boolean AppliesToString) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerivedByApplStrIdx() ";
        MSSBamGroupOperatorByApplStrIdxKey key = schema.getFactoryGroupOperator().newApplStrIdxKey();
        key.setRequiredAppliesToString(AppliesToString);

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

    public MSSBamGroupOperatorBuff[] readDerivedByApplNumIdx(MSSBamAuthorization Authorization,
            boolean AppliesToNumeric) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerivedByApplNumIdx() ";
        MSSBamGroupOperatorByApplNumIdxKey key = schema.getFactoryGroupOperator().newApplNumIdxKey();
        key.setRequiredAppliesToNumeric(AppliesToNumeric);

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

    public MSSBamGroupOperatorBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, short Id) {
        final String S_ProcName = "MSSBamRamGroupOperator.readDerivedByIdIdx() ";
        MSSBamGroupOperatorPKey key = schema.getFactoryGroupOperator().newPKey();
        key.setRequiredId(Id);

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

    public MSSBamGroupOperatorBuff readBuff(MSSBamAuthorization Authorization, MSSBamGroupOperatorPKey PKey) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuff() ";
        MSSBamGroupOperatorBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("GROP"))) {
            buff = null;
        }
        return (buff);
    }

    public MSSBamGroupOperatorBuff lockBuff(MSSBamAuthorization Authorization, MSSBamGroupOperatorPKey PKey) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuff() ";
        MSSBamGroupOperatorBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("GROP"))) {
            buff = null;
        }
        return (buff);
    }

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

    public MSSBamGroupOperatorBuff readBuffByIdIdx(MSSBamAuthorization Authorization, short Id) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuffByIdIdx() ";
        MSSBamGroupOperatorBuff buff = readDerivedByIdIdx(Authorization, Id);
        if ((buff != null) && buff.getClassCode().equals("GROP")) {
            return ((MSSBamGroupOperatorBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamGroupOperatorBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, String Name) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuffByUNameIdx() ";
        MSSBamGroupOperatorBuff buff = readDerivedByUNameIdx(Authorization, Name);
        if ((buff != null) && buff.getClassCode().equals("GROP")) {
            return ((MSSBamGroupOperatorBuff) buff);
        } else {
            return (null);
        }
    }

    public MSSBamGroupOperatorBuff[] readBuffByApplOptIdx(MSSBamAuthorization Authorization,
            boolean AppliesToOptional) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuffByApplOptIdx() ";
        MSSBamGroupOperatorBuff buff;
        ArrayList<MSSBamGroupOperatorBuff> filteredList = new ArrayList<MSSBamGroupOperatorBuff>();
        MSSBamGroupOperatorBuff[] buffList = readDerivedByApplOptIdx(Authorization, AppliesToOptional);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("GROP")) {
                filteredList.add((MSSBamGroupOperatorBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamGroupOperatorBuff[0]));
    }

    public MSSBamGroupOperatorBuff[] readBuffByApplStrIdx(MSSBamAuthorization Authorization,
            boolean AppliesToString) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuffByApplStrIdx() ";
        MSSBamGroupOperatorBuff buff;
        ArrayList<MSSBamGroupOperatorBuff> filteredList = new ArrayList<MSSBamGroupOperatorBuff>();
        MSSBamGroupOperatorBuff[] buffList = readDerivedByApplStrIdx(Authorization, AppliesToString);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("GROP")) {
                filteredList.add((MSSBamGroupOperatorBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamGroupOperatorBuff[0]));
    }

    public MSSBamGroupOperatorBuff[] readBuffByApplNumIdx(MSSBamAuthorization Authorization,
            boolean AppliesToNumeric) {
        final String S_ProcName = "MSSBamRamGroupOperator.readBuffByApplNumIdx() ";
        MSSBamGroupOperatorBuff buff;
        ArrayList<MSSBamGroupOperatorBuff> filteredList = new ArrayList<MSSBamGroupOperatorBuff>();
        MSSBamGroupOperatorBuff[] buffList = readDerivedByApplNumIdx(Authorization, AppliesToNumeric);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("GROP")) {
                filteredList.add((MSSBamGroupOperatorBuff) buff);
            }
        }
        return (filteredList.toArray(new MSSBamGroupOperatorBuff[0]));
    }

    public void updateGroupOperator(MSSBamAuthorization Authorization, MSSBamGroupOperatorBuff Buff) {
        MSSBamGroupOperatorPKey pkey = schema.getFactoryGroupOperator().newPKey();
        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamGroupOperatorBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateGroupOperator", "Existing record not found", "GroupOperator", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "updateGroupOperator", pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        MSSBamGroupOperatorByUNameIdxKey existingKeyUNameIdx = schema.getFactoryGroupOperator().newUNameIdxKey();
        existingKeyUNameIdx.setRequiredName(existing.getRequiredName());

        MSSBamGroupOperatorByUNameIdxKey newKeyUNameIdx = schema.getFactoryGroupOperator().newUNameIdxKey();
        newKeyUNameIdx.setRequiredName(Buff.getRequiredName());

        MSSBamGroupOperatorByApplOptIdxKey existingKeyApplOptIdx = schema.getFactoryGroupOperator()
                .newApplOptIdxKey();
        existingKeyApplOptIdx.setRequiredAppliesToOptional(existing.getRequiredAppliesToOptional());

        MSSBamGroupOperatorByApplOptIdxKey newKeyApplOptIdx = schema.getFactoryGroupOperator().newApplOptIdxKey();
        newKeyApplOptIdx.setRequiredAppliesToOptional(Buff.getRequiredAppliesToOptional());

        MSSBamGroupOperatorByApplStrIdxKey existingKeyApplStrIdx = schema.getFactoryGroupOperator()
                .newApplStrIdxKey();
        existingKeyApplStrIdx.setRequiredAppliesToString(existing.getRequiredAppliesToString());

        MSSBamGroupOperatorByApplStrIdxKey newKeyApplStrIdx = schema.getFactoryGroupOperator().newApplStrIdxKey();
        newKeyApplStrIdx.setRequiredAppliesToString(Buff.getRequiredAppliesToString());

        MSSBamGroupOperatorByApplNumIdxKey existingKeyApplNumIdx = schema.getFactoryGroupOperator()
                .newApplNumIdxKey();
        existingKeyApplNumIdx.setRequiredAppliesToNumeric(existing.getRequiredAppliesToNumeric());

        MSSBamGroupOperatorByApplNumIdxKey newKeyApplNumIdx = schema.getFactoryGroupOperator().newApplNumIdxKey();
        newKeyApplNumIdx.setRequiredAppliesToNumeric(Buff.getRequiredAppliesToNumeric());

        // Check unique indexes

        if (!existingKeyUNameIdx.equals(newKeyUNameIdx)) {
            if (dictByUNameIdx.containsKey(newKeyUNameIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateGroupOperator", "GroupOperatorUNameIdx", newKeyUNameIdx);
            }
        }

        // Validate foreign keys

        // Update is valid

        SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdict;

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

        dictByUNameIdx.remove(existingKeyUNameIdx);
        dictByUNameIdx.put(newKeyUNameIdx, Buff);

        subdict = dictByApplOptIdx.get(existingKeyApplOptIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByApplOptIdx.containsKey(newKeyApplOptIdx)) {
            subdict = dictByApplOptIdx.get(newKeyApplOptIdx);
        } else {
            subdict = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplOptIdx.put(newKeyApplOptIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByApplStrIdx.get(existingKeyApplStrIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByApplStrIdx.containsKey(newKeyApplStrIdx)) {
            subdict = dictByApplStrIdx.get(newKeyApplStrIdx);
        } else {
            subdict = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplStrIdx.put(newKeyApplStrIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByApplNumIdx.get(existingKeyApplNumIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByApplNumIdx.containsKey(newKeyApplNumIdx)) {
            subdict = dictByApplNumIdx.get(newKeyApplNumIdx);
        } else {
            subdict = new TreeMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff>();
            dictByApplNumIdx.put(newKeyApplNumIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteGroupOperator(MSSBamAuthorization Authorization, MSSBamGroupOperatorBuff Buff) {
        final String S_ProcName = "MSSBamRamGroupOperatorTable.deleteGroupOperator() ";
        MSSBamGroupOperatorPKey pkey = schema.getFactoryGroupOperator().newPKey();

        pkey.setRequiredId(Buff.getRequiredId());
        MSSBamGroupOperatorBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "deleteGroupOperator", "Existing record not found", "GroupOperator", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteGroupOperator", pkey);
        }
        MSSBamGroupOperatorByUNameIdxKey keyUNameIdx = schema.getFactoryGroupOperator().newUNameIdxKey();
        keyUNameIdx.setRequiredName(existing.getRequiredName());

        MSSBamGroupOperatorByApplOptIdxKey keyApplOptIdx = schema.getFactoryGroupOperator().newApplOptIdxKey();
        keyApplOptIdx.setRequiredAppliesToOptional(existing.getRequiredAppliesToOptional());

        MSSBamGroupOperatorByApplStrIdxKey keyApplStrIdx = schema.getFactoryGroupOperator().newApplStrIdxKey();
        keyApplStrIdx.setRequiredAppliesToString(existing.getRequiredAppliesToString());

        MSSBamGroupOperatorByApplNumIdxKey keyApplNumIdx = schema.getFactoryGroupOperator().newApplNumIdxKey();
        keyApplNumIdx.setRequiredAppliesToNumeric(existing.getRequiredAppliesToNumeric());

        // Validate reverse foreign keys

        if (schema.getTableRelGroupValue().readDerivedByGrpOpIdx(Authorization,
                existing.getRequiredId()).length > 0) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteGroupOperator", "Lookup", "LookupGroupOperator", "RelGroupValue", pkey);
        }

        // Delete is valid

        SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdict;

        dictByPKey.remove(pkey);

        dictByUNameIdx.remove(keyUNameIdx);

        subdict = dictByApplOptIdx.get(keyApplOptIdx);
        subdict.remove(pkey);

        subdict = dictByApplStrIdx.get(keyApplStrIdx);
        subdict.remove(pkey);

        subdict = dictByApplNumIdx.get(keyApplNumIdx);
        subdict.remove(pkey);

    }

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

    public MSSBamCursor openGroupOperatorCursorByApplOptIdx(MSSBamAuthorization Authorization,
            boolean AppliesToOptional) {
        MSSBamCursor cursor;
        MSSBamGroupOperatorByApplOptIdxKey key = schema.getFactoryGroupOperator().newApplOptIdxKey();
        key.setRequiredAppliesToOptional(AppliesToOptional);

        if (dictByApplOptIdx.containsKey(key)) {
            SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplOptIdx = dictByApplOptIdx
                    .get(key);
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema, subdictApplOptIdx.values());
        } else {
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema,
                    new ArrayList<MSSBamGroupOperatorBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openGroupOperatorCursorByApplStrIdx(MSSBamAuthorization Authorization,
            boolean AppliesToString) {
        MSSBamCursor cursor;
        MSSBamGroupOperatorByApplStrIdxKey key = schema.getFactoryGroupOperator().newApplStrIdxKey();
        key.setRequiredAppliesToString(AppliesToString);

        if (dictByApplStrIdx.containsKey(key)) {
            SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplStrIdx = dictByApplStrIdx
                    .get(key);
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema, subdictApplStrIdx.values());
        } else {
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema,
                    new ArrayList<MSSBamGroupOperatorBuff>());
        }
        return (cursor);
    }

    public MSSBamCursor openGroupOperatorCursorByApplNumIdx(MSSBamAuthorization Authorization,
            boolean AppliesToNumeric) {
        MSSBamCursor cursor;
        MSSBamGroupOperatorByApplNumIdxKey key = schema.getFactoryGroupOperator().newApplNumIdxKey();
        key.setRequiredAppliesToNumeric(AppliesToNumeric);

        if (dictByApplNumIdx.containsKey(key)) {
            SortedMap<MSSBamGroupOperatorPKey, MSSBamGroupOperatorBuff> subdictApplNumIdx = dictByApplNumIdx
                    .get(key);
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema, subdictApplNumIdx.values());
        } else {
            cursor = new MSSBamRamGroupOperatorCursor(Authorization, schema,
                    new ArrayList<MSSBamGroupOperatorBuff>());
        }
        return (cursor);
    }

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

    public MSSBamGroupOperatorBuff nextGroupOperatorCursor(MSSBamCursor Cursor) {
        MSSBamRamGroupOperatorCursor cursor = (MSSBamRamGroupOperatorCursor) Cursor;
        MSSBamGroupOperatorBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public MSSBamGroupOperatorBuff firstGroupOperatorCursor(MSSBamCursor Cursor) {
        int targetRowIdx = 1;
        MSSBamGroupOperatorBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextGroupOperatorCursor(Cursor);
        }
        return (rec);
    }

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

    public MSSBamGroupOperatorBuff nthGroupOperatorCursor(MSSBamCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        MSSBamGroupOperatorBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextGroupOperatorCursor(Cursor);
        }
        return (rec);
    }
}