Java tutorial
// Description: Java 8 in-memory RAM DbIO implementation for AsteriskConf. /* * Code Factory Asterisk 11 Configuration Model * * Copyright (c) 2014-2015 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/>. * */ package net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskRam; import java.sql.*; import java.util.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cflib.v2_3.CFLib.*; import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurity.*; import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternet.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsterisk.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*; import net.sourceforge.msscodefactory.cfsecurity.v2_4.CFSecurityObj.*; import net.sourceforge.msscodefactory.cfinternet.v2_4.CFInternetObj.*; import net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskObj.*; /* * CFAsteriskRamAsteriskConfTable in-memory RAM DbIO implementation * for AsteriskConf. */ public class CFAsteriskRamAsteriskConfTable implements ICFAsteriskAsteriskConfTable { private ICFAsteriskSchema schema; private Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> dictByPKey = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>(); private Map<CFAsteriskAsteriskConfByConfClusterIdxKey, Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>> dictByConfClusterIdx = new HashMap<CFAsteriskAsteriskConfByConfClusterIdxKey, Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>>(); public CFAsteriskRamAsteriskConfTable(ICFAsteriskSchema argSchema) { schema = argSchema; } public void createAsteriskConf(CFSecurityAuthorization Authorization, CFAsteriskAsteriskConfBuff Buff) { final String S_ProcName = "createAsteriskConf"; schema.getTableConfigurationFile().createConfigurationFile(Authorization, Buff); CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setClassCode(Buff.getClassCode()); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskAsteriskConfByConfClusterIdxKey keyConfClusterIdx = schema.getFactoryAsteriskConf() .newConfClusterIdxKey(); keyConfClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), S_ProcName, pkey); } // Validate foreign keys { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), S_ProcName, "Superclass", "SuperClass", "ConfigurationFile", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdictConfClusterIdx; if (dictByConfClusterIdx.containsKey(keyConfClusterIdx)) { subdictConfClusterIdx = dictByConfClusterIdx.get(keyConfClusterIdx); } else { subdictConfClusterIdx = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>(); dictByConfClusterIdx.put(keyConfClusterIdx, subdictConfClusterIdx); } subdictConfClusterIdx.put(pkey, Buff); } public CFAsteriskAsteriskConfBuff readDerived(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readDerived"; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredId(PKey.getRequiredId()); CFAsteriskAsteriskConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskAsteriskConfBuff lockDerived(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readDerived"; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(PKey.getRequiredClusterId()); key.setRequiredId(PKey.getRequiredId()); CFAsteriskAsteriskConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskAsteriskConfBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readAllDerived"; CFAsteriskAsteriskConfBuff[] retList = new CFAsteriskAsteriskConfBuff[dictByPKey.values().size()]; Iterator<CFAsteriskAsteriskConfBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFAsteriskAsteriskConfBuff[] readDerivedByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByClusterIdx"; CFAsteriskConfigurationFileBuff buffList[] = schema.getTableConfigurationFile() .readDerivedByClusterIdx(Authorization, ClusterId); if (buffList == null) { return (null); } else { CFAsteriskConfigurationFileBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFAsteriskAsteriskConfBuff)) { filteredList.add((CFAsteriskAsteriskConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } } public CFAsteriskAsteriskConfBuff[] readDerivedByHostIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByHostIdx"; CFAsteriskConfigurationFileBuff buffList[] = schema.getTableConfigurationFile() .readDerivedByHostIdx(Authorization, ClusterId, HostNodeId); if (buffList == null) { return (null); } else { CFAsteriskConfigurationFileBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && (buff instanceof CFAsteriskAsteriskConfBuff)) { filteredList.add((CFAsteriskAsteriskConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } } public CFAsteriskAsteriskConfBuff readDerivedByUNameIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId, String FileFullName) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByUNameIdx"; CFAsteriskConfigurationFileBuff buff = schema.getTableConfigurationFile() .readDerivedByUNameIdx(Authorization, ClusterId, HostNodeId, FileFullName); if (buff == null) { return (null); } else if (buff instanceof CFAsteriskAsteriskConfBuff) { return ((CFAsteriskAsteriskConfBuff) buff); } else { return (null); } } public CFAsteriskAsteriskConfBuff[] readDerivedByConfClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readDerivedByConfClusterIdx"; CFAsteriskAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey(); key.setRequiredClusterId(ClusterId); CFAsteriskAsteriskConfBuff[] recArray; if (dictByConfClusterIdx.containsKey(key)) { Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdictConfClusterIdx = dictByConfClusterIdx .get(key); recArray = new CFAsteriskAsteriskConfBuff[subdictConfClusterIdx.size()]; Iterator<CFAsteriskAsteriskConfBuff> iter = subdictConfClusterIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdictConfClusterIdx = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>(); dictByConfClusterIdx.put(key, subdictConfClusterIdx); recArray = new CFAsteriskAsteriskConfBuff[0]; } return (recArray); } public CFAsteriskAsteriskConfBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long Id) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readDerivedByIdIdx() "; CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(ClusterId); key.setRequiredId(Id); CFAsteriskAsteriskConfBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFAsteriskAsteriskConfBuff readBuff(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readBuff"; CFAsteriskAsteriskConfBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("CASC"))) { buff = null; } return (buff); } public CFAsteriskAsteriskConfBuff lockBuff(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey PKey) { final String S_ProcName = "lockBuff"; CFAsteriskAsteriskConfBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("CASC"))) { buff = null; } return (buff); } public CFAsteriskAsteriskConfBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readAllBuff"; CFAsteriskAsteriskConfBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); CFAsteriskAsteriskConfBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CASC")) { filteredList.add(buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } public CFAsteriskAsteriskConfBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long ClusterId, long Id) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByIdIdx() "; CFAsteriskAsteriskConfBuff buff = readDerivedByIdIdx(Authorization, ClusterId, Id); if ((buff != null) && buff.getClassCode().equals("CONF")) { return ((CFAsteriskAsteriskConfBuff) buff); } else { return (null); } } public CFAsteriskAsteriskConfBuff[] readBuffByClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByClusterIdx() "; CFAsteriskAsteriskConfBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); CFAsteriskAsteriskConfBuff[] buffList = readDerivedByClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CONF")) { filteredList.add((CFAsteriskAsteriskConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } public CFAsteriskAsteriskConfBuff[] readBuffByHostIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByHostIdx() "; CFAsteriskAsteriskConfBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); CFAsteriskAsteriskConfBuff[] buffList = readDerivedByHostIdx(Authorization, ClusterId, HostNodeId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CONF")) { filteredList.add((CFAsteriskAsteriskConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } public CFAsteriskAsteriskConfBuff readBuffByUNameIdx(CFSecurityAuthorization Authorization, long ClusterId, long HostNodeId, String FileFullName) { final String S_ProcName = "CFAsteriskRamConfigurationFile.readBuffByUNameIdx() "; CFAsteriskAsteriskConfBuff buff = readDerivedByUNameIdx(Authorization, ClusterId, HostNodeId, FileFullName); if ((buff != null) && buff.getClassCode().equals("CONF")) { return ((CFAsteriskAsteriskConfBuff) buff); } else { return (null); } } public CFAsteriskAsteriskConfBuff[] readBuffByConfClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { final String S_ProcName = "CFAsteriskRamAsteriskConf.readBuffByConfClusterIdx() "; CFAsteriskAsteriskConfBuff buff; ArrayList<CFAsteriskAsteriskConfBuff> filteredList = new ArrayList<CFAsteriskAsteriskConfBuff>(); CFAsteriskAsteriskConfBuff[] buffList = readDerivedByConfClusterIdx(Authorization, ClusterId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("CASC")) { filteredList.add((CFAsteriskAsteriskConfBuff) buff); } } return (filteredList.toArray(new CFAsteriskAsteriskConfBuff[0])); } public void updateAsteriskConf(CFSecurityAuthorization Authorization, CFAsteriskAsteriskConfBuff Buff) { schema.getTableConfigurationFile().updateConfigurationFile(Authorization, Buff); CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskAsteriskConfBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateAsteriskConf", "Existing record not found", "AsteriskConf", pkey); } CFAsteriskAsteriskConfByConfClusterIdxKey existingKeyConfClusterIdx = schema.getFactoryAsteriskConf() .newConfClusterIdxKey(); existingKeyConfClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); CFAsteriskAsteriskConfByConfClusterIdxKey newKeyConfClusterIdx = schema.getFactoryAsteriskConf() .newConfClusterIdxKey(); newKeyConfClusterIdx.setRequiredClusterId(Buff.getRequiredClusterId()); // Check unique indexes // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableConfigurationFile().readDerivedByIdIdx(Authorization, Buff.getRequiredClusterId(), Buff.getRequiredId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateAsteriskConf", "Superclass", "SuperClass", "ConfigurationFile", null); } } } // Update is valid Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByConfClusterIdx.get(existingKeyConfClusterIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByConfClusterIdx.containsKey(newKeyConfClusterIdx)) { subdict = dictByConfClusterIdx.get(newKeyConfClusterIdx); } else { subdict = new HashMap<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff>(); dictByConfClusterIdx.put(newKeyConfClusterIdx, subdict); } subdict.put(pkey, Buff); } public void deleteAsteriskConf(CFSecurityAuthorization Authorization, CFAsteriskAsteriskConfBuff Buff) { final String S_ProcName = "CFAsteriskRamAsteriskConfTable.deleteAsteriskConf() "; CFAsteriskConfigurationFilePKey pkey = schema.getFactoryConfigurationFile().newPKey(); pkey.setRequiredClusterId(Buff.getRequiredClusterId()); pkey.setRequiredId(Buff.getRequiredId()); CFAsteriskAsteriskConfBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteAsteriskConf", pkey); } CFAsteriskAsteriskConfByConfClusterIdxKey keyConfClusterIdx = schema.getFactoryAsteriskConf() .newConfClusterIdxKey(); keyConfClusterIdx.setRequiredClusterId(existing.getRequiredClusterId()); // Validate reverse foreign keys // Delete is valid Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdict; dictByPKey.remove(pkey); subdict = dictByConfClusterIdx.get(keyConfClusterIdx); subdict.remove(pkey); schema.getTableConfigurationFile().deleteConfigurationFile(Authorization, Buff); } public void deleteAsteriskConfByConfClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) { CFAsteriskAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteAsteriskConfByConfClusterIdx(Authorization, key); } public void deleteAsteriskConfByConfClusterIdx(CFSecurityAuthorization Authorization, CFAsteriskAsteriskConfByConfClusterIdxKey argKey) { CFAsteriskAsteriskConfBuff cur; LinkedList<CFAsteriskAsteriskConfBuff> matchSet = new LinkedList<CFAsteriskAsteriskConfBuff>(); Iterator<CFAsteriskAsteriskConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskAsteriskConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteAsteriskConf(Authorization, cur); } } public void deleteAsteriskConfByIdIdx(CFSecurityAuthorization Authorization, long argClusterId, long argId) { CFAsteriskConfigurationFilePKey key = schema.getFactoryConfigurationFile().newPKey(); key.setRequiredClusterId(argClusterId); key.setRequiredId(argId); deleteAsteriskConfByIdIdx(Authorization, key); } public void deleteAsteriskConfByIdIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFilePKey argKey) { CFAsteriskAsteriskConfBuff cur; LinkedList<CFAsteriskAsteriskConfBuff> matchSet = new LinkedList<CFAsteriskAsteriskConfBuff>(); Iterator<CFAsteriskAsteriskConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskAsteriskConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteAsteriskConf(Authorization, cur); } } public void deleteAsteriskConfByClusterIdx(CFSecurityAuthorization Authorization, long argClusterId) { CFAsteriskConfigurationFileByClusterIdxKey key = schema.getFactoryConfigurationFile().newClusterIdxKey(); key.setRequiredClusterId(argClusterId); deleteAsteriskConfByClusterIdx(Authorization, key); } public void deleteAsteriskConfByClusterIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByClusterIdxKey argKey) { CFAsteriskAsteriskConfBuff cur; LinkedList<CFAsteriskAsteriskConfBuff> matchSet = new LinkedList<CFAsteriskAsteriskConfBuff>(); Iterator<CFAsteriskAsteriskConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskAsteriskConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteAsteriskConf(Authorization, cur); } } public void deleteAsteriskConfByHostIdx(CFSecurityAuthorization Authorization, long argClusterId, long argHostNodeId) { CFAsteriskConfigurationFileByHostIdxKey key = schema.getFactoryConfigurationFile().newHostIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredHostNodeId(argHostNodeId); deleteAsteriskConfByHostIdx(Authorization, key); } public void deleteAsteriskConfByHostIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByHostIdxKey argKey) { CFAsteriskAsteriskConfBuff cur; LinkedList<CFAsteriskAsteriskConfBuff> matchSet = new LinkedList<CFAsteriskAsteriskConfBuff>(); Iterator<CFAsteriskAsteriskConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskAsteriskConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteAsteriskConf(Authorization, cur); } } public void deleteAsteriskConfByUNameIdx(CFSecurityAuthorization Authorization, long argClusterId, long argHostNodeId, String argFileFullName) { CFAsteriskConfigurationFileByUNameIdxKey key = schema.getFactoryConfigurationFile().newUNameIdxKey(); key.setRequiredClusterId(argClusterId); key.setRequiredHostNodeId(argHostNodeId); key.setRequiredFileFullName(argFileFullName); deleteAsteriskConfByUNameIdx(Authorization, key); } public void deleteAsteriskConfByUNameIdx(CFSecurityAuthorization Authorization, CFAsteriskConfigurationFileByUNameIdxKey argKey) { CFAsteriskAsteriskConfBuff cur; LinkedList<CFAsteriskAsteriskConfBuff> matchSet = new LinkedList<CFAsteriskAsteriskConfBuff>(); Iterator<CFAsteriskAsteriskConfBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFAsteriskAsteriskConfBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteAsteriskConf(Authorization, cur); } } public CFSecurityCursor openAsteriskConfCursorAll(CFSecurityAuthorization Authorization) { CFSecurityCursor cursor = new CFAsteriskRamAsteriskConfCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFSecurityCursor openAsteriskConfCursorByConfClusterIdx(CFSecurityAuthorization Authorization, long ClusterId) { CFSecurityCursor cursor; CFAsteriskAsteriskConfByConfClusterIdxKey key = schema.getFactoryAsteriskConf().newConfClusterIdxKey(); key.setRequiredClusterId(ClusterId); if (dictByConfClusterIdx.containsKey(key)) { Map<CFAsteriskConfigurationFilePKey, CFAsteriskAsteriskConfBuff> subdictConfClusterIdx = dictByConfClusterIdx .get(key); cursor = new CFAsteriskRamAsteriskConfCursor(Authorization, schema, subdictConfClusterIdx.values()); } else { cursor = new CFAsteriskRamAsteriskConfCursor(Authorization, schema, new ArrayList<CFAsteriskAsteriskConfBuff>()); } return (cursor); } public void closeAsteriskConfCursor(CFSecurityCursor Cursor) { // Cursor.DataReader.Close(); } public CFAsteriskAsteriskConfBuff nextAsteriskConfCursor(CFSecurityCursor Cursor) { CFAsteriskRamAsteriskConfCursor cursor = (CFAsteriskRamAsteriskConfCursor) Cursor; CFAsteriskAsteriskConfBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFAsteriskAsteriskConfBuff prevAsteriskConfCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAsteriskAsteriskConfBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextAsteriskConfCursor(Cursor); } return (rec); } public CFAsteriskAsteriskConfBuff firstAsteriskConfCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFAsteriskAsteriskConfBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextAsteriskConfCursor(Cursor); } return (rec); } public CFAsteriskAsteriskConfBuff lastAsteriskConfCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastAsteriskConfCursor"); } public CFAsteriskAsteriskConfBuff nthAsteriskConfCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAsteriskAsteriskConfBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextAsteriskConfCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }