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

Java tutorial

Introduction

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

Source

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

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

/*
 *   CFSecurityRamSecFormTable in-memory RAM DbIO implementation
 *   for SecForm.
 */
public class CFSecurityRamSecFormTable implements ICFSecuritySecFormTable {
    private CFSecurityRamSchema schema;
    private Map<CFSecuritySecFormPKey, CFSecuritySecFormBuff> dictByPKey = new HashMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
    private SortedMap<CFSecuritySecFormByClusterIdxKey, SortedMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>> dictByClusterIdx = new TreeMap<CFSecuritySecFormByClusterIdxKey, SortedMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>>();
    private SortedMap<CFSecuritySecFormBySecAppIdxKey, SortedMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>> dictBySecAppIdx = new TreeMap<CFSecuritySecFormBySecAppIdxKey, SortedMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>>();
    private SortedMap<CFSecuritySecFormByUJEEServletIdxKey, CFSecuritySecFormBuff> dictByUJEEServletIdx = new TreeMap<CFSecuritySecFormByUJEEServletIdxKey, CFSecuritySecFormBuff>();

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

    public void createSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
        CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecFormId(((CFSecurityRamClusterTable) schema.getTableCluster())
                .nextSecFormIdGen(Authorization, Buff.getRequiredClusterId()));
        Buff.setRequiredClusterId(pkey.getRequiredClusterId());
        Buff.setRequiredSecFormId(pkey.getRequiredSecFormId());
        CFSecuritySecFormByClusterIdxKey keyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

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

        CFSecuritySecFormByUJEEServletIdxKey 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<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdictClusterIdx;
        if (dictByClusterIdx.containsKey(keyClusterIdx)) {
            subdictClusterIdx = dictByClusterIdx.get(keyClusterIdx);
        } else {
            subdictClusterIdx = new TreeMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
            dictByClusterIdx.put(keyClusterIdx, subdictClusterIdx);
        }
        subdictClusterIdx.put(pkey, Buff);

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

        dictByUJEEServletIdx.put(keyUJEEServletIdx, Buff);

    }

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

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

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

    public CFSecuritySecFormBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) {
        final String S_ProcName = "CFSecurityRamSecForm.readDerivedByClusterIdx() ";
        CFSecuritySecFormByClusterIdxKey key = schema.getFactorySecForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFSecuritySecFormBuff[] readDerivedBySecAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        final String S_ProcName = "CFSecurityRamSecForm.readDerivedBySecAppIdx() ";
        CFSecuritySecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

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

    public CFSecuritySecFormBuff readDerivedByUJEEServletIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId, String JEEServletMapName) {
        final String S_ProcName = "CFSecurityRamSecForm.readDerivedByUJEEServletIdx() ";
        CFSecuritySecFormByUJEEServletIdxKey key = schema.getFactorySecForm().newUJEEServletIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);
        key.setRequiredJEEServletMapName(JEEServletMapName);

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

    public CFSecuritySecFormBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecFormId) {
        final String S_ProcName = "CFSecurityRamSecForm.readDerivedByIdIdx() ";
        CFSecuritySecFormPKey key = schema.getFactorySecForm().newPKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecFormId(SecFormId);

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

    public CFSecuritySecFormBuff readBuff(CFSecurityAuthorization Authorization, CFSecuritySecFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecForm.readBuff() ";
        CFSecuritySecFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SFRM"))) {
            buff = null;
        }
        return (buff);
    }

    public CFSecuritySecFormBuff lockBuff(CFSecurityAuthorization Authorization, CFSecuritySecFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecForm.readBuff() ";
        CFSecuritySecFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SFRM"))) {
            buff = null;
        }
        return (buff);
    }

    public CFSecuritySecFormBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
        final String S_ProcName = "CFSecurityRamSecForm.readAllBuff() ";
        CFSecuritySecFormBuff buff;
        ArrayList<CFSecuritySecFormBuff> filteredList = new ArrayList<CFSecuritySecFormBuff>();
        CFSecuritySecFormBuff[] 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 CFSecuritySecFormBuff[0]));
    }

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

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

    public CFSecuritySecFormBuff[] readBuffBySecAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        final String S_ProcName = "CFSecurityRamSecForm.readBuffBySecAppIdx() ";
        CFSecuritySecFormBuff buff;
        ArrayList<CFSecuritySecFormBuff> filteredList = new ArrayList<CFSecuritySecFormBuff>();
        CFSecuritySecFormBuff[] 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((CFSecuritySecFormBuff) buff);
            }
        }
        return (filteredList.toArray(new CFSecuritySecFormBuff[0]));
    }

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

    public void updateSecForm(CFSecurityAuthorization Authorization, CFSecuritySecFormBuff Buff) {
        CFSecuritySecFormPKey pkey = schema.getFactorySecForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecFormId(Buff.getRequiredSecFormId());
        CFSecuritySecFormBuff 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);
        CFSecuritySecFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecForm().newClusterIdxKey();
        existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

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

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

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

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

        CFSecuritySecFormByUJEEServletIdxKey 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<CFSecuritySecFormPKey, CFSecuritySecFormBuff> 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<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
            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<CFSecuritySecFormPKey, CFSecuritySecFormBuff>();
            dictBySecAppIdx.put(newKeySecAppIdx, subdict);
        }
        subdict.put(pkey, Buff);

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

    }

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

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

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

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFSecuritySecFormPKey, CFSecuritySecFormBuff> subdict;

        dictByPKey.remove(pkey);

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

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

        dictByUJEEServletIdx.remove(keyUJEEServletIdx);

    }

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

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

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

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

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

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

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

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

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

    public CFSecurityCursor openSecFormCursorByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) {
        CFSecurityCursor cursor;
        CFSecuritySecFormByClusterIdxKey key = schema.getFactorySecForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFSecurityCursor openSecFormCursorBySecAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        CFSecurityCursor cursor;
        CFSecuritySecFormBySecAppIdxKey key = schema.getFactorySecForm().newSecAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

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

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

    public CFSecuritySecFormBuff nextSecFormCursor(CFSecurityCursor Cursor) {
        CFSecurityRamSecFormCursor cursor = (CFSecurityRamSecFormCursor) Cursor;
        CFSecuritySecFormBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

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

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

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

    public void releasePreparedStatements() {
    }
}