net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamConfigurationFileTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.CFAstRamConfigurationFileTable.java

Source

// Description: Java7 in-memory RAM DbIO implementation for ConfigurationFile.

/*
 *   CF Asterisk 11 Configuration Model
 *
 *   Copyright (c) 2013-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/>.
 *   
 *      This source code incorporates modified modules originally licensed
 *      under the Apache 2.0 license by MSS Code Factory including CFSecurity
 *      (net-sourceforge-msscodefactory-2.0-cfsecurity.xml),
 *      CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and
 *      CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the
 *      required models being available as part of the MSS Code Factory 1.11
 *      distribution source and install zips.
 *   
 *      You can download installations of MSS Code Factory 1.11 from
 *      http://msscodefactory.sourceforge.net/
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam;

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.cfasterisk.v2_0.CFAst.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.*;

/*
 *   CFAstRamConfigurationFileTable in-memory RAM DbIO implementation
 *   for ConfigurationFile.
 */
public class CFAstRamConfigurationFileTable implements ICFAstConfigurationFileTable {
    private CFAstRamSchema schema;
    private Map<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> dictByPKey = new HashMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
    private SortedMap<CFAstConfigurationFileByClusterIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>> dictByClusterIdx = new TreeMap<CFAstConfigurationFileByClusterIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>>();
    private SortedMap<CFAstConfigurationFileByHostIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>> dictByHostIdx = new TreeMap<CFAstConfigurationFileByHostIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>>();
    private SortedMap<CFAstConfigurationFileByUNameIdxKey, CFAstConfigurationFileBuff> dictByUNameIdx = new TreeMap<CFAstConfigurationFileByUNameIdxKey, CFAstConfigurationFileBuff>();

    public CFAstRamConfigurationFileTable(CFAstRamSchema argSchema) {
        schema = argSchema;
    }

    public void createConfigurationFile(CFAstAuthorization Authorization, CFAstConfigurationFileBuff Buff) {
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setClassCode(Buff.getClassCode());
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(((CFAstRamClusterTable) schema.getTableCluster())
                .nextConfigurationFileIdGen(Authorization, Buff.getRequiredClusterId()));
        Buff.setRequiredClusterId(pkey.getRequiredClusterId());
        Buff.setRequiredId(pkey.getRequiredId());
        CFAstConfigurationFileByClusterIdxKey keyClusterIdx = schema.getFactoryConfigurationFile()
                .newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFAstConfigurationFileByHostIdxKey keyHostIdx = schema.getFactoryConfigurationFile().newHostIdxKey();
        keyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());

        CFAstConfigurationFileByUNameIdxKey keyUNameIdx = schema.getFactoryConfigurationFile().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyUNameIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
        keyUNameIdx.setRequiredFileFullName(Buff.getRequiredFileFullName());

        // Validate unique indexes

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

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

        // Validate foreign keys

        {
            boolean allNull = true;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredClusterId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createConfigurationFile", "Owner", "Cluster", "Cluster", null);
                }
            }
        }

        {
            boolean allNull = true;
            allNull = false;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableHostNode().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredHostNodeId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createConfigurationFile", "Container", "HostNode", "HostNode", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdictClusterIdx;
        if (dictByClusterIdx.containsKey(keyClusterIdx)) {
            subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
        } else {
            subdictClusterIdx = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
            dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
        }
        subdictClusterIdx.put(pkey, Buff);

        SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdictHostIdx;
        if (dictByHostIdx.containsKey(keyHostIdx)) {
            subdictHostIdx = dictByHostIdx.get(keyHostIdx);
        } else {
            subdictHostIdx = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
            dictByHostIdx.put(keyHostIdx, subdictHostIdx);
        }
        subdictHostIdx.put(pkey, Buff);

        dictByUNameIdx.put(keyUNameIdx, Buff);

    }

    public CFAstConfigurationFileBuff readDerived(CFAstAuthorization Authorization,
            CFAstConfigurationFilePKey PKey) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerived() ";
        CFAstConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredId(PKey.getRequiredId());
        CFAstConfigurationFileBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFAstConfigurationFileBuff lockDerived(CFAstAuthorization Authorization,
            CFAstConfigurationFilePKey PKey) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerived() ";
        CFAstConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredId(PKey.getRequiredId());
        CFAstConfigurationFileBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public CFAstConfigurationFileBuff[] readDerivedByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerivedByClusterIdx() ";
        CFAstConfigurationFileByClusterIdxKey key = schema.getFactoryConfigurationFile().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFAstConfigurationFileBuff[] readDerivedByHostIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerivedByHostIdx() ";
        CFAstConfigurationFileByHostIdxKey key = schema.getFactoryConfigurationFile().newHostIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredHostNodeId(HostNodeId);

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

    public CFAstConfigurationFileBuff readDerivedByUNameIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId, String FileFullName) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerivedByUNameIdx() ";
        CFAstConfigurationFileByUNameIdxKey key = schema.getFactoryConfigurationFile().newUNameIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredHostNodeId(HostNodeId);
        key.setRequiredFileFullName(FileFullName);

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

    public CFAstConfigurationFileBuff readDerivedByIdIdx(CFAstAuthorization Authorization, long ClusterId,
            long Id) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerivedByIdIdx() ";
        CFAstConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredId(Id);

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

    public CFAstConfigurationFileBuff readBuff(CFAstAuthorization Authorization, CFAstConfigurationFilePKey PKey) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuff() ";
        CFAstConfigurationFileBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("CONF"))) {
            buff = null;
        }
        return (buff);
    }

    public CFAstConfigurationFileBuff lockBuff(CFAstAuthorization Authorization, CFAstConfigurationFilePKey PKey) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuff() ";
        CFAstConfigurationFileBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("CONF"))) {
            buff = null;
        }
        return (buff);
    }

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

    public CFAstConfigurationFileBuff readBuffByIdIdx(CFAstAuthorization Authorization, long ClusterId, long Id) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByIdIdx() ";
        CFAstConfigurationFileBuff buff = readDerivedByIdIdx(Authorization, ClusterId, Id);
        if ((buff != null) && buff.getClassCode().equals("CONF")) {
            return ((CFAstConfigurationFileBuff) buff);
        } else {
            return (null);
        }
    }

    public CFAstConfigurationFileBuff[] readBuffByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByClusterIdx() ";
        CFAstConfigurationFileBuff buff;
        ArrayList<CFAstConfigurationFileBuff> filteredList = new ArrayList<CFAstConfigurationFileBuff>();
        CFAstConfigurationFileBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("CONF")) {
                filteredList.add((CFAstConfigurationFileBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstConfigurationFileBuff[0]));
    }

    public CFAstConfigurationFileBuff[] readBuffByHostIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByHostIdx() ";
        CFAstConfigurationFileBuff buff;
        ArrayList<CFAstConfigurationFileBuff> filteredList = new ArrayList<CFAstConfigurationFileBuff>();
        CFAstConfigurationFileBuff[] buffList = readDerivedByHostIdx(Authorization, ClusterId, HostNodeId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("CONF")) {
                filteredList.add((CFAstConfigurationFileBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstConfigurationFileBuff[0]));
    }

    public CFAstConfigurationFileBuff readBuffByUNameIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId, String FileFullName) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByUNameIdx() ";
        CFAstConfigurationFileBuff buff = readDerivedByUNameIdx(Authorization, ClusterId, HostNodeId, FileFullName);
        if ((buff != null) && buff.getClassCode().equals("CONF")) {
            return ((CFAstConfigurationFileBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateConfigurationFile(CFAstAuthorization Authorization, CFAstConfigurationFileBuff Buff) {
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setClassCode(Buff.getClassCode());
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAstConfigurationFileBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateConfigurationFile", "Existing record not found", "ConfigurationFile", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "updateConfigurationFile", pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        CFAstConfigurationFileByClusterIdxKey existingKeyClusterIdx = schema.getFactoryConfigurationFile()
                .newClusterIdxKey();
        existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFAstConfigurationFileByClusterIdxKey newKeyClusterIdx = schema.getFactoryConfigurationFile()
                .newClusterIdxKey();
        newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFAstConfigurationFileByHostIdxKey existingKeyHostIdx = schema.getFactoryConfigurationFile()
                .newHostIdxKey();
        existingKeyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

        CFAstConfigurationFileByHostIdxKey newKeyHostIdx = schema.getFactoryConfigurationFile().newHostIdxKey();
        newKeyHostIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyHostIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());

        CFAstConfigurationFileByUNameIdxKey existingKeyUNameIdx = schema.getFactoryConfigurationFile()
                .newUNameIdxKey();
        existingKeyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyUNameIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
        existingKeyUNameIdx.setRequiredFileFullName(existing.getRequiredFileFullName());

        CFAstConfigurationFileByUNameIdxKey newKeyUNameIdx = schema.getFactoryConfigurationFile().newUNameIdxKey();
        newKeyUNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyUNameIdx.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
        newKeyUNameIdx.setRequiredFileFullName(Buff.getRequiredFileFullName());

        // Check unique indexes

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

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableCluster().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredClusterId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateConfigurationFile", "Owner", "Cluster", "Cluster", null);
                }
            }
        }

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableHostNode().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredHostNodeId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateConfigurationFile", "Container", "HostNode", "HostNode", null);
                }
            }
        }

        // Update is valid

        SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdict;

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

        subdict = dictByClusterIdx.get(existingKeyClusterIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByClusterIdx.containsKey(newKeyClusterIdx)) {
            subdict = dictByClusterIdx.get(newKeyClusterIdx);
        } else {
            subdict = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
            dictByClusterIdx.put(newKeyClusterIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByHostIdx.get(existingKeyHostIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByHostIdx.containsKey(newKeyHostIdx)) {
            subdict = dictByHostIdx.get(newKeyHostIdx);
        } else {
            subdict = new TreeMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff>();
            dictByHostIdx.put(newKeyHostIdx, subdict);
        }
        subdict.put(pkey, Buff);

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

    }

    public void deleteConfigurationFile(CFAstAuthorization Authorization, CFAstConfigurationFileBuff Buff) {
        final String S_ProcName = "CFAstRamConfigurationFileTable.deleteConfigurationFile() ";
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setClassCode(Buff.getClassCode());
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAstConfigurationFileBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(),
                    "deleteConfigurationFile", pkey);
        }
        CFAstConfigurationFileByClusterIdxKey keyClusterIdx = schema.getFactoryConfigurationFile()
                .newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFAstConfigurationFileByHostIdxKey keyHostIdx = schema.getFactoryConfigurationFile().newHostIdxKey();
        keyHostIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyHostIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());

        CFAstConfigurationFileByUNameIdxKey keyUNameIdx = schema.getFactoryConfigurationFile().newUNameIdxKey();
        keyUNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyUNameIdx.setRequiredHostNodeId(existing.getRequiredHostNodeId());
        keyUNameIdx.setRequiredFileFullName(existing.getRequiredFileFullName());

        // Validate reverse foreign keys

        if (schema.getTableAsteriskConf().readDerivedByIdIdx(Authorization, existing.getRequiredClusterId(),
                existing.getRequiredId()) != null) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteConfigurationFile", "Superclass", "SuperClass", "AsteriskConf", pkey);
        }

        if (schema.getTableSipConf().readDerivedByIdIdx(Authorization, existing.getRequiredClusterId(),
                existing.getRequiredId()) != null) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteConfigurationFile", "Superclass", "SuperClass", "SipConf", pkey);
        }

        if (schema.getTableExtensionsConf().readDerivedByIdIdx(Authorization, existing.getRequiredClusterId(),
                existing.getRequiredId()) != null) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteConfigurationFile", "Superclass", "SuperClass", "ExtensionsConf", pkey);
        }

        if (schema.getTableVoicemailConf().readDerivedByIdIdx(Authorization, existing.getRequiredClusterId(),
                existing.getRequiredId()) != null) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteConfigurationFile", "Superclass", "SuperClass", "VoicemailConf", pkey);
        }

        if (schema.getTableExtConfigConf().readDerivedByIdIdx(Authorization, existing.getRequiredClusterId(),
                existing.getRequiredId()) != null) {
            throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(),
                    "deleteConfigurationFile", "Superclass", "SuperClass", "ExtConfigConf", pkey);
        }

        // Delete is valid

        SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByClusterIdx.get(keyClusterIdx);
        subdict.remove(pkey);

        subdict = dictByHostIdx.get(keyHostIdx);
        subdict.remove(pkey);

        dictByUNameIdx.remove(keyUNameIdx);

    }

    public void deleteConfigurationFileByIdIdx(CFAstAuthorization Authorization, long argClusterId, long argId) {
        CFAstConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredId(argId);
        deleteConfigurationFileByIdIdx(Authorization, key);
    }

    public void deleteConfigurationFileByIdIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFilePKey argKey) {
        final String S_ProcName = "deleteConfigurationFileByIdIdx";
        CFAstConfigurationFileBuff cur;
        LinkedList<CFAstConfigurationFileBuff> matchSet = new LinkedList<CFAstConfigurationFileBuff>();
        Iterator<CFAstConfigurationFileBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstConfigurationFileBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            String subClassCode = cur.getClassCode();
            if ("CONF".equals(subClassCode)) {
                schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, cur);
            } else if ("CASC".equals(subClassCode)) {
                schema.getTableAsteriskConf().deleteAsteriskConf(Authorization, (CFAstAsteriskConfBuff) cur);
            } else if ("CSIP".equals(subClassCode)) {
                schema.getTableSipConf().deleteSipConf(Authorization, (CFAstSipConfBuff) cur);
            } else if ("CEXT".equals(subClassCode)) {
                schema.getTableExtensionsConf().deleteExtensionsConf(Authorization, (CFAstExtensionsConfBuff) cur);
            } else if ("CVOM".equals(subClassCode)) {
                schema.getTableVoicemailConf().deleteVoicemailConf(Authorization, (CFAstVoicemailConfBuff) cur);
            } else if ("CECC".equals(subClassCode)) {
                schema.getTableExtConfigConf().deleteExtConfigConf(Authorization, (CFAstExtConfigConfBuff) cur);
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                        "subClassCode", cur,
                        "Instance of or subclass of ConfigurationFile must not be \"" + subClassCode + "\"");
            }
        }
    }

    public void deleteConfigurationFileByClusterIdx(CFAstAuthorization Authorization, long argClusterId) {
        CFAstConfigurationFileByClusterIdxKey key = schema.getFactoryConfigurationFile().newClusterIdxKey();
        key.setRequiredClusterId(argClusterId);
        deleteConfigurationFileByClusterIdx(Authorization, key);
    }

    public void deleteConfigurationFileByClusterIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByClusterIdxKey argKey) {
        final String S_ProcName = "deleteConfigurationFileByClusterIdx";
        CFAstConfigurationFileBuff cur;
        LinkedList<CFAstConfigurationFileBuff> matchSet = new LinkedList<CFAstConfigurationFileBuff>();
        Iterator<CFAstConfigurationFileBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstConfigurationFileBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            String subClassCode = cur.getClassCode();
            if ("CONF".equals(subClassCode)) {
                schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, cur);
            } else if ("CASC".equals(subClassCode)) {
                schema.getTableAsteriskConf().deleteAsteriskConf(Authorization, (CFAstAsteriskConfBuff) cur);
            } else if ("CSIP".equals(subClassCode)) {
                schema.getTableSipConf().deleteSipConf(Authorization, (CFAstSipConfBuff) cur);
            } else if ("CEXT".equals(subClassCode)) {
                schema.getTableExtensionsConf().deleteExtensionsConf(Authorization, (CFAstExtensionsConfBuff) cur);
            } else if ("CVOM".equals(subClassCode)) {
                schema.getTableVoicemailConf().deleteVoicemailConf(Authorization, (CFAstVoicemailConfBuff) cur);
            } else if ("CECC".equals(subClassCode)) {
                schema.getTableExtConfigConf().deleteExtConfigConf(Authorization, (CFAstExtConfigConfBuff) cur);
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                        "subClassCode", cur,
                        "Instance of or subclass of ConfigurationFile must not be \"" + subClassCode + "\"");
            }
        }
    }

    public void deleteConfigurationFileByHostIdx(CFAstAuthorization Authorization, long argClusterId,
            long argHostNodeId) {
        CFAstConfigurationFileByHostIdxKey key = schema.getFactoryConfigurationFile().newHostIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredHostNodeId(argHostNodeId);
        deleteConfigurationFileByHostIdx(Authorization, key);
    }

    public void deleteConfigurationFileByHostIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByHostIdxKey argKey) {
        final String S_ProcName = "deleteConfigurationFileByHostIdx";
        CFAstConfigurationFileBuff cur;
        LinkedList<CFAstConfigurationFileBuff> matchSet = new LinkedList<CFAstConfigurationFileBuff>();
        Iterator<CFAstConfigurationFileBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstConfigurationFileBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            String subClassCode = cur.getClassCode();
            if ("CONF".equals(subClassCode)) {
                schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, cur);
            } else if ("CASC".equals(subClassCode)) {
                schema.getTableAsteriskConf().deleteAsteriskConf(Authorization, (CFAstAsteriskConfBuff) cur);
            } else if ("CSIP".equals(subClassCode)) {
                schema.getTableSipConf().deleteSipConf(Authorization, (CFAstSipConfBuff) cur);
            } else if ("CEXT".equals(subClassCode)) {
                schema.getTableExtensionsConf().deleteExtensionsConf(Authorization, (CFAstExtensionsConfBuff) cur);
            } else if ("CVOM".equals(subClassCode)) {
                schema.getTableVoicemailConf().deleteVoicemailConf(Authorization, (CFAstVoicemailConfBuff) cur);
            } else if ("CECC".equals(subClassCode)) {
                schema.getTableExtConfigConf().deleteExtConfigConf(Authorization, (CFAstExtConfigConfBuff) cur);
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                        "subClassCode", cur,
                        "Instance of or subclass of ConfigurationFile must not be \"" + subClassCode + "\"");
            }
        }
    }

    public void deleteConfigurationFileByUNameIdx(CFAstAuthorization Authorization, long argClusterId,
            long argHostNodeId, String argFileFullName) {
        CFAstConfigurationFileByUNameIdxKey key = schema.getFactoryConfigurationFile().newUNameIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredHostNodeId(argHostNodeId);
        key.setRequiredFileFullName(argFileFullName);
        deleteConfigurationFileByUNameIdx(Authorization, key);
    }

    public void deleteConfigurationFileByUNameIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByUNameIdxKey argKey) {
        final String S_ProcName = "deleteConfigurationFileByUNameIdx";
        CFAstConfigurationFileBuff cur;
        LinkedList<CFAstConfigurationFileBuff> matchSet = new LinkedList<CFAstConfigurationFileBuff>();
        Iterator<CFAstConfigurationFileBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstConfigurationFileBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            String subClassCode = cur.getClassCode();
            if ("CONF".equals(subClassCode)) {
                schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, cur);
            } else if ("CASC".equals(subClassCode)) {
                schema.getTableAsteriskConf().deleteAsteriskConf(Authorization, (CFAstAsteriskConfBuff) cur);
            } else if ("CSIP".equals(subClassCode)) {
                schema.getTableSipConf().deleteSipConf(Authorization, (CFAstSipConfBuff) cur);
            } else if ("CEXT".equals(subClassCode)) {
                schema.getTableExtensionsConf().deleteExtensionsConf(Authorization, (CFAstExtensionsConfBuff) cur);
            } else if ("CVOM".equals(subClassCode)) {
                schema.getTableVoicemailConf().deleteVoicemailConf(Authorization, (CFAstVoicemailConfBuff) cur);
            } else if ("CECC".equals(subClassCode)) {
                schema.getTableExtConfigConf().deleteExtConfigConf(Authorization, (CFAstExtConfigConfBuff) cur);
            } else {
                throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                        "subClassCode", cur,
                        "Instance of or subclass of ConfigurationFile must not be \"" + subClassCode + "\"");
            }
        }
    }

    public CFAstCursor openConfigurationFileCursorAll(CFAstAuthorization Authorization) {
        CFAstCursor cursor = new CFAstRamConfigurationFileCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public CFAstCursor openConfigurationFileCursorByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        CFAstCursor cursor;
        CFAstConfigurationFileByClusterIdxKey key = schema.getFactoryConfigurationFile().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

        if (dictByClusterIdx.containsKey(key)) {
            SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdictClusterIdx = dictByClusterIdx
                    .get(key);
            cursor = new CFAstRamConfigurationFileCursor(Authorization, schema, subdictClusterIdx.values());
        } else {
            cursor = new CFAstRamConfigurationFileCursor(Authorization, schema,
                    new ArrayList<CFAstConfigurationFileBuff>());
        }
        return (cursor);
    }

    public CFAstCursor openConfigurationFileCursorByHostIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        CFAstCursor cursor;
        CFAstConfigurationFileByHostIdxKey key = schema.getFactoryConfigurationFile().newHostIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredHostNodeId(HostNodeId);

        if (dictByHostIdx.containsKey(key)) {
            SortedMap<CFAstConfigurationFilePKey, CFAstConfigurationFileBuff> subdictHostIdx = dictByHostIdx
                    .get(key);
            cursor = new CFAstRamConfigurationFileCursor(Authorization, schema, subdictHostIdx.values());
        } else {
            cursor = new CFAstRamConfigurationFileCursor(Authorization, schema,
                    new ArrayList<CFAstConfigurationFileBuff>());
        }
        return (cursor);
    }

    public void closeConfigurationFileCursor(CFAstCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public CFAstConfigurationFileBuff nextConfigurationFileCursor(CFAstCursor Cursor) {
        CFAstRamConfigurationFileCursor cursor = (CFAstRamConfigurationFileCursor) Cursor;
        CFAstConfigurationFileBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public CFAstConfigurationFileBuff prevConfigurationFileCursor(CFAstCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFAstConfigurationFileBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextConfigurationFileCursor(Cursor);
        }
        return (rec);
    }

    public CFAstConfigurationFileBuff firstConfigurationFileCursor(CFAstCursor Cursor) {
        int targetRowIdx = 1;
        CFAstConfigurationFileBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextConfigurationFileCursor(Cursor);
        }
        return (rec);
    }

    public CFAstConfigurationFileBuff lastConfigurationFileCursor(CFAstCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(),
                "lastConfigurationFileCursor");
    }

    public CFAstConfigurationFileBuff nthConfigurationFileCursor(CFAstCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFAstConfigurationFileBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextConfigurationFileCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}