net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskRam.CFAsteriskRamHostNodeTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskRam.CFAsteriskRamHostNodeTable.java

Source

// Description: Java 8 in-memory RAM DbIO implementation for HostNode.

/*
 *   Code Factory Asterisk 11 Configuration Model
 *
 *   Copyright (c) 2014-2015 Mark Sobkow
 *   
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *   
 *       http://www.apache.org/licenses/LICENSE-2.0
 *   
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *   
 */

package net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskRam;

import java.sql.*;
import java.util.*;
import org.apache.commons.codec.binary.Base64;
import net.sourceforge.msscodefactory.cflib.v2_3.CFLib.*;
import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurity.*;
import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternet.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsterisk.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*;
import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurityObj.*;
import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternetObj.*;
import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*;

/*
 *   CFAsteriskRamHostNodeTable in-memory RAM DbIO implementation
 *   for HostNode.
 */
public class CFAsteriskRamHostNodeTable implements ICFAsteriskHostNodeTable {
    private ICFAsteriskSchema schema;
    private Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> dictByPKey = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
    private Map<CFSecurityHostNodeByClusterIdxKey, Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>> dictByClusterIdx = new HashMap<CFSecurityHostNodeByClusterIdxKey, Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>>();
    private Map<CFSecurityHostNodeByUDescrIdxKey, CFSecurityHostNodeBuff> dictByUDescrIdx = new HashMap<CFSecurityHostNodeByUDescrIdxKey, CFSecurityHostNodeBuff>();
    private Map<CFSecurityHostNodeByHostNameIdxKey, CFSecurityHostNodeBuff> dictByHostNameIdx = new HashMap<CFSecurityHostNodeByHostNameIdxKey, CFSecurityHostNodeBuff>();

    public CFAsteriskRamHostNodeTable(ICFAsteriskSchema argSchema) {
        schema = argSchema;
    }

    public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
        final String S_ProcName = "createHostNode";
        CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredHostNodeId(((CFAsteriskRamClusterTable) schema.getTableCluster())
                .nextHostNodeIdGen(Authorization, Buff.getRequiredClusterId()));
        Buff.setRequiredClusterId(pkey.getRequiredClusterId());
        Buff.setRequiredHostNodeId(pkey.getRequiredHostNodeId());
        CFSecurityHostNodeByClusterIdxKey keyClusterIdx = schema.getFactoryHostNode().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
        keyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

        CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx = schema.getFactoryHostNode().newHostNameIdxKey();
        keyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

        // Validate unique indexes

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

        if (dictByUDescrIdx.containsKey(keyUDescrIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName,
                    "HostNodeUDescrIdx", keyUDescrIdx);
        }

        if (dictByHostNameIdx.containsKey(keyHostNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), S_ProcName,
                    "HostNodeUHostNameIdx", keyHostNameIdx);
        }

        // Validate foreign keys

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

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx;
        if (dictByClusterIdx.containsKey(keyClusterIdx)) {
            subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
        } else {
            subdictClusterIdx = new HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
            dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
        }
        subdictClusterIdx.put(pkey, Buff);

        dictByUDescrIdx.put(keyUDescrIdx, Buff);

        dictByHostNameIdx.put(keyHostNameIdx, Buff);

    }

    public CFSecurityHostNodeBuff readDerived(CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerived";
        CFSecurityHostNodePKey key = schema.getFactoryHostNode().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredHostNodeId(PKey.getRequiredHostNodeId());
        CFSecurityHostNodeBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFSecurityHostNodeBuff lockDerived(CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerived";
        CFSecurityHostNodePKey key = schema.getFactoryHostNode().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredHostNodeId(PKey.getRequiredHostNodeId());
        CFSecurityHostNodeBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public CFSecurityHostNodeBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerivedByClusterIdx";
        CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFSecurityHostNodeBuff readDerivedByUDescrIdx(CFSecurityAuthorization Authorization, long ClusterId,
            String Description) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerivedByUDescrIdx";
        CFSecurityHostNodeByUDescrIdxKey key = schema.getFactoryHostNode().newUDescrIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredDescription(Description);

        CFSecurityHostNodeBuff buff;
        if (dictByUDescrIdx.containsKey(key)) {
            buff = dictByUDescrIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFSecurityHostNodeBuff readDerivedByHostNameIdx(CFSecurityAuthorization Authorization, long ClusterId,
            String HostName) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerivedByHostNameIdx";
        CFSecurityHostNodeByHostNameIdxKey key = schema.getFactoryHostNode().newHostNameIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredHostName(HostName);

        CFSecurityHostNodeBuff buff;
        if (dictByHostNameIdx.containsKey(key)) {
            buff = dictByHostNameIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFSecurityHostNodeBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        final String S_ProcName = "CFAsteriskRamHostNode.readDerivedByIdIdx() ";
        CFSecurityHostNodePKey key = schema.getFactoryHostNode().newPKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredHostNodeId(HostNodeId);

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

    public CFSecurityHostNodeBuff readBuff(CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
        final String S_ProcName = "CFAsteriskRamHostNode.readBuff";
        CFSecurityHostNodeBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("HSND"))) {
            buff = null;
        }
        return (buff);
    }

    public CFSecurityHostNodeBuff lockBuff(CFSecurityAuthorization Authorization, CFSecurityHostNodePKey PKey) {
        final String S_ProcName = "lockBuff";
        CFSecurityHostNodeBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("HSND"))) {
            buff = null;
        }
        return (buff);
    }

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

    public CFSecurityHostNodeBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long ClusterId,
            long HostNodeId) {
        final String S_ProcName = "CFAsteriskRamHostNode.readBuffByIdIdx() ";
        CFSecurityHostNodeBuff buff = readDerivedByIdIdx(Authorization, ClusterId, HostNodeId);
        if ((buff != null) && buff.getClassCode().equals("HSND")) {
            return ((CFSecurityHostNodeBuff) buff);
        } else {
            return (null);
        }
    }

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

    public CFSecurityHostNodeBuff readBuffByUDescrIdx(CFSecurityAuthorization Authorization, long ClusterId,
            String Description) {
        final String S_ProcName = "CFAsteriskRamHostNode.readBuffByUDescrIdx() ";
        CFSecurityHostNodeBuff buff = readDerivedByUDescrIdx(Authorization, ClusterId, Description);
        if ((buff != null) && buff.getClassCode().equals("HSND")) {
            return ((CFSecurityHostNodeBuff) buff);
        } else {
            return (null);
        }
    }

    public CFSecurityHostNodeBuff readBuffByHostNameIdx(CFSecurityAuthorization Authorization, long ClusterId,
            String HostName) {
        final String S_ProcName = "CFAsteriskRamHostNode.readBuffByHostNameIdx() ";
        CFSecurityHostNodeBuff buff = readDerivedByHostNameIdx(Authorization, ClusterId, HostName);
        if ((buff != null) && buff.getClassCode().equals("HSND")) {
            return ((CFSecurityHostNodeBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
        CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
        CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateHostNode",
                    "Existing record not found", "HostNode", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateHostNode",
                    pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        CFSecurityHostNodeByClusterIdxKey existingKeyClusterIdx = schema.getFactoryHostNode().newClusterIdxKey();
        existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFSecurityHostNodeByClusterIdxKey newKeyClusterIdx = schema.getFactoryHostNode().newClusterIdxKey();
        newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFSecurityHostNodeByUDescrIdxKey existingKeyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
        existingKeyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

        CFSecurityHostNodeByUDescrIdxKey newKeyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
        newKeyUDescrIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyUDescrIdx.setRequiredDescription(Buff.getRequiredDescription());

        CFSecurityHostNodeByHostNameIdxKey existingKeyHostNameIdx = schema.getFactoryHostNode().newHostNameIdxKey();
        existingKeyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

        CFSecurityHostNodeByHostNameIdxKey newKeyHostNameIdx = schema.getFactoryHostNode().newHostNameIdxKey();
        newKeyHostNameIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyHostNameIdx.setRequiredHostName(Buff.getRequiredHostName());

        // Check unique indexes

        if (!existingKeyUDescrIdx.equals(newKeyUDescrIdx)) {
            if (dictByUDescrIdx.containsKey(newKeyUDescrIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateHostNode", "HostNodeUDescrIdx", newKeyUDescrIdx);
            }
        }

        if (!existingKeyHostNameIdx.equals(newKeyHostNameIdx)) {
            if (dictByHostNameIdx.containsKey(newKeyHostNameIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateHostNode", "HostNodeUHostNameIdx", newKeyHostNameIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

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

        // Update is valid

        Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> 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 HashMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff>();
            dictByClusterIdx.put(newKeyClusterIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByUDescrIdx.remove(existingKeyUDescrIdx);
        dictByUDescrIdx.put(newKeyUDescrIdx, Buff);

        dictByHostNameIdx.remove(existingKeyHostNameIdx);
        dictByHostNameIdx.put(newKeyHostNameIdx, Buff);

    }

    public void deleteHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
        final String S_ProcName = "CFAsteriskRamHostNodeTable.deleteHostNode() ";
        CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredHostNodeId(Buff.getRequiredHostNodeId());
        CFSecurityHostNodeBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteHostNode",
                    pkey);
        }
        CFSecurityHostNodeByClusterIdxKey keyClusterIdx = schema.getFactoryHostNode().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFSecurityHostNodeByUDescrIdxKey keyUDescrIdx = schema.getFactoryHostNode().newUDescrIdxKey();
        keyUDescrIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyUDescrIdx.setRequiredDescription(existing.getRequiredDescription());

        CFSecurityHostNodeByHostNameIdxKey keyHostNameIdx = schema.getFactoryHostNode().newHostNameIdxKey();
        keyHostNameIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyHostNameIdx.setRequiredHostName(existing.getRequiredHostName());

        // Validate reverse foreign keys

        // Delete is valid

        schema.getTableService().deleteServiceByHostIdx(Authorization, Buff.getRequiredClusterId(),
                Buff.getRequiredHostNodeId());
        schema.getTableConfigurationFile().deleteConfigurationFileByHostIdx(Authorization,
                Buff.getRequiredClusterId(), Buff.getRequiredHostNodeId());
        Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdict;

        dictByPKey.remove(pkey);

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

        dictByUDescrIdx.remove(keyUDescrIdx);

        dictByHostNameIdx.remove(keyHostNameIdx);

    }

    public void deleteHostNodeByIdIdx(CFSecurityAuthorization Authorization, long argClusterId,
            long argHostNodeId) {
        CFSecurityHostNodePKey key = schema.getFactoryHostNode().newPKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredHostNodeId(argHostNodeId);
        deleteHostNodeByIdIdx(Authorization, key);
    }

    public void deleteHostNodeByIdIdx(CFSecurityAuthorization Authorization, CFSecurityHostNodePKey argKey) {
        CFSecurityHostNodeBuff cur;
        LinkedList<CFSecurityHostNodeBuff> matchSet = new LinkedList<CFSecurityHostNodeBuff>();
        Iterator<CFSecurityHostNodeBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecurityHostNodeBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteHostNode(Authorization, cur);
        }
    }

    public void deleteHostNodeByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
        CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
        key.setRequiredClusterId(argClusterId);
        deleteHostNodeByClusterIdx(Authorization, key);
    }

    public void deleteHostNodeByClusterIdx(CFSecurityAuthorization Authorization,
            CFSecurityHostNodeByClusterIdxKey argKey) {
        CFSecurityHostNodeBuff cur;
        LinkedList<CFSecurityHostNodeBuff> matchSet = new LinkedList<CFSecurityHostNodeBuff>();
        Iterator<CFSecurityHostNodeBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecurityHostNodeBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteHostNode(Authorization, cur);
        }
    }

    public void deleteHostNodeByUDescrIdx(CFSecurityAuthorization Authorization, long argClusterId,
            String argDescription) {
        CFSecurityHostNodeByUDescrIdxKey key = schema.getFactoryHostNode().newUDescrIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredDescription(argDescription);
        deleteHostNodeByUDescrIdx(Authorization, key);
    }

    public void deleteHostNodeByUDescrIdx(CFSecurityAuthorization Authorization,
            CFSecurityHostNodeByUDescrIdxKey argKey) {
        CFSecurityHostNodeBuff cur;
        LinkedList<CFSecurityHostNodeBuff> matchSet = new LinkedList<CFSecurityHostNodeBuff>();
        Iterator<CFSecurityHostNodeBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecurityHostNodeBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteHostNode(Authorization, cur);
        }
    }

    public void deleteHostNodeByHostNameIdx(CFSecurityAuthorization Authorization, long argClusterId,
            String argHostName) {
        CFSecurityHostNodeByHostNameIdxKey key = schema.getFactoryHostNode().newHostNameIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredHostName(argHostName);
        deleteHostNodeByHostNameIdx(Authorization, key);
    }

    public void deleteHostNodeByHostNameIdx(CFSecurityAuthorization Authorization,
            CFSecurityHostNodeByHostNameIdxKey argKey) {
        CFSecurityHostNodeBuff cur;
        LinkedList<CFSecurityHostNodeBuff> matchSet = new LinkedList<CFSecurityHostNodeBuff>();
        Iterator<CFSecurityHostNodeBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecurityHostNodeBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteHostNode(Authorization, cur);
        }
    }

    public CFSecurityCursor openHostNodeCursorAll(CFSecurityAuthorization Authorization) {
        CFSecurityCursor cursor = new CFAsteriskRamHostNodeCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public CFSecurityCursor openHostNodeCursorByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) {
        CFSecurityCursor cursor;
        CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

        if (dictByClusterIdx.containsKey(key)) {
            Map<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx = dictByClusterIdx.get(key);
            cursor = new CFAsteriskRamHostNodeCursor(Authorization, schema, subdictClusterIdx.values());
        } else {
            cursor = new CFAsteriskRamHostNodeCursor(Authorization, schema,
                    new ArrayList<CFSecurityHostNodeBuff>());
        }
        return (cursor);
    }

    public void closeHostNodeCursor(CFSecurityCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public CFSecurityHostNodeBuff nextHostNodeCursor(CFSecurityCursor Cursor) {
        CFAsteriskRamHostNodeCursor cursor = (CFAsteriskRamHostNodeCursor) Cursor;
        CFSecurityHostNodeBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public CFSecurityHostNodeBuff prevHostNodeCursor(CFSecurityCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFSecurityHostNodeBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextHostNodeCursor(Cursor);
        }
        return (rec);
    }

    public CFSecurityHostNodeBuff firstHostNodeCursor(CFSecurityCursor Cursor) {
        int targetRowIdx = 1;
        CFSecurityHostNodeBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextHostNodeCursor(Cursor);
        }
        return (rec);
    }

    public CFSecurityHostNodeBuff lastHostNodeCursor(CFSecurityCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastHostNodeCursor");
    }

    public CFSecurityHostNodeBuff nthHostNodeCursor(CFSecurityCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFSecurityHostNodeBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextHostNodeCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}