net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmRam.CFCrmRamSecFormTable.java Source code

Java tutorial

Introduction

Here is the source code for net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmRam.CFCrmRamSecFormTable.java

Source

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

/*
 *   CF Customer Relations Management model
 *
 *   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.cfcrm.v2_0.CFCrmRam;

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.cfcrm.v2_0.CFCrm.*;
import net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrmRam.*;

/*
 *   CFCrmRamSecFormTable in-memory RAM DbIO implementation
 *   for SecForm.
 */
public class CFCrmRamSecFormTable implements ICFCrmSecFormTable {
    private CFCrmRamSchema schema;
    private Map<CFCrmSecFormPKey, CFCrmSecFormBuff> dictByPKey = new HashMap<CFCrmSecFormPKey, CFCrmSecFormBuff>();
    private SortedMap<CFCrmSecFormByClusterIdxKey, SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff>> dictByClusterIdx = new TreeMap<CFCrmSecFormByClusterIdxKey, SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff>>();
    private SortedMap<CFCrmSecFormBySecAppIdxKey, SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff>> dictBySecAppIdx = new TreeMap<CFCrmSecFormBySecAppIdxKey, SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff>>();
    private SortedMap<CFCrmSecFormByUJEEServletIdxKey, CFCrmSecFormBuff> dictByUJEEServletIdx = new TreeMap<CFCrmSecFormByUJEEServletIdxKey, CFCrmSecFormBuff>();

    public CFCrmRamSecFormTable(CFCrmRamSchema argSchema) {
        schema = argSchema;
    }

    public void createSecForm(CFCrmAuthorization Authorization, CFCrmSecFormBuff Buff) {
        CFCrmSecFormPKey pkey = schema.getFactorySecForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecFormId(((CFCrmRamClusterTable) schema.getTableCluster()).nextSecFormIdGen(Authorization,
                Buff.getRequiredClusterId()));
        Buff.setRequiredClusterId(pkey.getRequiredClusterId());
        Buff.setRequiredSecFormId(pkey.getRequiredSecFormId());
        CFCrmSecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFCrmSecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
        keySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

        CFCrmSecFormByUJEEServletIdxKey keyUJEEServletIdx = schema.getFactorySecForm().newUJEEServletIdxKey();
        keyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
        keyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

        // Validate unique indexes

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

        if (dictByUJEEServletIdx.containsKey(keyUJEEServletIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createSecForm",
                    "SecFormUJEEServletIdx", keyUJEEServletIdx);
        }

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecApp().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredSecAppId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createSecForm", "Container", "SecFormApplication", "SecApp", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

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

        SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> subdictSecAppIdx;
        if (dictBySecAppIdx.containsKey(keySecAppIdx)) {
            subdictSecAppIdx = dictBySecAppIdx.get(keySecAppIdx);
        } else {
            subdictSecAppIdx = new TreeMap<CFCrmSecFormPKey, CFCrmSecFormBuff>();
            dictBySecAppIdx.put(keySecAppIdx, subdictSecAppIdx);
        }
        subdictSecAppIdx.put(pkey, Buff);

        dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff);

    }

    public CFCrmSecFormBuff readDerived(CFCrmAuthorization Authorization, CFCrmSecFormPKey PKey) {
        final String S_ProcName = "CFCrmRamSecForm.readDerived() ";
        CFCrmSecFormPKey key = schema.getFactorySecForm().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredSecFormId(PKey.getRequiredSecFormId());
        CFCrmSecFormBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFCrmSecFormBuff lockDerived(CFCrmAuthorization Authorization, CFCrmSecFormPKey PKey) {
        final String S_ProcName = "CFCrmRamSecForm.readDerived() ";
        CFCrmSecFormPKey key = schema.getFactorySecForm().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredSecFormId(PKey.getRequiredSecFormId());
        CFCrmSecFormBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public CFCrmSecFormBuff[] readDerivedByClusterIdx(CFCrmAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFCrmRamSecForm.readDerivedByClusterIdx() ";
        CFCrmSecFormByClusterIdxKey key = schema.getFactorySecForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFCrmSecFormBuff[] readDerivedBySecAppIdx(CFCrmAuthorization Authorization, long ClusterId,
            int SecAppId) {
        final String S_ProcName = "CFCrmRamSecForm.readDerivedBySecAppIdx() ";
        CFCrmSecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

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

    public CFCrmSecFormBuff readDerivedByUJEEServletIdx(CFCrmAuthorization Authorization, long ClusterId,
            int SecAppId, String JEEServletMapName) {
        final String S_ProcName = "CFCrmRamSecForm.readDerivedByUJEEServletIdx() ";
        CFCrmSecFormByUJEEServletIdxKey key = schema.getFactorySecForm().newUJEEServletIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);
        key.setRequiredJEEServletMapName(JEEServletMapName);

        CFCrmSecFormBuff buff;
        if (dictByUJEEServletIdx.containsKey(key)) {
            buff = dictByUJEEServletIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFCrmSecFormBuff readDerivedByIdIdx(CFCrmAuthorization Authorization, long ClusterId, int SecFormId) {
        final String S_ProcName = "CFCrmRamSecForm.readDerivedByIdIdx() ";
        CFCrmSecFormPKey key = schema.getFactorySecForm().newPKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecFormId(SecFormId);

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

    public CFCrmSecFormBuff readBuff(CFCrmAuthorization Authorization, CFCrmSecFormPKey PKey) {
        final String S_ProcName = "CFCrmRamSecForm.readBuff() ";
        CFCrmSecFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SFRM"))) {
            buff = null;
        }
        return (buff);
    }

    public CFCrmSecFormBuff lockBuff(CFCrmAuthorization Authorization, CFCrmSecFormPKey PKey) {
        final String S_ProcName = "CFCrmRamSecForm.readBuff() ";
        CFCrmSecFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SFRM"))) {
            buff = null;
        }
        return (buff);
    }

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

    public CFCrmSecFormBuff readBuffByIdIdx(CFCrmAuthorization Authorization, long ClusterId, int SecFormId) {
        final String S_ProcName = "CFCrmRamSecForm.readBuffByIdIdx() ";
        CFCrmSecFormBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecFormId);
        if ((buff != null) && buff.getClassCode().equals("SFRM")) {
            return ((CFCrmSecFormBuff) buff);
        } else {
            return (null);
        }
    }

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

    public CFCrmSecFormBuff[] readBuffBySecAppIdx(CFCrmAuthorization Authorization, long ClusterId, int SecAppId) {
        final String S_ProcName = "CFCrmRamSecForm.readBuffBySecAppIdx() ";
        CFCrmSecFormBuff buff;
        ArrayList<CFCrmSecFormBuff> filteredList = new ArrayList<CFCrmSecFormBuff>();
        CFCrmSecFormBuff[] buffList = readDerivedBySecAppIdx(Authorization, ClusterId, SecAppId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SFRM")) {
                filteredList.add((CFCrmSecFormBuff) buff);
            }
        }
        return (filteredList.toArray(new CFCrmSecFormBuff[0]));
    }

    public CFCrmSecFormBuff readBuffByUJEEServletIdx(CFCrmAuthorization Authorization, long ClusterId, int SecAppId,
            String JEEServletMapName) {
        final String S_ProcName = "CFCrmRamSecForm.readBuffByUJEEServletIdx() ";
        CFCrmSecFormBuff buff = readDerivedByUJEEServletIdx(Authorization, ClusterId, SecAppId, JEEServletMapName);
        if ((buff != null) && buff.getClassCode().equals("SFRM")) {
            return ((CFCrmSecFormBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateSecForm(CFCrmAuthorization Authorization, CFCrmSecFormBuff Buff) {
        CFCrmSecFormPKey pkey = schema.getFactorySecForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
        CFCrmSecFormBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateSecForm",
                    "Existing record not found", "SecForm", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecForm",
                    pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        CFCrmSecFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFCrmSecFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFCrmSecFormBySecAppIdxKey existingKeySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
        existingKeySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

        CFCrmSecFormBySecAppIdxKey newKeySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
        newKeySecAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeySecAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

        CFCrmSecFormByUJEEServletIdxKey existingKeyUJEEServletIdx = schema.getFactorySecForm()
                .newUJEEServletIdxKey();
        existingKeyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
        existingKeyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

        CFCrmSecFormByUJEEServletIdxKey newKeyUJEEServletIdx = schema.getFactorySecForm().newUJEEServletIdxKey();
        newKeyUJEEServletIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyUJEEServletIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());
        newKeyUJEEServletIdx.setRequiredJEEServletMapName(Buff.getRequiredJEEServletMapName());

        // Check unique indexes

        if (!existingKeyUJEEServletIdx.equals(newKeyUJEEServletIdx)) {
            if (dictByUJEEServletIdx.containsKey(newKeyUJEEServletIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateSecForm", "SecFormUJEEServletIdx", newKeyUJEEServletIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecApp().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredSecAppId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateSecForm", "Container", "SecFormApplication", "SecApp", null);
                }
            }
        }

        // Update is valid

        SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> 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<CFCrmSecFormPKey, CFCrmSecFormBuff>();
            dictByClusterIdx.put(newKeyClusterIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictBySecAppIdx.get(existingKeySecAppIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictBySecAppIdx.containsKey(newKeySecAppIdx)) {
            subdict = dictBySecAppIdx.get(newKeySecAppIdx);
        } else {
            subdict = new TreeMap<CFCrmSecFormPKey, CFCrmSecFormBuff>();
            dictBySecAppIdx.put(newKeySecAppIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByUJEEServletIdx.remove(existingKeyUJEEServletIdx);
        dictByUJEEServletIdx.put(newKeyUJEEServletIdx, Buff);

    }

    public void deleteSecForm(CFCrmAuthorization Authorization, CFCrmSecFormBuff Buff) {
        final String S_ProcName = "CFCrmRamSecFormTable.deleteSecForm() ";
        CFCrmSecFormPKey pkey = schema.getFactorySecForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
        CFCrmSecFormBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecForm",
                    pkey);
        }
        CFCrmSecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFCrmSecFormBySecAppIdxKey keySecAppIdx = schema.getFactorySecForm().newSecAppIdxKey();
        keySecAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keySecAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

        CFCrmSecFormByUJEEServletIdxKey keyUJEEServletIdx = schema.getFactorySecForm().newUJEEServletIdxKey();
        keyUJEEServletIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyUJEEServletIdx.setRequiredSecAppId(existing.getRequiredSecAppId());
        keyUJEEServletIdx.setRequiredJEEServletMapName(existing.getRequiredJEEServletMapName());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> subdict;

        dictByPKey.remove(pkey);

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

        subdict = dictBySecAppIdx.get(keySecAppIdx);
        subdict.remove(pkey);

        dictByUJEEServletIdx.remove(keyUJEEServletIdx);

    }

    public void deleteSecFormByIdIdx(CFCrmAuthorization Authorization, long argClusterId, int argSecFormId) {
        CFCrmSecFormPKey key = schema.getFactorySecForm().newPKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecFormId(argSecFormId);
        deleteSecFormByIdIdx(Authorization, key);
    }

    public void deleteSecFormByIdIdx(CFCrmAuthorization Authorization, CFCrmSecFormPKey argKey) {
        CFCrmSecFormBuff cur;
        LinkedList<CFCrmSecFormBuff> matchSet = new LinkedList<CFCrmSecFormBuff>();
        Iterator<CFCrmSecFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFCrmSecFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecForm(Authorization, cur);
        }
    }

    public void deleteSecFormByClusterIdx(CFCrmAuthorization Authorization, long argClusterId) {
        CFCrmSecFormByClusterIdxKey key = schema.getFactorySecForm().newClusterIdxKey();
        key.setRequiredClusterId(argClusterId);
        deleteSecFormByClusterIdx(Authorization, key);
    }

    public void deleteSecFormByClusterIdx(CFCrmAuthorization Authorization, CFCrmSecFormByClusterIdxKey argKey) {
        CFCrmSecFormBuff cur;
        LinkedList<CFCrmSecFormBuff> matchSet = new LinkedList<CFCrmSecFormBuff>();
        Iterator<CFCrmSecFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFCrmSecFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecForm(Authorization, cur);
        }
    }

    public void deleteSecFormBySecAppIdx(CFCrmAuthorization Authorization, long argClusterId, int argSecAppId) {
        CFCrmSecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecAppId(argSecAppId);
        deleteSecFormBySecAppIdx(Authorization, key);
    }

    public void deleteSecFormBySecAppIdx(CFCrmAuthorization Authorization, CFCrmSecFormBySecAppIdxKey argKey) {
        CFCrmSecFormBuff cur;
        LinkedList<CFCrmSecFormBuff> matchSet = new LinkedList<CFCrmSecFormBuff>();
        Iterator<CFCrmSecFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFCrmSecFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecForm(Authorization, cur);
        }
    }

    public void deleteSecFormByUJEEServletIdx(CFCrmAuthorization Authorization, long argClusterId, int argSecAppId,
            String argJEEServletMapName) {
        CFCrmSecFormByUJEEServletIdxKey key = schema.getFactorySecForm().newUJEEServletIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecAppId(argSecAppId);
        key.setRequiredJEEServletMapName(argJEEServletMapName);
        deleteSecFormByUJEEServletIdx(Authorization, key);
    }

    public void deleteSecFormByUJEEServletIdx(CFCrmAuthorization Authorization,
            CFCrmSecFormByUJEEServletIdxKey argKey) {
        CFCrmSecFormBuff cur;
        LinkedList<CFCrmSecFormBuff> matchSet = new LinkedList<CFCrmSecFormBuff>();
        Iterator<CFCrmSecFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFCrmSecFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecForm(Authorization, cur);
        }
    }

    public CFCrmCursor openSecFormCursorAll(CFCrmAuthorization Authorization) {
        CFCrmCursor cursor = new CFCrmRamSecFormCursor(Authorization, schema, dictByPKey.values());
        return (cursor);
    }

    public CFCrmCursor openSecFormCursorByClusterIdx(CFCrmAuthorization Authorization, long ClusterId) {
        CFCrmCursor cursor;
        CFCrmSecFormByClusterIdxKey key = schema.getFactorySecForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFCrmCursor openSecFormCursorBySecAppIdx(CFCrmAuthorization Authorization, long ClusterId,
            int SecAppId) {
        CFCrmCursor cursor;
        CFCrmSecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

        if (dictBySecAppIdx.containsKey(key)) {
            SortedMap<CFCrmSecFormPKey, CFCrmSecFormBuff> subdictSecAppIdx = dictBySecAppIdx.get(key);
            cursor = new CFCrmRamSecFormCursor(Authorization, schema, subdictSecAppIdx.values());
        } else {
            cursor = new CFCrmRamSecFormCursor(Authorization, schema, new ArrayList<CFCrmSecFormBuff>());
        }
        return (cursor);
    }

    public void closeSecFormCursor(CFCrmCursor Cursor) {
        // Cursor.DataReader.Close();
    }

    public CFCrmSecFormBuff nextSecFormCursor(CFCrmCursor Cursor) {
        CFCrmRamSecFormCursor cursor = (CFCrmRamSecFormCursor) Cursor;
        CFCrmSecFormBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

    public CFCrmSecFormBuff prevSecFormCursor(CFCrmCursor Cursor) {
        int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1;
        CFCrmSecFormBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecFormCursor(Cursor);
        }
        return (rec);
    }

    public CFCrmSecFormBuff firstSecFormCursor(CFCrmCursor Cursor) {
        int targetRowIdx = 1;
        CFCrmSecFormBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecFormCursor(Cursor);
        }
        return (rec);
    }

    public CFCrmSecFormBuff lastSecFormCursor(CFCrmCursor Cursor) {
        throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSecFormCursor");
    }

    public CFCrmSecFormBuff nthSecFormCursor(CFCrmCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFCrmSecFormBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecFormCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}