net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamHostNodeTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.CFSecurityRamHostNodeTable.java

Source

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

/*
 *   CF Security Core Implementation
 *
 *   Copyright (c) 2010-2014 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.
 *   
 * ***********************************************************************
 *
 *   Code manufactured by MSS Code Factory
 */

package net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam;

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.cfsecurity.v2_0.CFSecurity.*;
import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.*;

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

    public CFSecurityRamHostNodeTable(CFSecurityRamSchema argSchema) {
        schema = argSchema;
    }

    public void createHostNode(CFSecurityAuthorization Authorization, CFSecurityHostNodeBuff Buff) {
        CFSecurityHostNodePKey pkey = schema.getFactoryHostNode().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredHostNodeId(((CFSecurityRamClusterTable) 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(), "createHostNode",
                    pkey);
        }

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

        if (dictByHostNameIdx.containsKey(keyHostNameIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createHostNode",
                    "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(),
                            "createHostNode", "Container", "HostNodeCluster", "Cluster", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

        SortedMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx;
        if (dictByClusterIdx.containsKey(keyClusterIdx)) {
            subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
        } else {
            subdictClusterIdx = new TreeMap<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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.readDerivedByClusterIdx() ";
        CFSecurityHostNodeByClusterIdxKey key = schema.getFactoryHostNode().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

        CFSecurityHostNodeBuff[] recArray;
        if (dictByClusterIdx.containsKey(key)) {
            SortedMap<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 {
            recArray = new CFSecurityHostNodeBuff[0];
        }
        return (recArray);
    }

    public CFSecurityHostNodeBuff readDerivedByUDescrIdx(CFSecurityAuthorization Authorization, long ClusterId,
            String Description) {
        final String S_ProcName = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.readBuff() ";
        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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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 = "CFSecurityRamHostNode.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

        SortedMap<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 TreeMap<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 = "CFSecurityRamHostNodeTable.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());
        SortedMap<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 CFSecurityRamHostNodeCursor(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)) {
            SortedMap<CFSecurityHostNodePKey, CFSecurityHostNodeBuff> subdictClusterIdx = dictByClusterIdx.get(key);
            cursor = new CFSecurityRamHostNodeCursor(Authorization, schema, subdictClusterIdx.values());
        } else {
            cursor = new CFSecurityRamHostNodeCursor(Authorization, schema,
                    new ArrayList<CFSecurityHostNodeBuff>());
        }
        return (cursor);
    }

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

    public CFSecurityHostNodeBuff nextHostNodeCursor(CFSecurityCursor Cursor) {
        CFSecurityRamHostNodeCursor cursor = (CFSecurityRamHostNodeCursor) 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() {
    }
}