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

Java tutorial

Introduction

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

Source

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

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

/*
 *   CFAstRamAsteriskConfTable in-memory RAM DbIO implementation
 *   for AsteriskConf.
 */
public class CFAstRamAsteriskConfTable implements ICFAstAsteriskConfTable {
    private CFAstRamSchema schema;
    private Map<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> dictByPKey = new HashMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>();
    private SortedMap<CFAstAsteriskConfByConfClusterIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>> dictByConfClusterIdx = new TreeMap<CFAstAsteriskConfByConfClusterIdxKey, SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>>();

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

    public void createAsteriskConf(CFAstAuthorization Authorization, CFAstAsteriskConfBuff Buff) {
        schema.getTableConfigurationFile().createConfigurationFile(Authorization, Buff);
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setClassCode(Buff.getClassCode());
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAstAsteriskConfByConfClusterIdxKey keyConfClusterIdx = schema.getFactoryAsteriskConf()
                .newConfClusterIdxKey();
        keyConfClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        // Validate unique indexes

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

        // Validate foreign keys

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

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> subdictConfClusterIdx;
        if (dictByConfClusterIdx.containsKey(keyConfClusterIdx)) {
            subdictConfClusterIdx = dictByConfClusterIdx.get(keyConfClusterIdx);
        } else {
            subdictConfClusterIdx = new TreeMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>();
            dictByConfClusterIdx.put(keyConfClusterIdx, subdictConfClusterIdx);
        }
        subdictConfClusterIdx.put(pkey, Buff);

    }

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

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

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

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

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

    public CFAstAsteriskConfBuff readDerivedByUNameIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId, String FileFullName) {
        final String S_ProcName = "CFAstRamConfigurationFile.readDerivedByUNameIdx() ";
        CFAstConfigurationFileBuff buff = schema.getTableConfigurationFile().readDerivedByUNameIdx(Authorization,
                ClusterId, HostNodeId, FileFullName);
        if (buff == null) {
            return (null);
        } else if (buff instanceof CFAstAsteriskConfBuff) {
            return ((CFAstAsteriskConfBuff) buff);
        } else {
            return (null);
        }
    }

    public CFAstAsteriskConfBuff[] readDerivedByConfClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFAstRamAsteriskConf.readDerivedByConfClusterIdx() ";
        CFAstAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

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

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

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

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

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

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

    public CFAstAsteriskConfBuff[] readBuffByClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByClusterIdx() ";
        CFAstConfigurationFileBuff buff;
        ArrayList<CFAstAsteriskConfBuff> filteredList = new ArrayList<CFAstAsteriskConfBuff>();
        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((CFAstAsteriskConfBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstAsteriskConfBuff[0]));
    }

    public CFAstAsteriskConfBuff[] readBuffByHostIdx(CFAstAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        final String S_ProcName = "CFAstRamConfigurationFile.readBuffByHostIdx() ";
        CFAstConfigurationFileBuff buff;
        ArrayList<CFAstAsteriskConfBuff> filteredList = new ArrayList<CFAstAsteriskConfBuff>();
        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((CFAstAsteriskConfBuff) buff);
            }
        }
        return (filteredList.toArray(new CFAstAsteriskConfBuff[0]));
    }

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

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

    public void updateAsteriskConf(CFAstAuthorization Authorization, CFAstAsteriskConfBuff Buff) {
        schema.getTableConfigurationFile().updateConfigurationFile(Authorization, Buff);
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAstAsteriskConfBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateAsteriskConf", "Existing record not found", "AsteriskConf", pkey);
        }
        CFAstAsteriskConfByConfClusterIdxKey existingKeyConfClusterIdx = schema.getFactoryAsteriskConf()
                .newConfClusterIdxKey();
        existingKeyConfClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFAstAsteriskConfByConfClusterIdxKey newKeyConfClusterIdx = schema.getFactoryAsteriskConf()
                .newConfClusterIdxKey();
        newKeyConfClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        // Check unique indexes

        // Validate foreign keys

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization,
                        Buff.getRequiredClusterId(), Buff.getRequiredId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateAsteriskConf", "Superclass", "SuperClass", "ConfigurationFile", null);
                }
            }
        }

        // Update is valid

        SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> subdict;

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

        subdict = dictByConfClusterIdx.get(existingKeyConfClusterIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByConfClusterIdx.containsKey(newKeyConfClusterIdx)) {
            subdict = dictByConfClusterIdx.get(newKeyConfClusterIdx);
        } else {
            subdict = new TreeMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff>();
            dictByConfClusterIdx.put(newKeyConfClusterIdx, subdict);
        }
        subdict.put(pkey, Buff);

    }

    public void deleteAsteriskConf(CFAstAuthorization Authorization, CFAstAsteriskConfBuff Buff) {
        final String S_ProcName = "CFAstRamAsteriskConfTable.deleteAsteriskConf() ";
        CFAstConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredId(Buff.getRequiredId());
        CFAstAsteriskConfBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteAsteriskConf",
                    pkey);
        }
        CFAstAsteriskConfByConfClusterIdxKey keyConfClusterIdx = schema.getFactoryAsteriskConf()
                .newConfClusterIdxKey();
        keyConfClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> subdict;

        dictByPKey.remove(pkey);

        subdict = dictByConfClusterIdx.get(keyConfClusterIdx);
        subdict.remove(pkey);

        schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, Buff);
    }

    public void deleteAsteriskConfByConfClusterIdx(CFAstAuthorization Authorization, long argClusterId) {
        CFAstAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey();
        key.setRequiredClusterId(argClusterId);
        deleteAsteriskConfByConfClusterIdx(Authorization, key);
    }

    public void deleteAsteriskConfByConfClusterIdx(CFAstAuthorization Authorization,
            CFAstAsteriskConfByConfClusterIdxKey argKey) {
        CFAstAsteriskConfBuff cur;
        LinkedList<CFAstAsteriskConfBuff> matchSet = new LinkedList<CFAstAsteriskConfBuff>();
        Iterator<CFAstAsteriskConfBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstAsteriskConfBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteAsteriskConf(Authorization, cur);
        }
    }

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

    public void deleteAsteriskConfByIdIdx(CFAstAuthorization Authorization, CFAstConfigurationFilePKey argKey) {
        CFAstAsteriskConfBuff cur;
        LinkedList<CFAstAsteriskConfBuff> matchSet = new LinkedList<CFAstAsteriskConfBuff>();
        Iterator<CFAstAsteriskConfBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstAsteriskConfBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteAsteriskConf(Authorization, cur);
        }
    }

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

    public void deleteAsteriskConfByClusterIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByClusterIdxKey argKey) {
        CFAstAsteriskConfBuff cur;
        LinkedList<CFAstAsteriskConfBuff> matchSet = new LinkedList<CFAstAsteriskConfBuff>();
        Iterator<CFAstAsteriskConfBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstAsteriskConfBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteAsteriskConf(Authorization, cur);
        }
    }

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

    public void deleteAsteriskConfByHostIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByHostIdxKey argKey) {
        CFAstAsteriskConfBuff cur;
        LinkedList<CFAstAsteriskConfBuff> matchSet = new LinkedList<CFAstAsteriskConfBuff>();
        Iterator<CFAstAsteriskConfBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstAsteriskConfBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteAsteriskConf(Authorization, cur);
        }
    }

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

    public void deleteAsteriskConfByUNameIdx(CFAstAuthorization Authorization,
            CFAstConfigurationFileByUNameIdxKey argKey) {
        CFAstAsteriskConfBuff cur;
        LinkedList<CFAstAsteriskConfBuff> matchSet = new LinkedList<CFAstAsteriskConfBuff>();
        Iterator<CFAstAsteriskConfBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFAstAsteriskConfBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteAsteriskConf(Authorization, cur);
        }
    }

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

    public CFAstCursor openAsteriskConfCursorByConfClusterIdx(CFAstAuthorization Authorization, long ClusterId) {
        CFAstCursor cursor;
        CFAstAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

        if (dictByConfClusterIdx.containsKey(key)) {
            SortedMap<CFAstConfigurationFilePKey, CFAstAsteriskConfBuff> subdictConfClusterIdx = dictByConfClusterIdx
                    .get(key);
            cursor = new CFAstRamAsteriskConfCursor(Authorization, schema, subdictConfClusterIdx.values());
        } else {
            cursor = new CFAstRamAsteriskConfCursor(Authorization, schema, new ArrayList<CFAstAsteriskConfBuff>());
        }
        return (cursor);
    }

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

    public CFAstAsteriskConfBuff nextAsteriskConfCursor(CFAstCursor Cursor) {
        CFAstRamAsteriskConfCursor cursor = (CFAstRamAsteriskConfCursor) Cursor;
        CFAstAsteriskConfBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public CFAstAsteriskConfBuff firstAsteriskConfCursor(CFAstCursor Cursor) {
        int targetRowIdx = 1;
        CFAstAsteriskConfBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextAsteriskConfCursor(Cursor);
        }
        return (rec);
    }

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

    public CFAstAsteriskConfBuff nthAsteriskConfCursor(CFAstCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFAstAsteriskConfBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextAsteriskConfCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}