Java tutorial
// Description: Java6 in-memory RAM DbIO implementation for RelGroupValue. /* * MSS Code Factory 1.11 * * Copyright (c) 2012-2014 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/>. * * *********************************************************************** * * $Revision$ */ package net.sourceforge.msscodefactory.v1_11.MSSBamRam; 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.v1_11.MSSBam.*; import net.sourceforge.msscodefactory.v1_11.MSSBamBL.*; import net.sourceforge.msscodefactory.v1_11.MSSBamBLRam.*; /* * MSSBamRamRelGroupValueTable in-memory RAM DbIO implementation * for RelGroupValue. */ public class MSSBamRamRelGroupValueTable implements IMSSBamRelGroupValueTable { private MSSBamBLRamSchema schema; private Map<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> dictByPKey = new HashMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); private SortedMap<MSSBamRelGroupValueByUAltIdxKey, MSSBamRelGroupValueBuff> dictByUAltIdx = new TreeMap<MSSBamRelGroupValueByUAltIdxKey, MSSBamRelGroupValueBuff>(); private SortedMap<MSSBamRelGroupValueByRelationIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>> dictByRelationIdx = new TreeMap<MSSBamRelGroupValueByRelationIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>>(); private SortedMap<MSSBamRelGroupValueByGrpOpIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>> dictByGrpOpIdx = new TreeMap<MSSBamRelGroupValueByGrpOpIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>>(); private SortedMap<MSSBamRelGroupValueByToColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>> dictByToColIdx = new TreeMap<MSSBamRelGroupValueByToColIdxKey, SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>>(); public MSSBamRamRelGroupValueTable(MSSBamBLRamSchema argSchema) { schema = argSchema; } public void createRelGroupValue(MSSBamAuthorization Authorization, MSSBamRelGroupValueBuff Buff) { MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredId(Buff.getRequiredId()); MSSBamRelGroupValueByUAltIdxKey keyUAltIdx = schema.getFactoryRelGroupValue().newUAltIdxKey(); keyUAltIdx.setRequiredRelationId(Buff.getRequiredRelationId()); keyUAltIdx.setRequiredGroupOperatorId(Buff.getRequiredGroupOperatorId()); keyUAltIdx.setRequiredToColId(Buff.getRequiredToColId()); MSSBamRelGroupValueByRelationIdxKey keyRelationIdx = schema.getFactoryRelGroupValue().newRelationIdxKey(); keyRelationIdx.setRequiredRelationId(Buff.getRequiredRelationId()); MSSBamRelGroupValueByGrpOpIdxKey keyGrpOpIdx = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); keyGrpOpIdx.setRequiredGroupOperatorId(Buff.getRequiredGroupOperatorId()); MSSBamRelGroupValueByToColIdxKey keyToColIdx = schema.getFactoryRelGroupValue().newToColIdxKey(); keyToColIdx.setRequiredToColId(Buff.getRequiredToColId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createRelGroupValue", pkey); } if (dictByUAltIdx.containsKey(keyUAltIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createRelGroupValue", "RelGroupValueUAltIdx", keyUAltIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableAnyObj().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createRelGroupValue", "Superclass", "SuperClass", "AnyObj", null); } } } { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableRelation().readDerivedByIdIdx(Authorization, Buff.getRequiredRelationId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createRelGroupValue", "Container", "Relation", "Relation", null); } } } { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableGroupOperator().readDerivedByIdIdx(Authorization, Buff.getRequiredGroupOperatorId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createRelGroupValue", "Lookup", "LookupGroupOperator", "GroupOperator", null); } } } { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredToColId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createRelGroupValue", "Lookup", "LookupToCol", "Value", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); dictByUAltIdx.put(keyUAltIdx, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictRelationIdx; if (dictByRelationIdx.containsKey(keyRelationIdx)) { subdictRelationIdx = dictByRelationIdx.get(keyRelationIdx); } else { subdictRelationIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByRelationIdx.put(keyRelationIdx, subdictRelationIdx); } subdictRelationIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictGrpOpIdx; if (dictByGrpOpIdx.containsKey(keyGrpOpIdx)) { subdictGrpOpIdx = dictByGrpOpIdx.get(keyGrpOpIdx); } else { subdictGrpOpIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByGrpOpIdx.put(keyGrpOpIdx, subdictGrpOpIdx); } subdictGrpOpIdx.put(pkey, Buff); SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictToColIdx; if (dictByToColIdx.containsKey(keyToColIdx)) { subdictToColIdx = dictByToColIdx.get(keyToColIdx); } else { subdictToColIdx = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByToColIdx.put(keyToColIdx, subdictToColIdx); } subdictToColIdx.put(pkey, Buff); } public MSSBamRelGroupValueBuff readDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerived() "; MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey(); key.setRequiredId(PKey.getRequiredId()); MSSBamRelGroupValueBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamRelGroupValueBuff lockDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerived() "; MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey(); key.setRequiredId(PKey.getRequiredId()); MSSBamRelGroupValueBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamRelGroupValueBuff[] readAllDerived(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamRelGroupValue.readAllDerived() "; MSSBamRelGroupValueBuff[] retList = new MSSBamRelGroupValueBuff[dictByPKey.values().size()]; Iterator<MSSBamRelGroupValueBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public MSSBamRelGroupValueBuff[] 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<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamRelGroupValueBuff)) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } } public MSSBamRelGroupValueBuff[] 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<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamRelGroupValueBuff)) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } } public MSSBamRelGroupValueBuff[] readDerivedByDefSchemaIdx(MSSBamAuthorization Authorization, Long DefSchemaId) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByDefSchemaIdx() "; MSSBamAnyObjBuff buffList[] = schema.getTableAnyObj().readDerivedByDefSchemaIdx(Authorization, DefSchemaId); if (buffList == null) { return (null); } else { MSSBamAnyObjBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamRelGroupValueBuff)) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } } public MSSBamRelGroupValueBuff[] 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<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof MSSBamRelGroupValueBuff)) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } } public MSSBamRelGroupValueBuff 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 MSSBamRelGroupValueBuff) { return ((MSSBamRelGroupValueBuff) buff); } else { return (null); } } public MSSBamRelGroupValueBuff readDerivedByUAltIdx(MSSBamAuthorization Authorization, long RelationId, short GroupOperatorId, long ToColId) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerivedByUAltIdx() "; MSSBamRelGroupValueByUAltIdxKey key = schema.getFactoryRelGroupValue().newUAltIdxKey(); key.setRequiredRelationId(RelationId); key.setRequiredGroupOperatorId(GroupOperatorId); key.setRequiredToColId(ToColId); MSSBamRelGroupValueBuff buff; if (dictByUAltIdx.containsKey(key)) { buff = dictByUAltIdx.get(key); } else { buff = null; } return (buff); } public MSSBamRelGroupValueBuff[] readDerivedByRelationIdx(MSSBamAuthorization Authorization, long RelationId) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerivedByRelationIdx() "; MSSBamRelGroupValueByRelationIdxKey key = schema.getFactoryRelGroupValue().newRelationIdxKey(); key.setRequiredRelationId(RelationId); MSSBamRelGroupValueBuff[] recArray; if (dictByRelationIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictRelationIdx = dictByRelationIdx.get(key); recArray = new MSSBamRelGroupValueBuff[subdictRelationIdx.size()]; Iterator<MSSBamRelGroupValueBuff> iter = subdictRelationIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamRelGroupValueBuff[0]; } return (recArray); } public MSSBamRelGroupValueBuff[] readDerivedByGrpOpIdx(MSSBamAuthorization Authorization, short GroupOperatorId) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerivedByGrpOpIdx() "; MSSBamRelGroupValueByGrpOpIdxKey key = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); key.setRequiredGroupOperatorId(GroupOperatorId); MSSBamRelGroupValueBuff[] recArray; if (dictByGrpOpIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictGrpOpIdx = dictByGrpOpIdx.get(key); recArray = new MSSBamRelGroupValueBuff[subdictGrpOpIdx.size()]; Iterator<MSSBamRelGroupValueBuff> iter = subdictGrpOpIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamRelGroupValueBuff[0]; } return (recArray); } public MSSBamRelGroupValueBuff[] readDerivedByToColIdx(MSSBamAuthorization Authorization, long ToColId) { final String S_ProcName = "MSSBamRamRelGroupValue.readDerivedByToColIdx() "; MSSBamRelGroupValueByToColIdxKey key = schema.getFactoryRelGroupValue().newToColIdxKey(); key.setRequiredToColId(ToColId); MSSBamRelGroupValueBuff[] recArray; if (dictByToColIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictToColIdx = dictByToColIdx.get(key); recArray = new MSSBamRelGroupValueBuff[subdictToColIdx.size()]; Iterator<MSSBamRelGroupValueBuff> iter = subdictToColIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new MSSBamRelGroupValueBuff[0]; } return (recArray); } public MSSBamRelGroupValueBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "MSSBamRamAnyObj.readDerivedByIdIdx() "; MSSBamAnyObjPKey key = schema.getFactoryAnyObj().newPKey(); key.setRequiredId(Id); MSSBamRelGroupValueBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public MSSBamRelGroupValueBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuff() "; MSSBamRelGroupValueBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("RLGV"))) { buff = null; } return (buff); } public MSSBamRelGroupValueBuff lockBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuff() "; MSSBamRelGroupValueBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("RLGV"))) { buff = null; } return (buff); } public MSSBamRelGroupValueBuff[] readAllBuff(MSSBamAuthorization Authorization) { final String S_ProcName = "MSSBamRamRelGroupValue.readAllBuff() "; MSSBamRelGroupValueBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); MSSBamRelGroupValueBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("RLGV")) { filteredList.add(buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByIdIdx() "; MSSBamAnyObjBuff buff = readDerivedByIdIdx(Authorization, Id); if ((buff != null) && buff.getClassCode().equals("ANYO")) { return ((MSSBamRelGroupValueBuff) buff); } else { return (null); } } public MSSBamRelGroupValueBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByTenantIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); 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((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByScopeIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); 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((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff[] readBuffByDefSchemaIdx(MSSBamAuthorization Authorization, Long DefSchemaId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByDefSchemaIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); MSSBamAnyObjBuff[] buffList = readDerivedByDefSchemaIdx(Authorization, DefSchemaId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("ANYO")) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "MSSBamRamAnyObj.readBuffByAuthorIdx() "; MSSBamAnyObjBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); 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((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff 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 ((MSSBamRelGroupValueBuff) buff); } else { return (null); } } public MSSBamRelGroupValueBuff readBuffByUAltIdx(MSSBamAuthorization Authorization, long RelationId, short GroupOperatorId, long ToColId) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuffByUAltIdx() "; MSSBamRelGroupValueBuff buff = readDerivedByUAltIdx(Authorization, RelationId, GroupOperatorId, ToColId); if ((buff != null) && buff.getClassCode().equals("RLGV")) { return ((MSSBamRelGroupValueBuff) buff); } else { return (null); } } public MSSBamRelGroupValueBuff[] readBuffByRelationIdx(MSSBamAuthorization Authorization, long RelationId) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuffByRelationIdx() "; MSSBamRelGroupValueBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); MSSBamRelGroupValueBuff[] buffList = readDerivedByRelationIdx(Authorization, RelationId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("RLGV")) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff[] readBuffByGrpOpIdx(MSSBamAuthorization Authorization, short GroupOperatorId) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuffByGrpOpIdx() "; MSSBamRelGroupValueBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); MSSBamRelGroupValueBuff[] buffList = readDerivedByGrpOpIdx(Authorization, GroupOperatorId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("RLGV")) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public MSSBamRelGroupValueBuff[] readBuffByToColIdx(MSSBamAuthorization Authorization, long ToColId) { final String S_ProcName = "MSSBamRamRelGroupValue.readBuffByToColIdx() "; MSSBamRelGroupValueBuff buff; ArrayList<MSSBamRelGroupValueBuff> filteredList = new ArrayList<MSSBamRelGroupValueBuff>(); MSSBamRelGroupValueBuff[] buffList = readDerivedByToColIdx(Authorization, ToColId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("RLGV")) { filteredList.add((MSSBamRelGroupValueBuff) buff); } } return (filteredList.toArray(new MSSBamRelGroupValueBuff[0])); } public void updateRelGroupValue(MSSBamAuthorization Authorization, MSSBamRelGroupValueBuff Buff) { MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setRequiredId(Buff.getRequiredId()); MSSBamRelGroupValueBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateRelGroupValue", "Existing record not found", "RelGroupValue", pkey); } MSSBamRelGroupValueByUAltIdxKey existingKeyUAltIdx = schema.getFactoryRelGroupValue().newUAltIdxKey(); existingKeyUAltIdx.setRequiredRelationId(existing.getRequiredRelationId()); existingKeyUAltIdx.setRequiredGroupOperatorId(existing.getRequiredGroupOperatorId()); existingKeyUAltIdx.setRequiredToColId(existing.getRequiredToColId()); MSSBamRelGroupValueByUAltIdxKey newKeyUAltIdx = schema.getFactoryRelGroupValue().newUAltIdxKey(); newKeyUAltIdx.setRequiredRelationId(Buff.getRequiredRelationId()); newKeyUAltIdx.setRequiredGroupOperatorId(Buff.getRequiredGroupOperatorId()); newKeyUAltIdx.setRequiredToColId(Buff.getRequiredToColId()); MSSBamRelGroupValueByRelationIdxKey existingKeyRelationIdx = schema.getFactoryRelGroupValue() .newRelationIdxKey(); existingKeyRelationIdx.setRequiredRelationId(existing.getRequiredRelationId()); MSSBamRelGroupValueByRelationIdxKey newKeyRelationIdx = schema.getFactoryRelGroupValue() .newRelationIdxKey(); newKeyRelationIdx.setRequiredRelationId(Buff.getRequiredRelationId()); MSSBamRelGroupValueByGrpOpIdxKey existingKeyGrpOpIdx = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); existingKeyGrpOpIdx.setRequiredGroupOperatorId(existing.getRequiredGroupOperatorId()); MSSBamRelGroupValueByGrpOpIdxKey newKeyGrpOpIdx = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); newKeyGrpOpIdx.setRequiredGroupOperatorId(Buff.getRequiredGroupOperatorId()); MSSBamRelGroupValueByToColIdxKey existingKeyToColIdx = schema.getFactoryRelGroupValue().newToColIdxKey(); existingKeyToColIdx.setRequiredToColId(existing.getRequiredToColId()); MSSBamRelGroupValueByToColIdxKey newKeyToColIdx = schema.getFactoryRelGroupValue().newToColIdxKey(); newKeyToColIdx.setRequiredToColId(Buff.getRequiredToColId()); // Check unique indexes if (!existingKeyUAltIdx.equals(newKeyUAltIdx)) { if (dictByUAltIdx.containsKey(newKeyUAltIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateRelGroupValue", "RelGroupValueUAltIdx", newKeyUAltIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableAnyObj().readDerivedByIdIdx(Authorization, Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateRelGroupValue", "Superclass", "SuperClass", "AnyObj", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableRelation().readDerivedByIdIdx(Authorization, Buff.getRequiredRelationId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateRelGroupValue", "Container", "Relation", "Relation", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableGroupOperator().readDerivedByIdIdx(Authorization, Buff.getRequiredGroupOperatorId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateRelGroupValue", "Lookup", "LookupGroupOperator", "GroupOperator", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableValue().readDerivedByIdIdx(Authorization, Buff.getRequiredToColId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateRelGroupValue", "Lookup", "LookupToCol", "Value", null); } } } // Update is valid SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); dictByUAltIdx.remove(existingKeyUAltIdx); dictByUAltIdx.put(newKeyUAltIdx, Buff); subdict = dictByRelationIdx.get(existingKeyRelationIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByRelationIdx.containsKey(newKeyRelationIdx)) { subdict = dictByRelationIdx.get(newKeyRelationIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByRelationIdx.put(newKeyRelationIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByGrpOpIdx.get(existingKeyGrpOpIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByGrpOpIdx.containsKey(newKeyGrpOpIdx)) { subdict = dictByGrpOpIdx.get(newKeyGrpOpIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByGrpOpIdx.put(newKeyGrpOpIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByToColIdx.get(existingKeyToColIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByToColIdx.containsKey(newKeyToColIdx)) { subdict = dictByToColIdx.get(newKeyToColIdx); } else { subdict = new TreeMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff>(); dictByToColIdx.put(newKeyToColIdx, subdict); } subdict.put(pkey, Buff); } public void deleteRelGroupValue(MSSBamAuthorization Authorization, MSSBamRelGroupValueBuff Buff) { final String S_ProcName = "MSSBamRamRelGroupValueTable.deleteRelGroupValue() "; MSSBamAnyObjPKey pkey = schema.getFactoryAnyObj().newPKey(); pkey.setRequiredId(schema.nextAnyObjIdGen()); MSSBamRelGroupValueBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "deleteRelGroupValue", "Existing record not found", "RelGroupValue", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteRelGroupValue", pkey); } MSSBamRelGroupValueByUAltIdxKey keyUAltIdx = schema.getFactoryRelGroupValue().newUAltIdxKey(); keyUAltIdx.setRequiredRelationId(existing.getRequiredRelationId()); keyUAltIdx.setRequiredGroupOperatorId(existing.getRequiredGroupOperatorId()); keyUAltIdx.setRequiredToColId(existing.getRequiredToColId()); MSSBamRelGroupValueByRelationIdxKey keyRelationIdx = schema.getFactoryRelGroupValue().newRelationIdxKey(); keyRelationIdx.setRequiredRelationId(existing.getRequiredRelationId()); MSSBamRelGroupValueByGrpOpIdxKey keyGrpOpIdx = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); keyGrpOpIdx.setRequiredGroupOperatorId(existing.getRequiredGroupOperatorId()); MSSBamRelGroupValueByToColIdxKey keyToColIdx = schema.getFactoryRelGroupValue().newToColIdxKey(); keyToColIdx.setRequiredToColId(existing.getRequiredToColId()); // Validate reverse foreign keys // Delete is valid SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdict; dictByPKey.remove(pkey); dictByUAltIdx.remove(keyUAltIdx); subdict = dictByRelationIdx.get(keyRelationIdx); subdict.remove(pkey); subdict = dictByGrpOpIdx.get(keyGrpOpIdx); subdict.remove(pkey); subdict = dictByToColIdx.get(keyToColIdx); subdict.remove(pkey); } public MSSBamCursor openRelGroupValueCursorAll(MSSBamAuthorization Authorization) { MSSBamCursor cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public MSSBamCursor openRelGroupValueCursorByRelationIdx(MSSBamAuthorization Authorization, long RelationId) { MSSBamCursor cursor; MSSBamRelGroupValueByRelationIdxKey key = schema.getFactoryRelGroupValue().newRelationIdxKey(); key.setRequiredRelationId(RelationId); if (dictByRelationIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictRelationIdx = dictByRelationIdx.get(key); cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, subdictRelationIdx.values()); } else { cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, new ArrayList<MSSBamRelGroupValueBuff>()); } return (cursor); } public MSSBamCursor openRelGroupValueCursorByGrpOpIdx(MSSBamAuthorization Authorization, short GroupOperatorId) { MSSBamCursor cursor; MSSBamRelGroupValueByGrpOpIdxKey key = schema.getFactoryRelGroupValue().newGrpOpIdxKey(); key.setRequiredGroupOperatorId(GroupOperatorId); if (dictByGrpOpIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictGrpOpIdx = dictByGrpOpIdx.get(key); cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, subdictGrpOpIdx.values()); } else { cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, new ArrayList<MSSBamRelGroupValueBuff>()); } return (cursor); } public MSSBamCursor openRelGroupValueCursorByToColIdx(MSSBamAuthorization Authorization, long ToColId) { MSSBamCursor cursor; MSSBamRelGroupValueByToColIdxKey key = schema.getFactoryRelGroupValue().newToColIdxKey(); key.setRequiredToColId(ToColId); if (dictByToColIdx.containsKey(key)) { SortedMap<MSSBamAnyObjPKey, MSSBamRelGroupValueBuff> subdictToColIdx = dictByToColIdx.get(key); cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, subdictToColIdx.values()); } else { cursor = new MSSBamRamRelGroupValueCursor(Authorization, schema, new ArrayList<MSSBamRelGroupValueBuff>()); } return (cursor); } public void closeRelGroupValueCursor(MSSBamCursor Cursor) { // Cursor.DataReader.Close(); } public MSSBamRelGroupValueBuff nextRelGroupValueCursor(MSSBamCursor Cursor) { MSSBamRamRelGroupValueCursor cursor = (MSSBamRamRelGroupValueCursor) Cursor; MSSBamRelGroupValueBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public MSSBamRelGroupValueBuff prevRelGroupValueCursor(MSSBamCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; MSSBamRelGroupValueBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextRelGroupValueCursor(Cursor); } return (rec); } public MSSBamRelGroupValueBuff firstRelGroupValueCursor(MSSBamCursor Cursor) { int targetRowIdx = 1; MSSBamRelGroupValueBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextRelGroupValueCursor(Cursor); } return (rec); } public MSSBamRelGroupValueBuff lastRelGroupValueCursor(MSSBamCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastRelGroupValueCursor"); } public MSSBamRelGroupValueBuff nthRelGroupValueCursor(MSSBamCursor Cursor, int Idx) { int targetRowIdx = Idx; MSSBamRelGroupValueBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextRelGroupValueCursor(Cursor); } return (rec); } }