Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for MajorVersion. /* * CF Asterisk 11 Configuration Model * * Copyright (c) 2013-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/>. * * This source code incorporates modified modules originally licensed * under the Apache 2.0 license by MSS Code Factory including CFSecurity * (net-sourceforge-msscodefactory-2.0-cfsecurity.xml), * CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and * CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the * required models being available as part of the MSS Code Factory 1.11 * distribution source and install zips. * * You can download installations of MSS Code Factory 1.11 from * http://msscodefactory.sourceforge.net/ * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam; 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.cfasterisk.v2_0.CFAst.*; import net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstRam.*; /* * CFAstRamMajorVersionTable in-memory RAM DbIO implementation * for MajorVersion. */ public class CFAstRamMajorVersionTable implements ICFAstMajorVersionTable { private CFAstRamSchema schema; private Map<CFAstDomainBasePKey, CFAstMajorVersionBuff> dictByPKey = new HashMap<CFAstDomainBasePKey, CFAstMajorVersionBuff>(); private SortedMap<CFAstMajorVersionByPPrjIdxKey, SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff>> dictByPPrjIdx = new TreeMap<CFAstMajorVersionByPPrjIdxKey, SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff>>(); private SortedMap<CFAstMajorVersionByNameIdxKey, CFAstMajorVersionBuff> dictByNameIdx = new TreeMap<CFAstMajorVersionByNameIdxKey, CFAstMajorVersionBuff>(); public CFAstRamMajorVersionTable(CFAstRamSchema argSchema) { schema = argSchema; } public void createMajorVersion(CFAstAuthorization Authorization, CFAstMajorVersionBuff Buff) { schema.getTableVersion().createVersion(Authorization, Buff); CFAstDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAstMajorVersionByPPrjIdxKey keyPPrjIdx = schema.getFactoryMajorVersion().newPPrjIdxKey(); keyPPrjIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyPPrjIdx.setRequiredParentProjectId(Buff.getRequiredParentProjectId()); CFAstMajorVersionByNameIdxKey keyNameIdx = schema.getFactoryMajorVersion().newNameIdxKey(); keyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyNameIdx.setRequiredParentProjectId(Buff.getRequiredParentProjectId()); keyNameIdx.setRequiredName(Buff.getRequiredName()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createMajorVersion", pkey); } if (dictByNameIdx.containsKey(keyNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createMajorVersion", "MajorVersionNameIdx", keyNameIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableVersion().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createMajorVersion", "Superclass", "SuperClass", "Version", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableRealProject().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredParentProjectId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createMajorVersion", "Container", "ParentProject", "RealProject", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff> subdictPPrjIdx; if (dictByPPrjIdx.containsKey(keyPPrjIdx)) { subdictPPrjIdx = dictByPPrjIdx.get(keyPPrjIdx); } else { subdictPPrjIdx = new TreeMap<CFAstDomainBasePKey, CFAstMajorVersionBuff>(); dictByPPrjIdx.put(keyPPrjIdx, subdictPPrjIdx); } subdictPPrjIdx.put(pkey, Buff); dictByNameIdx.put(keyNameIdx, Buff); } public CFAstMajorVersionBuff readDerived(CFAstAuthorization Authorization, CFAstDomainBasePKey PKey) { final String S_ProcName = "CFAstRamMajorVersion.readDerived() "; CFAstDomainBasePKey key = schema.getFactoryDomainBase().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredId(PKey.getRequiredId()); CFAstMajorVersionBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstMajorVersionBuff lockDerived(CFAstAuthorization Authorization, CFAstDomainBasePKey PKey) { final String S_ProcName = "CFAstRamMajorVersion.readDerived() "; CFAstDomainBasePKey key = schema.getFactoryDomainBase().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredId(PKey.getRequiredId()); CFAstMajorVersionBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstMajorVersionBuff[] readAllDerived(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamMajorVersion.readAllDerived() "; CFAstMajorVersionBuff[] retList = new CFAstMajorVersionBuff[dictByPKey.values().size()]; Iterator<CFAstMajorVersionBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAstMajorVersionBuff[] readDerivedByTenantIdx(CFAstAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAstRamDomainBase.readDerivedByTenantIdx() "; CFAstDomainBaseBuff buffList[] = schema.getTableDomainBase().readDerivedByTenantIdx(Authorization, TenantId); if (buffList == null) { return (null); } else { CFAstDomainBaseBuff buff; ArrayList<CFAstMajorVersionBuff> filteredList = new ArrayList<CFAstMajorVersionBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFAstMajorVersionBuff)) { filteredList.add((CFAstMajorVersionBuff) buff); } } return (filteredList.toArray(new CFAstMajorVersionBuff[0])); } } public CFAstMajorVersionBuff[] readDerivedByPPrjIdx(CFAstAuthorization Authorization, long TenantId, long ParentProjectId) { final String S_ProcName = "CFAstRamMajorVersion.readDerivedByPPrjIdx() "; CFAstMajorVersionByPPrjIdxKey key = schema.getFactoryMajorVersion().newPPrjIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredParentProjectId(ParentProjectId); CFAstMajorVersionBuff[] recArray; if (dictByPPrjIdx.containsKey(key)) { SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff> subdictPPrjIdx = dictByPPrjIdx.get(key); recArray = new CFAstMajorVersionBuff[subdictPPrjIdx.size()]; Iterator<CFAstMajorVersionBuff> iter = subdictPPrjIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFAstMajorVersionBuff[0]; } return (recArray); } public CFAstMajorVersionBuff readDerivedByNameIdx(CFAstAuthorization Authorization, long TenantId, long ParentProjectId, String Name) { final String S_ProcName = "CFAstRamMajorVersion.readDerivedByNameIdx() "; CFAstMajorVersionByNameIdxKey key = schema.getFactoryMajorVersion().newNameIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredParentProjectId(ParentProjectId); key.setRequiredName(Name); CFAstMajorVersionBuff buff; if (dictByNameIdx.containsKey(key)) { buff = dictByNameIdx.get(key); } else { buff = null; } return (buff); } public CFAstMajorVersionBuff readDerivedByIdIdx(CFAstAuthorization Authorization, long TenantId, long Id) { final String S_ProcName = "CFAstRamDomainBase.readDerivedByIdIdx() "; CFAstDomainBasePKey key = schema.getFactoryDomainBase().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredId(Id); CFAstMajorVersionBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAstMajorVersionBuff readBuff(CFAstAuthorization Authorization, CFAstDomainBasePKey PKey) { final String S_ProcName = "CFAstRamMajorVersion.readBuff() "; CFAstMajorVersionBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("MJVR"))) { buff = null; } return (buff); } public CFAstMajorVersionBuff lockBuff(CFAstAuthorization Authorization, CFAstDomainBasePKey PKey) { final String S_ProcName = "CFAstRamMajorVersion.readBuff() "; CFAstMajorVersionBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("MJVR"))) { buff = null; } return (buff); } public CFAstMajorVersionBuff[] readAllBuff(CFAstAuthorization Authorization) { final String S_ProcName = "CFAstRamMajorVersion.readAllBuff() "; CFAstMajorVersionBuff buff; ArrayList<CFAstMajorVersionBuff> filteredList = new ArrayList<CFAstMajorVersionBuff>(); CFAstMajorVersionBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("MJVR")) { filteredList.add(buff); } } return (filteredList.toArray(new CFAstMajorVersionBuff[0])); } public CFAstMajorVersionBuff readBuffByIdIdx(CFAstAuthorization Authorization, long TenantId, long Id) { final String S_ProcName = "CFAstRamDomainBase.readBuffByIdIdx() "; CFAstDomainBaseBuff buff = readDerivedByIdIdx(Authorization, TenantId, Id); if ((buff != null) && buff.getClassCode().equals("BDOM")) { return ((CFAstMajorVersionBuff) buff); } else { return (null); } } public CFAstMajorVersionBuff[] readBuffByTenantIdx(CFAstAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAstRamDomainBase.readBuffByTenantIdx() "; CFAstDomainBaseBuff buff; ArrayList<CFAstMajorVersionBuff> filteredList = new ArrayList<CFAstMajorVersionBuff>(); CFAstDomainBaseBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("BDOM")) { filteredList.add((CFAstMajorVersionBuff) buff); } } return (filteredList.toArray(new CFAstMajorVersionBuff[0])); } public CFAstMajorVersionBuff[] readBuffByPPrjIdx(CFAstAuthorization Authorization, long TenantId, long ParentProjectId) { final String S_ProcName = "CFAstRamMajorVersion.readBuffByPPrjIdx() "; CFAstMajorVersionBuff buff; ArrayList<CFAstMajorVersionBuff> filteredList = new ArrayList<CFAstMajorVersionBuff>(); CFAstMajorVersionBuff[] buffList = readDerivedByPPrjIdx(Authorization, TenantId, ParentProjectId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("MJVR")) { filteredList.add((CFAstMajorVersionBuff) buff); } } return (filteredList.toArray(new CFAstMajorVersionBuff[0])); } public CFAstMajorVersionBuff readBuffByNameIdx(CFAstAuthorization Authorization, long TenantId, long ParentProjectId, String Name) { final String S_ProcName = "CFAstRamMajorVersion.readBuffByNameIdx() "; CFAstMajorVersionBuff buff = readDerivedByNameIdx(Authorization, TenantId, ParentProjectId, Name); if ((buff != null) && buff.getClassCode().equals("MJVR")) { return ((CFAstMajorVersionBuff) buff); } else { return (null); } } public void updateMajorVersion(CFAstAuthorization Authorization, CFAstMajorVersionBuff Buff) { schema.getTableVersion().updateVersion(Authorization, Buff); CFAstDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAstMajorVersionBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateMajorVersion", "Existing record not found", "MajorVersion", pkey); } CFAstMajorVersionByPPrjIdxKey existingKeyPPrjIdx = schema.getFactoryMajorVersion().newPPrjIdxKey(); existingKeyPPrjIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyPPrjIdx.setRequiredParentProjectId(existing.getRequiredParentProjectId()); CFAstMajorVersionByPPrjIdxKey newKeyPPrjIdx = schema.getFactoryMajorVersion().newPPrjIdxKey(); newKeyPPrjIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyPPrjIdx.setRequiredParentProjectId(Buff.getRequiredParentProjectId()); CFAstMajorVersionByNameIdxKey existingKeyNameIdx = schema.getFactoryMajorVersion().newNameIdxKey(); existingKeyNameIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyNameIdx.setRequiredParentProjectId(existing.getRequiredParentProjectId()); existingKeyNameIdx.setRequiredName(existing.getRequiredName()); CFAstMajorVersionByNameIdxKey newKeyNameIdx = schema.getFactoryMajorVersion().newNameIdxKey(); newKeyNameIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyNameIdx.setRequiredParentProjectId(Buff.getRequiredParentProjectId()); newKeyNameIdx.setRequiredName(Buff.getRequiredName()); // Check unique indexes if (!existingKeyNameIdx.equals(newKeyNameIdx)) { if (dictByNameIdx.containsKey(newKeyNameIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateMajorVersion", "MajorVersionNameIdx", newKeyNameIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableVersion().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateMajorVersion", "Superclass", "SuperClass", "Version", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableRealProject().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredParentProjectId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateMajorVersion", "Container", "ParentProject", "RealProject", null); } } } // Update is valid SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByPPrjIdx.get(existingKeyPPrjIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByPPrjIdx.containsKey(newKeyPPrjIdx)) { subdict = dictByPPrjIdx.get(newKeyPPrjIdx); } else { subdict = new TreeMap<CFAstDomainBasePKey, CFAstMajorVersionBuff>(); dictByPPrjIdx.put(newKeyPPrjIdx, subdict); } subdict.put(pkey, Buff); dictByNameIdx.remove(existingKeyNameIdx); dictByNameIdx.put(newKeyNameIdx, Buff); } public void deleteMajorVersion(CFAstAuthorization Authorization, CFAstMajorVersionBuff Buff) { final String S_ProcName = "CFAstRamMajorVersionTable.deleteMajorVersion() "; CFAstDomainBasePKey pkey = schema.getFactoryDomainBase().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredId(Buff.getRequiredId()); CFAstMajorVersionBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteMajorVersion", pkey); } CFAstMajorVersionByPPrjIdxKey keyPPrjIdx = schema.getFactoryMajorVersion().newPPrjIdxKey(); keyPPrjIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyPPrjIdx.setRequiredParentProjectId(existing.getRequiredParentProjectId()); CFAstMajorVersionByNameIdxKey keyNameIdx = schema.getFactoryMajorVersion().newNameIdxKey(); keyNameIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyNameIdx.setRequiredParentProjectId(existing.getRequiredParentProjectId()); keyNameIdx.setRequiredName(existing.getRequiredName()); // Validate reverse foreign keys // Delete is valid schema.getTableMinorVersion().deleteMinorVersionByMajorIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredId()); SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff> subdict; dictByPKey.remove(pkey); subdict = dictByPPrjIdx.get(keyPPrjIdx); subdict.remove(pkey); dictByNameIdx.remove(keyNameIdx); schema.getTableVersion().deleteVersion(Authorization, Buff); } public void deleteMajorVersionByPPrjIdx(CFAstAuthorization Authorization, long argTenantId, long argParentProjectId) { CFAstMajorVersionByPPrjIdxKey key = schema.getFactoryMajorVersion().newPPrjIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredParentProjectId(argParentProjectId); deleteMajorVersionByPPrjIdx(Authorization, key); } public void deleteMajorVersionByPPrjIdx(CFAstAuthorization Authorization, CFAstMajorVersionByPPrjIdxKey argKey) { CFAstMajorVersionBuff cur; LinkedList<CFAstMajorVersionBuff> matchSet = new LinkedList<CFAstMajorVersionBuff>(); Iterator<CFAstMajorVersionBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstMajorVersionBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteMajorVersion(Authorization, cur); } } public void deleteMajorVersionByNameIdx(CFAstAuthorization Authorization, long argTenantId, long argParentProjectId, String argName) { CFAstMajorVersionByNameIdxKey key = schema.getFactoryMajorVersion().newNameIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredParentProjectId(argParentProjectId); key.setRequiredName(argName); deleteMajorVersionByNameIdx(Authorization, key); } public void deleteMajorVersionByNameIdx(CFAstAuthorization Authorization, CFAstMajorVersionByNameIdxKey argKey) { CFAstMajorVersionBuff cur; LinkedList<CFAstMajorVersionBuff> matchSet = new LinkedList<CFAstMajorVersionBuff>(); Iterator<CFAstMajorVersionBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstMajorVersionBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteMajorVersion(Authorization, cur); } } public void deleteMajorVersionByIdIdx(CFAstAuthorization Authorization, long argTenantId, long argId) { CFAstDomainBasePKey key = schema.getFactoryDomainBase().newPKey(); key.setRequiredTenantId(argTenantId); key.setRequiredId(argId); deleteMajorVersionByIdIdx(Authorization, key); } public void deleteMajorVersionByIdIdx(CFAstAuthorization Authorization, CFAstDomainBasePKey argKey) { CFAstMajorVersionBuff cur; LinkedList<CFAstMajorVersionBuff> matchSet = new LinkedList<CFAstMajorVersionBuff>(); Iterator<CFAstMajorVersionBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstMajorVersionBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteMajorVersion(Authorization, cur); } } public void deleteMajorVersionByTenantIdx(CFAstAuthorization Authorization, long argTenantId) { CFAstDomainBaseByTenantIdxKey key = schema.getFactoryDomainBase().newTenantIdxKey(); key.setRequiredTenantId(argTenantId); deleteMajorVersionByTenantIdx(Authorization, key); } public void deleteMajorVersionByTenantIdx(CFAstAuthorization Authorization, CFAstDomainBaseByTenantIdxKey argKey) { CFAstMajorVersionBuff cur; LinkedList<CFAstMajorVersionBuff> matchSet = new LinkedList<CFAstMajorVersionBuff>(); Iterator<CFAstMajorVersionBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAstMajorVersionBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteMajorVersion(Authorization, cur); } } public CFAstCursor openMajorVersionCursorAll(CFAstAuthorization Authorization) { CFAstCursor cursor = new CFAstRamMajorVersionCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFAstCursor openMajorVersionCursorByPPrjIdx(CFAstAuthorization Authorization, long TenantId, long ParentProjectId) { CFAstCursor cursor; CFAstMajorVersionByPPrjIdxKey key = schema.getFactoryMajorVersion().newPPrjIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredParentProjectId(ParentProjectId); if (dictByPPrjIdx.containsKey(key)) { SortedMap<CFAstDomainBasePKey, CFAstMajorVersionBuff> subdictPPrjIdx = dictByPPrjIdx.get(key); cursor = new CFAstRamMajorVersionCursor(Authorization, schema, subdictPPrjIdx.values()); } else { cursor = new CFAstRamMajorVersionCursor(Authorization, schema, new ArrayList<CFAstMajorVersionBuff>()); } return (cursor); } public void closeMajorVersionCursor(CFAstCursor Cursor) { // Cursor.DataReader.Close(); } public CFAstMajorVersionBuff nextMajorVersionCursor(CFAstCursor Cursor) { CFAstRamMajorVersionCursor cursor = (CFAstRamMajorVersionCursor) Cursor; CFAstMajorVersionBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAstMajorVersionBuff prevMajorVersionCursor(CFAstCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAstMajorVersionBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextMajorVersionCursor(Cursor); } return (rec); } public CFAstMajorVersionBuff firstMajorVersionCursor(CFAstCursor Cursor) { int targetRowIdx = 1; CFAstMajorVersionBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextMajorVersionCursor(Cursor); } return (rec); } public CFAstMajorVersionBuff lastMajorVersionCursor(CFAstCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastMajorVersionCursor"); } public CFAstMajorVersionBuff nthMajorVersionCursor(CFAstCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAstMajorVersionBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextMajorVersionCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }