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

Java tutorial

Introduction

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

Source

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

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

/*
 *   CFSecurityRamSecGroupFormTable in-memory RAM DbIO implementation
 *   for SecGroupForm.
 */
public class CFSecurityRamSecGroupFormTable implements ICFSecuritySecGroupFormTable {
    private CFSecurityRamSchema schema;
    private Map<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> dictByPKey = new HashMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
    private SortedMap<CFSecuritySecGroupFormByClusterIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>> dictByClusterIdx = new TreeMap<CFSecuritySecGroupFormByClusterIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>>();
    private SortedMap<CFSecuritySecGroupFormByGroupIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>> dictByGroupIdx = new TreeMap<CFSecuritySecGroupFormByGroupIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>>();
    private SortedMap<CFSecuritySecGroupFormByAppIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>> dictByAppIdx = new TreeMap<CFSecuritySecGroupFormByAppIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>>();
    private SortedMap<CFSecuritySecGroupFormByFormIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>> dictByFormIdx = new TreeMap<CFSecuritySecGroupFormByFormIdxKey, SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>>();
    private SortedMap<CFSecuritySecGroupFormByUFormIdxKey, CFSecuritySecGroupFormBuff> dictByUFormIdx = new TreeMap<CFSecuritySecGroupFormByUFormIdxKey, CFSecuritySecGroupFormBuff>();

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

    public void createSecGroupForm(CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
        CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecGroupFormId(((CFSecurityRamClusterTable) schema.getTableCluster())
                .nextSecGroupFormIdGen(Authorization, Buff.getRequiredClusterId()));
        Buff.setRequiredClusterId(pkey.getRequiredClusterId());
        Buff.setRequiredSecGroupFormId(pkey.getRequiredSecGroupFormId());
        CFSecuritySecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFSecuritySecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
        keyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        CFSecuritySecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
        keyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

        CFSecuritySecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
        keyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

        CFSecuritySecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
        keyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        keyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        keyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

        // Validate unique indexes

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

        if (dictByUFormIdx.containsKey(keyUFormIdx)) {
            throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                    "createSecGroupForm", "SecGroupFormUFormIdx", keyUFormIdx);
        }

        // Validate foreign keys

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

        {
            boolean allNull = true;
            allNull = false;
            allNull = false;
            if (!allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredSecGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "createSecGroupForm", "Container", "SecGroupFormGroup", "SecGroup", null);
                }
            }
        }

        // Proceed with adding the new record

        dictByPKey.put(pkey, Buff);

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

        SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictGroupIdx;
        if (dictByGroupIdx.containsKey(keyGroupIdx)) {
            subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx);
        } else {
            subdictGroupIdx = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx);
        }
        subdictGroupIdx.put(pkey, Buff);

        SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictAppIdx;
        if (dictByAppIdx.containsKey(keyAppIdx)) {
            subdictAppIdx = dictByAppIdx.get(keyAppIdx);
        } else {
            subdictAppIdx = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByAppIdx.put(keyAppIdx, subdictAppIdx);
        }
        subdictAppIdx.put(pkey, Buff);

        SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx;
        if (dictByFormIdx.containsKey(keyFormIdx)) {
            subdictFormIdx = dictByFormIdx.get(keyFormIdx);
        } else {
            subdictFormIdx = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByFormIdx.put(keyFormIdx, subdictFormIdx);
        }
        subdictFormIdx.put(pkey, Buff);

        dictByUFormIdx.put(keyUFormIdx, Buff);

    }

    public CFSecuritySecGroupFormBuff readDerived(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerived() ";
        CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredSecGroupFormId(PKey.getRequiredSecGroupFormId());
        CFSecuritySecGroupFormBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFSecuritySecGroupFormBuff lockDerived(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerived() ";
        CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
        key.setRequiredClusterId(PKey.getRequiredClusterId());
        key.setRequiredSecGroupFormId(PKey.getRequiredSecGroupFormId());
        CFSecuritySecGroupFormBuff buff;
        if (dictByPKey.containsKey(key)) {
            buff = dictByPKey.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

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

    public CFSecuritySecGroupFormBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization,
            long ClusterId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByClusterIdx() ";
        CFSecuritySecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFSecuritySecGroupFormBuff[] readDerivedByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecGroupId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByGroupIdx() ";
        CFSecuritySecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecGroupId(SecGroupId);

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

    public CFSecuritySecGroupFormBuff[] readDerivedByAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByAppIdx() ";
        CFSecuritySecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

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

    public CFSecuritySecGroupFormBuff[] readDerivedByFormIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByFormIdx() ";
        CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecFormId(SecFormId);

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

    public CFSecuritySecGroupFormBuff readDerivedByUFormIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecGroupId, int SecFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByUFormIdx() ";
        CFSecuritySecGroupFormByUFormIdxKey key = schema.getFactorySecGroupForm().newUFormIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecGroupId(SecGroupId);
        key.setRequiredSecFormId(SecFormId);

        CFSecuritySecGroupFormBuff buff;
        if (dictByUFormIdx.containsKey(key)) {
            buff = dictByUFormIdx.get(key);
        } else {
            buff = null;
        }
        return (buff);
    }

    public CFSecuritySecGroupFormBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId,
            long SecGroupFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readDerivedByIdIdx() ";
        CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecGroupFormId(SecGroupFormId);

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

    public CFSecuritySecGroupFormBuff readBuff(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuff() ";
        CFSecuritySecGroupFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SGFM"))) {
            buff = null;
        }
        return (buff);
    }

    public CFSecuritySecGroupFormBuff lockBuff(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormPKey PKey) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuff() ";
        CFSecuritySecGroupFormBuff buff = readDerived(Authorization, PKey);
        if ((buff != null) && (!buff.getClassCode().equals("SGFM"))) {
            buff = null;
        }
        return (buff);
    }

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

    public CFSecuritySecGroupFormBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long ClusterId,
            long SecGroupFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuffByIdIdx() ";
        CFSecuritySecGroupFormBuff buff = readDerivedByIdIdx(Authorization, ClusterId, SecGroupFormId);
        if ((buff != null) && buff.getClassCode().equals("SGFM")) {
            return ((CFSecuritySecGroupFormBuff) buff);
        } else {
            return (null);
        }
    }

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

    public CFSecuritySecGroupFormBuff[] readBuffByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecGroupId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuffByGroupIdx() ";
        CFSecuritySecGroupFormBuff buff;
        ArrayList<CFSecuritySecGroupFormBuff> filteredList = new ArrayList<CFSecuritySecGroupFormBuff>();
        CFSecuritySecGroupFormBuff[] buffList = readDerivedByGroupIdx(Authorization, ClusterId, SecGroupId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGFM")) {
                filteredList.add((CFSecuritySecGroupFormBuff) buff);
            }
        }
        return (filteredList.toArray(new CFSecuritySecGroupFormBuff[0]));
    }

    public CFSecuritySecGroupFormBuff[] readBuffByAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuffByAppIdx() ";
        CFSecuritySecGroupFormBuff buff;
        ArrayList<CFSecuritySecGroupFormBuff> filteredList = new ArrayList<CFSecuritySecGroupFormBuff>();
        CFSecuritySecGroupFormBuff[] buffList = readDerivedByAppIdx(Authorization, ClusterId, SecAppId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGFM")) {
                filteredList.add((CFSecuritySecGroupFormBuff) buff);
            }
        }
        return (filteredList.toArray(new CFSecuritySecGroupFormBuff[0]));
    }

    public CFSecuritySecGroupFormBuff[] readBuffByFormIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuffByFormIdx() ";
        CFSecuritySecGroupFormBuff buff;
        ArrayList<CFSecuritySecGroupFormBuff> filteredList = new ArrayList<CFSecuritySecGroupFormBuff>();
        CFSecuritySecGroupFormBuff[] buffList = readDerivedByFormIdx(Authorization, ClusterId, SecFormId);
        for (int idx = 0; idx < buffList.length; idx++) {
            buff = buffList[idx];
            if ((buff != null) && buff.getClassCode().equals("SGFM")) {
                filteredList.add((CFSecuritySecGroupFormBuff) buff);
            }
        }
        return (filteredList.toArray(new CFSecuritySecGroupFormBuff[0]));
    }

    public CFSecuritySecGroupFormBuff readBuffByUFormIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecGroupId, int SecFormId) {
        final String S_ProcName = "CFSecurityRamSecGroupForm.readBuffByUFormIdx() ";
        CFSecuritySecGroupFormBuff buff = readDerivedByUFormIdx(Authorization, ClusterId, SecGroupId, SecFormId);
        if ((buff != null) && buff.getClassCode().equals("SGFM")) {
            return ((CFSecuritySecGroupFormBuff) buff);
        } else {
            return (null);
        }
    }

    public void updateSecGroupForm(CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
        CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
        CFSecuritySecGroupFormBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(),
                    "updateSecGroupForm", "Existing record not found", "SecGroupForm", pkey);
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateSecGroupForm",
                    pkey);
        }
        Buff.setRequiredRevision(Buff.getRequiredRevision() + 1);
        CFSecuritySecGroupFormByClusterIdxKey existingKeyClusterIdx = schema.getFactorySecGroupForm()
                .newClusterIdxKey();
        existingKeyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFSecuritySecGroupFormByClusterIdxKey newKeyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
        newKeyClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId());

        CFSecuritySecGroupFormByGroupIdxKey existingKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
        existingKeyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        CFSecuritySecGroupFormByGroupIdxKey newKeyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
        newKeyGroupIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyGroupIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());

        CFSecuritySecGroupFormByAppIdxKey existingKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
        existingKeyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

        CFSecuritySecGroupFormByAppIdxKey newKeyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
        newKeyAppIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyAppIdx.setRequiredSecAppId(Buff.getRequiredSecAppId());

        CFSecuritySecGroupFormByFormIdxKey existingKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
        existingKeyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

        CFSecuritySecGroupFormByFormIdxKey newKeyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
        newKeyFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

        CFSecuritySecGroupFormByUFormIdxKey existingKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
        existingKeyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
        existingKeyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        existingKeyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

        CFSecuritySecGroupFormByUFormIdxKey newKeyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
        newKeyUFormIdx.setRequiredClusterId(Buff.getRequiredClusterId());
        newKeyUFormIdx.setRequiredSecGroupId(Buff.getRequiredSecGroupId());
        newKeyUFormIdx.setRequiredSecFormId(Buff.getRequiredSecFormId());

        // Check unique indexes

        if (!existingKeyUFormIdx.equals(newKeyUFormIdx)) {
            if (dictByUFormIdx.containsKey(newKeyUFormIdx)) {
                throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(),
                        "updateSecGroupForm", "SecGroupFormUFormIdx", newKeyUFormIdx);
            }
        }

        // Validate foreign keys

        {
            boolean allNull = true;

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

        {
            boolean allNull = true;

            if (allNull) {
                if (null == schema.getTableSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(),
                        Buff.getRequiredSecGroupId())) {
                    throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(),
                            "updateSecGroupForm", "Container", "SecGroupFormGroup", "SecGroup", null);
                }
            }
        }

        // Update is valid

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

        subdict = dictByGroupIdx.get(existingKeyGroupIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByGroupIdx.containsKey(newKeyGroupIdx)) {
            subdict = dictByGroupIdx.get(newKeyGroupIdx);
        } else {
            subdict = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByGroupIdx.put(newKeyGroupIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByAppIdx.get(existingKeyAppIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByAppIdx.containsKey(newKeyAppIdx)) {
            subdict = dictByAppIdx.get(newKeyAppIdx);
        } else {
            subdict = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByAppIdx.put(newKeyAppIdx, subdict);
        }
        subdict.put(pkey, Buff);

        subdict = dictByFormIdx.get(existingKeyFormIdx);
        if (subdict != null) {
            subdict.remove(pkey);
        }
        if (dictByFormIdx.containsKey(newKeyFormIdx)) {
            subdict = dictByFormIdx.get(newKeyFormIdx);
        } else {
            subdict = new TreeMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff>();
            dictByFormIdx.put(newKeyFormIdx, subdict);
        }
        subdict.put(pkey, Buff);

        dictByUFormIdx.remove(existingKeyUFormIdx);
        dictByUFormIdx.put(newKeyUFormIdx, Buff);

    }

    public void deleteSecGroupForm(CFSecurityAuthorization Authorization, CFSecuritySecGroupFormBuff Buff) {
        final String S_ProcName = "CFSecurityRamSecGroupFormTable.deleteSecGroupForm() ";
        CFSecuritySecGroupFormPKey pkey = schema.getFactorySecGroupForm().newPKey();
        pkey.setRequiredClusterId(Buff.getRequiredClusterId());
        pkey.setRequiredSecGroupFormId(Buff.getRequiredSecGroupFormId());
        CFSecuritySecGroupFormBuff existing = dictByPKey.get(pkey);
        if (existing == null) {
            return;
        }
        if (existing.getRequiredRevision() != Buff.getRequiredRevision()) {
            throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteSecGroupForm",
                    pkey);
        }
        CFSecuritySecGroupFormByClusterIdxKey keyClusterIdx = schema.getFactorySecGroupForm().newClusterIdxKey();
        keyClusterIdx.setRequiredClusterId(existing.getRequiredClusterId());

        CFSecuritySecGroupFormByGroupIdxKey keyGroupIdx = schema.getFactorySecGroupForm().newGroupIdxKey();
        keyGroupIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyGroupIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());

        CFSecuritySecGroupFormByAppIdxKey keyAppIdx = schema.getFactorySecGroupForm().newAppIdxKey();
        keyAppIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyAppIdx.setRequiredSecAppId(existing.getRequiredSecAppId());

        CFSecuritySecGroupFormByFormIdxKey keyFormIdx = schema.getFactorySecGroupForm().newFormIdxKey();
        keyFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

        CFSecuritySecGroupFormByUFormIdxKey keyUFormIdx = schema.getFactorySecGroupForm().newUFormIdxKey();
        keyUFormIdx.setRequiredClusterId(existing.getRequiredClusterId());
        keyUFormIdx.setRequiredSecGroupId(existing.getRequiredSecGroupId());
        keyUFormIdx.setRequiredSecFormId(existing.getRequiredSecFormId());

        // Validate reverse foreign keys

        // Delete is valid

        SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdict;

        dictByPKey.remove(pkey);

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

        subdict = dictByGroupIdx.get(keyGroupIdx);
        subdict.remove(pkey);

        subdict = dictByAppIdx.get(keyAppIdx);
        subdict.remove(pkey);

        subdict = dictByFormIdx.get(keyFormIdx);
        subdict.remove(pkey);

        dictByUFormIdx.remove(keyUFormIdx);

    }

    public void deleteSecGroupFormByIdIdx(CFSecurityAuthorization Authorization, long argClusterId,
            long argSecGroupFormId) {
        CFSecuritySecGroupFormPKey key = schema.getFactorySecGroupForm().newPKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecGroupFormId(argSecGroupFormId);
        deleteSecGroupFormByIdIdx(Authorization, key);
    }

    public void deleteSecGroupFormByIdIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormPKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

    public void deleteSecGroupFormByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) {
        CFSecuritySecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey();
        key.setRequiredClusterId(argClusterId);
        deleteSecGroupFormByClusterIdx(Authorization, key);
    }

    public void deleteSecGroupFormByClusterIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormByClusterIdxKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

    public void deleteSecGroupFormByGroupIdx(CFSecurityAuthorization Authorization, long argClusterId,
            int argSecGroupId) {
        CFSecuritySecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecGroupId(argSecGroupId);
        deleteSecGroupFormByGroupIdx(Authorization, key);
    }

    public void deleteSecGroupFormByGroupIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormByGroupIdxKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

    public void deleteSecGroupFormByAppIdx(CFSecurityAuthorization Authorization, long argClusterId,
            int argSecAppId) {
        CFSecuritySecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecAppId(argSecAppId);
        deleteSecGroupFormByAppIdx(Authorization, key);
    }

    public void deleteSecGroupFormByAppIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormByAppIdxKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

    public void deleteSecGroupFormByFormIdx(CFSecurityAuthorization Authorization, long argClusterId,
            int argSecFormId) {
        CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecFormId(argSecFormId);
        deleteSecGroupFormByFormIdx(Authorization, key);
    }

    public void deleteSecGroupFormByFormIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormByFormIdxKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

    public void deleteSecGroupFormByUFormIdx(CFSecurityAuthorization Authorization, long argClusterId,
            int argSecGroupId, int argSecFormId) {
        CFSecuritySecGroupFormByUFormIdxKey key = schema.getFactorySecGroupForm().newUFormIdxKey();
        key.setRequiredClusterId(argClusterId);
        key.setRequiredSecGroupId(argSecGroupId);
        key.setRequiredSecFormId(argSecFormId);
        deleteSecGroupFormByUFormIdx(Authorization, key);
    }

    public void deleteSecGroupFormByUFormIdx(CFSecurityAuthorization Authorization,
            CFSecuritySecGroupFormByUFormIdxKey argKey) {
        CFSecuritySecGroupFormBuff cur;
        LinkedList<CFSecuritySecGroupFormBuff> matchSet = new LinkedList<CFSecuritySecGroupFormBuff>();
        Iterator<CFSecuritySecGroupFormBuff> values = dictByPKey.values().iterator();
        while (values.hasNext()) {
            cur = values.next();
            if (argKey.equals(cur)) {
                matchSet.add(cur);
            }
        }
        Iterator<CFSecuritySecGroupFormBuff> iterMatch = matchSet.iterator();
        while (iterMatch.hasNext()) {
            cur = iterMatch.next();
            deleteSecGroupForm(Authorization, cur);
        }
    }

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

    public CFSecurityCursor openSecGroupFormCursorByClusterIdx(CFSecurityAuthorization Authorization,
            long ClusterId) {
        CFSecurityCursor cursor;
        CFSecuritySecGroupFormByClusterIdxKey key = schema.getFactorySecGroupForm().newClusterIdxKey();
        key.setRequiredClusterId(ClusterId);

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

    public CFSecurityCursor openSecGroupFormCursorByGroupIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecGroupId) {
        CFSecurityCursor cursor;
        CFSecuritySecGroupFormByGroupIdxKey key = schema.getFactorySecGroupForm().newGroupIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecGroupId(SecGroupId);

        if (dictByGroupIdx.containsKey(key)) {
            SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictGroupIdx = dictByGroupIdx
                    .get(key);
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema, subdictGroupIdx.values());
        } else {
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema,
                    new ArrayList<CFSecuritySecGroupFormBuff>());
        }
        return (cursor);
    }

    public CFSecurityCursor openSecGroupFormCursorByAppIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecAppId) {
        CFSecurityCursor cursor;
        CFSecuritySecGroupFormByAppIdxKey key = schema.getFactorySecGroupForm().newAppIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecAppId(SecAppId);

        if (dictByAppIdx.containsKey(key)) {
            SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictAppIdx = dictByAppIdx.get(key);
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema, subdictAppIdx.values());
        } else {
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema,
                    new ArrayList<CFSecuritySecGroupFormBuff>());
        }
        return (cursor);
    }

    public CFSecurityCursor openSecGroupFormCursorByFormIdx(CFSecurityAuthorization Authorization, long ClusterId,
            int SecFormId) {
        CFSecurityCursor cursor;
        CFSecuritySecGroupFormByFormIdxKey key = schema.getFactorySecGroupForm().newFormIdxKey();
        key.setRequiredClusterId(ClusterId);
        key.setRequiredSecFormId(SecFormId);

        if (dictByFormIdx.containsKey(key)) {
            SortedMap<CFSecuritySecGroupFormPKey, CFSecuritySecGroupFormBuff> subdictFormIdx = dictByFormIdx
                    .get(key);
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema, subdictFormIdx.values());
        } else {
            cursor = new CFSecurityRamSecGroupFormCursor(Authorization, schema,
                    new ArrayList<CFSecuritySecGroupFormBuff>());
        }
        return (cursor);
    }

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

    public CFSecuritySecGroupFormBuff nextSecGroupFormCursor(CFSecurityCursor Cursor) {
        CFSecurityRamSecGroupFormCursor cursor = (CFSecurityRamSecGroupFormCursor) Cursor;
        CFSecuritySecGroupFormBuff rec = cursor.getCursor().next();
        cursor.setRowIdx(cursor.getRowIdx() + 1);
        return (rec);
    }

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

    public CFSecuritySecGroupFormBuff firstSecGroupFormCursor(CFSecurityCursor Cursor) {
        int targetRowIdx = 1;
        CFSecuritySecGroupFormBuff rec = null;
        Cursor.reset();
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupFormCursor(Cursor);
        }
        return (rec);
    }

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

    public CFSecuritySecGroupFormBuff nthSecGroupFormCursor(CFSecurityCursor Cursor, int Idx) {
        int targetRowIdx = Idx;
        CFSecuritySecGroupFormBuff rec = null;
        if (Cursor.getRowIdx() >= targetRowIdx) {
            Cursor.reset();
        }
        while (Cursor.getRowIdx() < targetRowIdx) {
            rec = nextSecGroupFormCursor(Cursor);
        }
        return (rec);
    }

    public void releasePreparedStatements() {
    }
}