Java tutorial
// Description: Java6 in-memory RAM DbIO implementation for Table. /* * MSS Code Factory 1.10 * * Copyright (c) 2012 Mark Sobkow * * This program is available as free software under the GNU GPL v3, or * under a commercial license from Mark Sobkow. For commercial licensing * details, please contact msobkow@sasktel.net. * * Under the terms of the GPL: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * *********************************************************************** * * Code manufactured * by MSS Code Factory version 1.9.3294 * * $Revision: 26 $ */ package net.sourceforge.msscodefactory.v1_10.MSSBamRam; import java.sql.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_9.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.v1_10.MSSBam.*; import net.sourceforge.msscodefactory.v1_10.MSSBamBL.*; import net.sourceforge.msscodefactory.v1_10.MSSBamBLRam.*; /* * MSSBamRamTableTable in-memory RAM DbIO implementation * for Table. */ public class MSSBamRamTableTable implements IMSSBamTableTable { private MSSBamBLRamSchema schema; private Map<MSSBamAnyObjPKey, MSSBamTableBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); private SortedMap<MSSBamTableBySchemaIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictBySchemaIdx = new TreeMap<MSSBamTableBySchemaIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableBySchemaCdIdxKey, MSSBamTableBuff> dictBySchemaCdIdx = new TreeMap<MSSBamTableBySchemaCdIdxKey, MSSBamTableBuff>(); private SortedMap<MSSBamTableByPrimaryIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByPrimaryIndexIdx = new TreeMap<MSSBamTableByPrimaryIndexIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableBySuperClassDefIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictBySuperClassDefIdx = new TreeMap<MSSBamTableBySuperClassDefIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableByDataScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByDataScopeIdx = new TreeMap<MSSBamTableByDataScopeIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableByVAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByVAccSecIdx = new TreeMap<MSSBamTableByVAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableByVAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByVAccFreqIdx = new TreeMap<MSSBamTableByVAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableByEAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByEAccSecIdx = new TreeMap<MSSBamTableByEAccSecIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); private SortedMap<MSSBamTableByEAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>> dictByEAccFreqIdx = new TreeMap<MSSBamTableByEAccFreqIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff>>(); public MSSBamRamTableTable(MSSBamBLRamSchema argSchema) { schema = argSchema; } public void createTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) { MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredId(Buff.getRequiredId()); MSSBamTableBySchemaIdxKey keySchemaIdx = schema.getFactoryTable().newSchemaIdxKey(); keySchemaIdx.setRequiredSchemaId(Buff.getRequiredSchemaId()); MSSBamTableBySchemaCdIdxKey keySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey(); keySchemaCdIdx.setRequiredSchemaId(Buff.getRequiredSchemaId()); keySchemaCdIdx.setRequiredTableClassCode(Buff.getRequiredTableClassCode()); MSSBamTableByPrimaryIndexIdxKey keyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey(); keyPrimaryIndexIdx.setOptionalPrimaryIndexId(Buff.getOptionalPrimaryIndexId()); MSSBamTableBySuperClassDefIdxKey keySuperClassDefIdx = schema.getFactoryTable().newSuperClassDefIdxKey(); keySuperClassDefIdx.setOptionalSuperClassDefId(Buff.getOptionalSuperClassDefId()); MSSBamTableByDataScopeIdxKey keyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey(); keyDataScopeIdx.setOptionalDataScopeId(Buff.getOptionalDataScopeId()); MSSBamTableByVAccSecIdxKey keyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey(); keyVAccSecIdx.setOptionalViewAccessSecurityId(Buff.getOptionalViewAccessSecurityId()); MSSBamTableByVAccFreqIdxKey keyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey(); keyVAccFreqIdx.setOptionalViewAccessFrequencyId(Buff.getOptionalViewAccessFrequencyId()); MSSBamTableByEAccSecIdxKey keyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey(); keyEAccSecIdx.setOptionalEditAccessSecurityId(Buff.getOptionalEditAccessSecurityId()); MSSBamTableByEAccFreqIdxKey keyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey(); keyEAccFreqIdx.setOptionalEditAccessFrequencyId(Buff.getOptionalEditAccessFrequencyId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTable", pkey); } if (dictBySchemaCdIdx.containsKey(keySchemaCdIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTable", "TableSchemaCodeIdx", keySchemaCdIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableScope().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTable", "Superclass", "SuperClass", "Scope", null); } } } { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableSchemaDef().readDerivedByIdIdx(Authorization, Buff.getRequiredSchemaId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTable", "Container", "Schema", "SchemaDef", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx; if (dictBySchemaIdx.containsKey(keySchemaIdx)) { subdictSchemaIdx = dictBySchemaIdx.get(keySchemaIdx); } else { subdictSchemaIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictBySchemaIdx.put(keySchemaIdx, subdictSchemaIdx); } subdictSchemaIdx.put(pkey, Buff); dictBySchemaCdIdx.put(keySchemaCdIdx, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx; if (dictByPrimaryIndexIdx.containsKey(keyPrimaryIndexIdx)) { subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(keyPrimaryIndexIdx); } else { subdictPrimaryIndexIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByPrimaryIndexIdx.put(keyPrimaryIndexIdx, subdictPrimaryIndexIdx); } subdictPrimaryIndexIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSuperClassDefIdx; if (dictBySuperClassDefIdx.containsKey(keySuperClassDefIdx)) { subdictSuperClassDefIdx = dictBySuperClassDefIdx.get(keySuperClassDefIdx); } else { subdictSuperClassDefIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictBySuperClassDefIdx.put(keySuperClassDefIdx, subdictSuperClassDefIdx); } subdictSuperClassDefIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx; if (dictByDataScopeIdx.containsKey(keyDataScopeIdx)) { subdictDataScopeIdx = dictByDataScopeIdx.get(keyDataScopeIdx); } else { subdictDataScopeIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByDataScopeIdx.put(keyDataScopeIdx, subdictDataScopeIdx); } subdictDataScopeIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx; if (dictByVAccSecIdx.containsKey(keyVAccSecIdx)) { subdictVAccSecIdx = dictByVAccSecIdx.get(keyVAccSecIdx); } else { subdictVAccSecIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByVAccSecIdx.put(keyVAccSecIdx, subdictVAccSecIdx); } subdictVAccSecIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx; if (dictByVAccFreqIdx.containsKey(keyVAccFreqIdx)) { subdictVAccFreqIdx = dictByVAccFreqIdx.get(keyVAccFreqIdx); } else { subdictVAccFreqIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByVAccFreqIdx.put(keyVAccFreqIdx, subdictVAccFreqIdx); } subdictVAccFreqIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx; if (dictByEAccSecIdx.containsKey(keyEAccSecIdx)) { subdictEAccSecIdx = dictByEAccSecIdx.get(keyEAccSecIdx); } else { subdictEAccSecIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByEAccSecIdx.put(keyEAccSecIdx, subdictEAccSecIdx); } subdictEAccSecIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx; if (dictByEAccFreqIdx.containsKey(keyEAccFreqIdx)) { subdictEAccFreqIdx = dictByEAccFreqIdx.get(keyEAccFreqIdx); } else { subdictEAccFreqIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByEAccFreqIdx.put(keyEAccFreqIdx, subdictEAccFreqIdx); } subdictEAccFreqIdx.put(pkey, Buff); } public MSSBamTableBuff readDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamTable.readDerived() "; MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey(); key.setRequiredId(PKey.getRequiredId()); MSSBamTableBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamTableBuff[] readAllDerived(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamTable.readAllDerived() "; MSSBamTableBuff[] retList = new MSSBamTableBuff[dictByPKey.values().size()]; Iterator<MSSBamTableBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public MSSBamTableBuff[] readDerivedByTenantIdx(MSSBamAuthorization Authorization, long TenantId) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByTenantIdx() "; MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByTenantIdx(Authorization, TenantId); if (buffList == null) { return (null); } else { MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamTableBuff)) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } } public MSSBamTableBuff[] readDerivedByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByScopeIdx() "; MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByScopeIdx(Authorization, ScopeId); if (buffList == null) { return (null); } else { MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamTableBuff)) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } } public MSSBamTableBuff[] readDerivedByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByAuthorIdx() "; MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByAuthorIdx(Authorization, AuthorId); if (buffList == null) { return (null); } else { MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamTableBuff)) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } } public MSSBamTableBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByUNameIdx() "; MSSBamAnyObjBuff buff = schema.getTableAnyObj().readDerivedByUNameIdx(Authorization, ScopeId, Name); if (buff == null) { return (null); } else if (buff instanceof MSSBamTableBuff) { return ((MSSBamTableBuff) buff); } else { return (null); } } public MSSBamTableBuff[] readDerivedBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) { final String S_ProcName = "MSSBamRamTable.readDerivedBySchemaIdx() "; MSSBamTableBySchemaIdxKey key = schema.getFactoryTable().newSchemaIdxKey(); key.setRequiredSchemaId(SchemaId); MSSBamTableBuff[] recArray; if (dictBySchemaIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx = dictBySchemaIdx.get(key); recArray = new MSSBamTableBuff[subdictSchemaIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictSchemaIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff readDerivedBySchemaCdIdx(MSSBamAuthorization Authorization, long SchemaId, String TableClassCode) { final String S_ProcName = "MSSBamRamTable.readDerivedBySchemaCdIdx() "; MSSBamTableBySchemaCdIdxKey key = schema.getFactoryTable().newSchemaCdIdxKey(); key.setRequiredSchemaId(SchemaId); key.setRequiredTableClassCode(TableClassCode); MSSBamTableBuff buff; if (dictBySchemaCdIdx.containsKey(key)) { buff = dictBySchemaCdIdx.get(key); } else { buff = null; } return (buff); } public MSSBamTableBuff[] readDerivedByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) { final String S_ProcName = "MSSBamRamTable.readDerivedByPrimaryIndexIdx() "; MSSBamTableByPrimaryIndexIdxKey key = schema.getFactoryTable().newPrimaryIndexIdxKey(); key.setOptionalPrimaryIndexId(PrimaryIndexId); MSSBamTableBuff[] recArray; if (dictByPrimaryIndexIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(key); recArray = new MSSBamTableBuff[subdictPrimaryIndexIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictPrimaryIndexIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedBySuperClassDefIdx(MSSBamAuthorization Authorization, Long SuperClassDefId) { final String S_ProcName = "MSSBamRamTable.readDerivedBySuperClassDefIdx() "; MSSBamTableBySuperClassDefIdxKey key = schema.getFactoryTable().newSuperClassDefIdxKey(); key.setOptionalSuperClassDefId(SuperClassDefId); MSSBamTableBuff[] recArray; if (dictBySuperClassDefIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSuperClassDefIdx = dictBySuperClassDefIdx.get(key); recArray = new MSSBamTableBuff[subdictSuperClassDefIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictSuperClassDefIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { final String S_ProcName = "MSSBamRamTable.readDerivedByDataScopeIdx() "; MSSBamTableByDataScopeIdxKey key = schema.getFactoryTable().newDataScopeIdxKey(); key.setOptionalDataScopeId(DataScopeId); MSSBamTableBuff[] recArray; if (dictByDataScopeIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx = dictByDataScopeIdx.get(key); recArray = new MSSBamTableBuff[subdictDataScopeIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictDataScopeIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) { final String S_ProcName = "MSSBamRamTable.readDerivedByVAccSecIdx() "; MSSBamTableByVAccSecIdxKey key = schema.getFactoryTable().newVAccSecIdxKey(); key.setOptionalViewAccessSecurityId(ViewAccessSecurityId); MSSBamTableBuff[] recArray; if (dictByVAccSecIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx = dictByVAccSecIdx.get(key); recArray = new MSSBamTableBuff[subdictVAccSecIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictVAccSecIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) { final String S_ProcName = "MSSBamRamTable.readDerivedByVAccFreqIdx() "; MSSBamTableByVAccFreqIdxKey key = schema.getFactoryTable().newVAccFreqIdxKey(); key.setOptionalViewAccessFrequencyId(ViewAccessFrequencyId); MSSBamTableBuff[] recArray; if (dictByVAccFreqIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx = dictByVAccFreqIdx.get(key); recArray = new MSSBamTableBuff[subdictVAccFreqIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictVAccFreqIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) { final String S_ProcName = "MSSBamRamTable.readDerivedByEAccSecIdx() "; MSSBamTableByEAccSecIdxKey key = schema.getFactoryTable().newEAccSecIdxKey(); key.setOptionalEditAccessSecurityId(EditAccessSecurityId); MSSBamTableBuff[] recArray; if (dictByEAccSecIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx = dictByEAccSecIdx.get(key); recArray = new MSSBamTableBuff[subdictEAccSecIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictEAccSecIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff[] readDerivedByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) { final String S_ProcName = "MSSBamRamTable.readDerivedByEAccFreqIdx() "; MSSBamTableByEAccFreqIdxKey key = schema.getFactoryTable().newEAccFreqIdxKey(); key.setOptionalEditAccessFrequencyId(EditAccessFrequencyId); MSSBamTableBuff[] recArray; if (dictByEAccFreqIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx = dictByEAccFreqIdx.get(key); recArray = new MSSBamTableBuff[subdictEAccFreqIdx.size()]; Iterator<MSSBamTableBuff> iter = subdictEAccFreqIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamTableBuff[0]; } return (recArray); } public MSSBamTableBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByIdIdx() "; MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey(); key.setRequiredId(Id); MSSBamTableBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamTableBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamTable.readBuff() "; MSSBamTableBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TBL"))) { buff = null; } return (buff); } public MSSBamTableBuff[] readAllBuff(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamTable.readAllBuff() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add(buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByIdIdx() "; MSSBamAnyObjBuff buff = readDerivedByIdIdx(Authorization, Id); if ((buff != null) && buff.getClassCode().equals("ANYO")) { return ((MSSBamTableBuff) buff); } else { return (null); } } public MSSBamTableBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByTenantIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamAnyObjBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ANYO")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByScopeIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamAnyObjBuff[] buffList = readDerivedByScopeIdx(Authorization, ScopeId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ANYO")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByAuthorIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamAnyObjBuff[] buffList = readDerivedByAuthorIdx(Authorization, AuthorId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ANYO")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByUNameIdx() "; MSSBamAnyObjBuff buff = readDerivedByUNameIdx(Authorization, ScopeId, Name); if ((buff != null) && buff.getClassCode().equals("ANYO")) { return ((MSSBamTableBuff) buff); } else { return (null); } } public MSSBamTableBuff[] readBuffBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) { final String S_ProcName = "MSSBamRamTable.readBuffBySchemaIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedBySchemaIdx(Authorization, SchemaId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff readBuffBySchemaCdIdx(MSSBamAuthorization Authorization, long SchemaId, String TableClassCode) { final String S_ProcName = "MSSBamRamTable.readBuffBySchemaCdIdx() "; MSSBamTableBuff buff = readDerivedBySchemaCdIdx(Authorization, SchemaId, TableClassCode); if ((buff != null) && buff.getClassCode().equals("TBL")) { return ((MSSBamTableBuff) buff); } else { return (null); } } public MSSBamTableBuff[] readBuffByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) { final String S_ProcName = "MSSBamRamTable.readBuffByPrimaryIndexIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByPrimaryIndexIdx(Authorization, PrimaryIndexId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffBySuperClassDefIdx(MSSBamAuthorization Authorization, Long SuperClassDefId) { final String S_ProcName = "MSSBamRamTable.readBuffBySuperClassDefIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedBySuperClassDefIdx(Authorization, SuperClassDefId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { final String S_ProcName = "MSSBamRamTable.readBuffByDataScopeIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByDataScopeIdx(Authorization, DataScopeId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) { final String S_ProcName = "MSSBamRamTable.readBuffByVAccSecIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByVAccSecIdx(Authorization, ViewAccessSecurityId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) { final String S_ProcName = "MSSBamRamTable.readBuffByVAccFreqIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByVAccFreqIdx(Authorization, ViewAccessFrequencyId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) { final String S_ProcName = "MSSBamRamTable.readBuffByEAccSecIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByEAccSecIdx(Authorization, EditAccessSecurityId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public MSSBamTableBuff[] readBuffByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) { final String S_ProcName = "MSSBamRamTable.readBuffByEAccFreqIdx() "; MSSBamTableBuff buff; ArrayList<MSSBamTableBuff> filteredList = new ArrayList<MSSBamTableBuff>(); MSSBamTableBuff[] buffList = readDerivedByEAccFreqIdx(Authorization, EditAccessFrequencyId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TBL")) { filteredList.add((MSSBamTableBuff) buff); } } return (filteredList.toArray(new MSSBamTableBuff[0])); } public void updateTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) { MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); MSSBamTableBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTable", "Existing record not found", "Table", pkey); } MSSBamTableBySchemaIdxKey existingKeySchemaIdx = schema.getFactoryTable().newSchemaIdxKey(); existingKeySchemaIdx.setRequiredSchemaId(existing.getRequiredSchemaId()); MSSBamTableBySchemaIdxKey newKeySchemaIdx = schema.getFactoryTable().newSchemaIdxKey(); newKeySchemaIdx.setRequiredSchemaId(Buff.getRequiredSchemaId()); MSSBamTableBySchemaCdIdxKey existingKeySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey(); existingKeySchemaCdIdx.setRequiredSchemaId(existing.getRequiredSchemaId()); existingKeySchemaCdIdx.setRequiredTableClassCode(existing.getRequiredTableClassCode()); MSSBamTableBySchemaCdIdxKey newKeySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey(); newKeySchemaCdIdx.setRequiredSchemaId(Buff.getRequiredSchemaId()); newKeySchemaCdIdx.setRequiredTableClassCode(Buff.getRequiredTableClassCode()); MSSBamTableByPrimaryIndexIdxKey existingKeyPrimaryIndexIdx = schema.getFactoryTable() .newPrimaryIndexIdxKey(); existingKeyPrimaryIndexIdx.setOptionalPrimaryIndexId(existing.getOptionalPrimaryIndexId()); MSSBamTableByPrimaryIndexIdxKey newKeyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey(); newKeyPrimaryIndexIdx.setOptionalPrimaryIndexId(Buff.getOptionalPrimaryIndexId()); MSSBamTableBySuperClassDefIdxKey existingKeySuperClassDefIdx = schema.getFactoryTable() .newSuperClassDefIdxKey(); existingKeySuperClassDefIdx.setOptionalSuperClassDefId(existing.getOptionalSuperClassDefId()); MSSBamTableBySuperClassDefIdxKey newKeySuperClassDefIdx = schema.getFactoryTable().newSuperClassDefIdxKey(); newKeySuperClassDefIdx.setOptionalSuperClassDefId(Buff.getOptionalSuperClassDefId()); MSSBamTableByDataScopeIdxKey existingKeyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey(); existingKeyDataScopeIdx.setOptionalDataScopeId(existing.getOptionalDataScopeId()); MSSBamTableByDataScopeIdxKey newKeyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey(); newKeyDataScopeIdx.setOptionalDataScopeId(Buff.getOptionalDataScopeId()); MSSBamTableByVAccSecIdxKey existingKeyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey(); existingKeyVAccSecIdx.setOptionalViewAccessSecurityId(existing.getOptionalViewAccessSecurityId()); MSSBamTableByVAccSecIdxKey newKeyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey(); newKeyVAccSecIdx.setOptionalViewAccessSecurityId(Buff.getOptionalViewAccessSecurityId()); MSSBamTableByVAccFreqIdxKey existingKeyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey(); existingKeyVAccFreqIdx.setOptionalViewAccessFrequencyId(existing.getOptionalViewAccessFrequencyId()); MSSBamTableByVAccFreqIdxKey newKeyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey(); newKeyVAccFreqIdx.setOptionalViewAccessFrequencyId(Buff.getOptionalViewAccessFrequencyId()); MSSBamTableByEAccSecIdxKey existingKeyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey(); existingKeyEAccSecIdx.setOptionalEditAccessSecurityId(existing.getOptionalEditAccessSecurityId()); MSSBamTableByEAccSecIdxKey newKeyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey(); newKeyEAccSecIdx.setOptionalEditAccessSecurityId(Buff.getOptionalEditAccessSecurityId()); MSSBamTableByEAccFreqIdxKey existingKeyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey(); existingKeyEAccFreqIdx.setOptionalEditAccessFrequencyId(existing.getOptionalEditAccessFrequencyId()); MSSBamTableByEAccFreqIdxKey newKeyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey(); newKeyEAccFreqIdx.setOptionalEditAccessFrequencyId(Buff.getOptionalEditAccessFrequencyId()); // Check unique indexes if (!existingKeySchemaCdIdx.equals(newKeySchemaCdIdx)) { if (dictBySchemaCdIdx.containsKey(newKeySchemaCdIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateTable", "TableSchemaCodeIdx", newKeySchemaCdIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableScope().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTable", "Superclass", "SuperClass", "Scope", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableSchemaDef().readDerivedByIdIdx(Authorization, Buff.getRequiredSchemaId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTable", "Container", "Schema", "SchemaDef", null); } } } // Update is valid SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictBySchemaIdx.get(existingKeySchemaIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySchemaIdx.containsKey(newKeySchemaIdx)) { subdict = dictBySchemaIdx.get(newKeySchemaIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictBySchemaIdx.put(newKeySchemaIdx, subdict); } subdict.put(pkey, Buff); dictBySchemaCdIdx.remove(existingKeySchemaCdIdx); dictBySchemaCdIdx.put(newKeySchemaCdIdx, Buff); subdict = dictByPrimaryIndexIdx.get(existingKeyPrimaryIndexIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByPrimaryIndexIdx.containsKey(newKeyPrimaryIndexIdx)) { subdict = dictByPrimaryIndexIdx.get(newKeyPrimaryIndexIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByPrimaryIndexIdx.put(newKeyPrimaryIndexIdx, subdict); } subdict.put(pkey, Buff); subdict = dictBySuperClassDefIdx.get(existingKeySuperClassDefIdx); if (subdict != null) { subdict.remove(pkey); } if (dictBySuperClassDefIdx.containsKey(newKeySuperClassDefIdx)) { subdict = dictBySuperClassDefIdx.get(newKeySuperClassDefIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictBySuperClassDefIdx.put(newKeySuperClassDefIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByDataScopeIdx.get(existingKeyDataScopeIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByDataScopeIdx.containsKey(newKeyDataScopeIdx)) { subdict = dictByDataScopeIdx.get(newKeyDataScopeIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByDataScopeIdx.put(newKeyDataScopeIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByVAccSecIdx.get(existingKeyVAccSecIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByVAccSecIdx.containsKey(newKeyVAccSecIdx)) { subdict = dictByVAccSecIdx.get(newKeyVAccSecIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByVAccSecIdx.put(newKeyVAccSecIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByVAccFreqIdx.get(existingKeyVAccFreqIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByVAccFreqIdx.containsKey(newKeyVAccFreqIdx)) { subdict = dictByVAccFreqIdx.get(newKeyVAccFreqIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByVAccFreqIdx.put(newKeyVAccFreqIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByEAccSecIdx.get(existingKeyEAccSecIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByEAccSecIdx.containsKey(newKeyEAccSecIdx)) { subdict = dictByEAccSecIdx.get(newKeyEAccSecIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByEAccSecIdx.put(newKeyEAccSecIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByEAccFreqIdx.get(existingKeyEAccFreqIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByEAccFreqIdx.containsKey(newKeyEAccFreqIdx)) { subdict = dictByEAccFreqIdx.get(newKeyEAccFreqIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamTableBuff>(); dictByEAccFreqIdx.put(newKeyEAccFreqIdx, subdict); } subdict.put(pkey, Buff); } public void deleteTable(MSSBamAuthorization Authorization, MSSBamTableBuff Buff) { final String S_ProcName = "MSSBamRamTableTable.deleteTable() "; MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setRequiredId(schema.nextAnyObjIdGen()); MSSBamTableBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteTable", "Existing record not found", "Table", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTable", pkey); } MSSBamTableBySchemaIdxKey keySchemaIdx = schema.getFactoryTable().newSchemaIdxKey(); keySchemaIdx.setRequiredSchemaId(existing.getRequiredSchemaId()); MSSBamTableBySchemaCdIdxKey keySchemaCdIdx = schema.getFactoryTable().newSchemaCdIdxKey(); keySchemaCdIdx.setRequiredSchemaId(existing.getRequiredSchemaId()); keySchemaCdIdx.setRequiredTableClassCode(existing.getRequiredTableClassCode()); MSSBamTableByPrimaryIndexIdxKey keyPrimaryIndexIdx = schema.getFactoryTable().newPrimaryIndexIdxKey(); keyPrimaryIndexIdx.setOptionalPrimaryIndexId(existing.getOptionalPrimaryIndexId()); MSSBamTableBySuperClassDefIdxKey keySuperClassDefIdx = schema.getFactoryTable().newSuperClassDefIdxKey(); keySuperClassDefIdx.setOptionalSuperClassDefId(existing.getOptionalSuperClassDefId()); MSSBamTableByDataScopeIdxKey keyDataScopeIdx = schema.getFactoryTable().newDataScopeIdxKey(); keyDataScopeIdx.setOptionalDataScopeId(existing.getOptionalDataScopeId()); MSSBamTableByVAccSecIdxKey keyVAccSecIdx = schema.getFactoryTable().newVAccSecIdxKey(); keyVAccSecIdx.setOptionalViewAccessSecurityId(existing.getOptionalViewAccessSecurityId()); MSSBamTableByVAccFreqIdxKey keyVAccFreqIdx = schema.getFactoryTable().newVAccFreqIdxKey(); keyVAccFreqIdx.setOptionalViewAccessFrequencyId(existing.getOptionalViewAccessFrequencyId()); MSSBamTableByEAccSecIdxKey keyEAccSecIdx = schema.getFactoryTable().newEAccSecIdxKey(); keyEAccSecIdx.setOptionalEditAccessSecurityId(existing.getOptionalEditAccessSecurityId()); MSSBamTableByEAccFreqIdxKey keyEAccFreqIdx = schema.getFactoryTable().newEAccFreqIdxKey(); keyEAccFreqIdx.setOptionalEditAccessFrequencyId(existing.getOptionalEditAccessFrequencyId()); // Validate reverse foreign keys if (schema.getTableIndex().readDerivedByTableIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "Table", "Index", pkey); } if (schema.getTableRelation().readDerivedByFromTblIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "FromTable", "Relation", pkey); } if (schema.getTableRelation().readDerivedByToTblIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Lookup", "ToTable", "Relation", pkey); } if (schema.getTableChain().readDerivedByTableIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "Table", "Chain", pkey); } if (schema.getTableTableBlob().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableBlob", pkey); } if (schema.getTableTableBool().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableBool", pkey); } if (schema.getTableTableDate().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableDate", pkey); } if (schema.getTableTableDouble().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "Table", "TableDouble", pkey); } if (schema.getTableTableNumber().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "Table", "TableNumber", pkey); } if (schema.getTableTableFloat().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableFloat", pkey); } if (schema.getTableTableInt16().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableInt16", pkey); } if (schema.getTableTableEnum().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableEnum", pkey); } if (schema.getTableTableId16Gen().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableId16Gen", pkey); } if (schema.getTableTableUInt16().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableUInt16", pkey); } if (schema.getTableTableInt32().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableInt32", pkey); } if (schema.getTableTableId32Gen().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableId32Gen", pkey); } if (schema.getTableTableUInt32().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableUInt32", pkey); } if (schema.getTableTableInt64().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableInt64", pkey); } if (schema.getTableTableId64Gen().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableId64Gen", pkey); } if (schema.getTableTableUInt64().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableUInt64", pkey); } if (schema.getTableTableNmToken().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableNmToken", pkey); } if (schema.getTableTableNmTokens().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableNmTokens", pkey); } if (schema.getTableTableString().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableString", pkey); } if (schema.getTableTableTZDate().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableTZDate", pkey); } if (schema.getTableTableTZTime().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableTZTime", pkey); } if (schema.getTableTableTZTimestamp().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableTZTimestamp", pkey); } if (schema.getTableTableText().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableText", pkey); } if (schema.getTableTableTime().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableTime", pkey); } if (schema.getTableTableTimestamp().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableTimestamp", pkey); } if (schema.getTableTableToken().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableToken", pkey); } if (schema.getTableTableUuid().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableUuid", pkey); } if (schema.getTableTableUuidGen().readDerivedByContainerIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableUuidGen", pkey); } if (schema.getTableTableCol().readDerivedByCTableIdx(Authorization, existing.getRequiredId()).length > 0) { throw CFLib.getDefaultExceptionFactory().newDependentsDetectedException(getClass(), "deleteTable", "Container", "CTable", "TableCol", pkey); } // Delete is valid SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdict; dictByPKey.remove(pkey); subdict = dictBySchemaIdx.get(keySchemaIdx); subdict.remove(pkey); dictBySchemaCdIdx.remove(keySchemaCdIdx); subdict = dictByPrimaryIndexIdx.get(keyPrimaryIndexIdx); subdict.remove(pkey); subdict = dictBySuperClassDefIdx.get(keySuperClassDefIdx); subdict.remove(pkey); subdict = dictByDataScopeIdx.get(keyDataScopeIdx); subdict.remove(pkey); subdict = dictByVAccSecIdx.get(keyVAccSecIdx); subdict.remove(pkey); subdict = dictByVAccFreqIdx.get(keyVAccFreqIdx); subdict.remove(pkey); subdict = dictByEAccSecIdx.get(keyEAccSecIdx); subdict.remove(pkey); subdict = dictByEAccFreqIdx.get(keyEAccFreqIdx); subdict.remove(pkey); } public MSSBamCursor openTableCursorAll(MSSBamAuthorization Authorization) { MSSBamCursor cursor = new MSSBamRamTableCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public MSSBamCursor openTableCursorBySchemaIdx(MSSBamAuthorization Authorization, long SchemaId) { MSSBamCursor cursor; MSSBamTableBySchemaIdxKey key = schema.getFactoryTable().newSchemaIdxKey(); key.setRequiredSchemaId(SchemaId); if (dictBySchemaIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSchemaIdx = dictBySchemaIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictSchemaIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByPrimaryIndexIdx(MSSBamAuthorization Authorization, Long PrimaryIndexId) { MSSBamCursor cursor; MSSBamTableByPrimaryIndexIdxKey key = schema.getFactoryTable().newPrimaryIndexIdxKey(); key.setOptionalPrimaryIndexId(PrimaryIndexId); if (dictByPrimaryIndexIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictPrimaryIndexIdx = dictByPrimaryIndexIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictPrimaryIndexIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorBySuperClassDefIdx(MSSBamAuthorization Authorization, Long SuperClassDefId) { MSSBamCursor cursor; MSSBamTableBySuperClassDefIdxKey key = schema.getFactoryTable().newSuperClassDefIdxKey(); key.setOptionalSuperClassDefId(SuperClassDefId); if (dictBySuperClassDefIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictSuperClassDefIdx = dictBySuperClassDefIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictSuperClassDefIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { MSSBamCursor cursor; MSSBamTableByDataScopeIdxKey key = schema.getFactoryTable().newDataScopeIdxKey(); key.setOptionalDataScopeId(DataScopeId); if (dictByDataScopeIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictDataScopeIdx = dictByDataScopeIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictDataScopeIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) { MSSBamCursor cursor; MSSBamTableByVAccSecIdxKey key = schema.getFactoryTable().newVAccSecIdxKey(); key.setOptionalViewAccessSecurityId(ViewAccessSecurityId); if (dictByVAccSecIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccSecIdx = dictByVAccSecIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictVAccSecIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) { MSSBamCursor cursor; MSSBamTableByVAccFreqIdxKey key = schema.getFactoryTable().newVAccFreqIdxKey(); key.setOptionalViewAccessFrequencyId(ViewAccessFrequencyId); if (dictByVAccFreqIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictVAccFreqIdx = dictByVAccFreqIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictVAccFreqIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) { MSSBamCursor cursor; MSSBamTableByEAccSecIdxKey key = schema.getFactoryTable().newEAccSecIdxKey(); key.setOptionalEditAccessSecurityId(EditAccessSecurityId); if (dictByEAccSecIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccSecIdx = dictByEAccSecIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictEAccSecIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public MSSBamCursor openTableCursorByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) { MSSBamCursor cursor; MSSBamTableByEAccFreqIdxKey key = schema.getFactoryTable().newEAccFreqIdxKey(); key.setOptionalEditAccessFrequencyId(EditAccessFrequencyId); if (dictByEAccFreqIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamTableBuff> subdictEAccFreqIdx = dictByEAccFreqIdx.get(key); cursor = new MSSBamRamTableCursor(Authorization, schema, subdictEAccFreqIdx.values()); } else { cursor = new MSSBamRamTableCursor(Authorization, schema, new ArrayList<MSSBamTableBuff>()); } return (cursor); } public void closeTableCursor(MSSBamCursor Cursor) { // Cursor.DataReader.Close(); } public MSSBamTableBuff nextTableCursor(MSSBamCursor Cursor) { MSSBamRamTableCursor cursor = (MSSBamRamTableCursor) Cursor; MSSBamTableBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public MSSBamTableBuff prevTableCursor(MSSBamCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; MSSBamTableBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTableCursor(Cursor); } return (rec); } public MSSBamTableBuff firstTableCursor(MSSBamCursor Cursor) { int targetRowIdx = 1; MSSBamTableBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTableCursor(Cursor); } return (rec); } public MSSBamTableBuff lastTableCursor(MSSBamCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastTableCursor"); } public MSSBamTableBuff nthTableCursor(MSSBamCursor Cursor, int Idx) { int targetRowIdx = Idx; MSSBamTableBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTableCursor(Cursor); } return (rec); } }