Java tutorial
// Description: Java7 in-memory RAM DbIO implementation for TSecGroupMember. /* * CF Security Core Implementation * * Copyright (c) 2010-2014 Mark Sobkow * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam; import java.sql.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurity.*; import net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityRam.*; /* * CFSecurityRamTSecGroupMemberTable in-memory RAM DbIO implementation * for TSecGroupMember. */ public class CFSecurityRamTSecGroupMemberTable implements ICFSecurityTSecGroupMemberTable { private CFSecurityRamSchema schema; private Map<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> dictByPKey = new HashMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); private SortedMap<CFSecurityTSecGroupMemberByTenantIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>> dictByTenantIdx = new TreeMap<CFSecurityTSecGroupMemberByTenantIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>>(); private SortedMap<CFSecurityTSecGroupMemberByGroupIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>> dictByGroupIdx = new TreeMap<CFSecurityTSecGroupMemberByGroupIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>>(); private SortedMap<CFSecurityTSecGroupMemberByUserIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>> dictByUserIdx = new TreeMap<CFSecurityTSecGroupMemberByUserIdxKey, SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>>(); private SortedMap<CFSecurityTSecGroupMemberByUUserIdxKey, CFSecurityTSecGroupMemberBuff> dictByUUserIdx = new TreeMap<CFSecurityTSecGroupMemberByUUserIdxKey, CFSecurityTSecGroupMemberBuff>(); public CFSecurityRamTSecGroupMemberTable(CFSecurityRamSchema argSchema) { schema = argSchema; } public void createTSecGroupMember(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberBuff Buff) { CFSecurityTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupMemberId(((CFSecurityRamTenantTable) schema.getTableTenant()) .nextTSecGroupMemberIdGen(Authorization, Buff.getRequiredTenantId())); Buff.setRequiredTenantId(pkey.getRequiredTenantId()); Buff.setRequiredTSecGroupMemberId(pkey.getRequiredTSecGroupMemberId()); CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupMember().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey(); keyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey(); keyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId()); keyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); keyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); // Validate unique indexes if (dictByPKey.containsKey(pkey)) { throw CFLib.getDefaultExceptionFactory().newPrimaryKeyNotNewException(getClass(), "createTSecGroupMember", pkey); } if (dictByUUserIdx.containsKey(keyUUserIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "createTSecGroupMember", "TSecGroupMemberUUserIdx", keyUUserIdx); } // Validate foreign keys { boolean allNull = true; allNull = false; if (!allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroupMember", "Owner", "TSecGroupMemberTenant", "Tenant", null); } } } { boolean allNull = true; allNull = false; allNull = false; if (!allNull) { if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "createTSecGroupMember", "Container", "TSecGroupMemberGroup", "TSecGroup", null); } } } // Proceed with adding the new record dictByPKey.put(pkey, Buff); SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictTenantIdx; if (dictByTenantIdx.containsKey(keyTenantIdx)) { subdictTenantIdx = dictByTenantIdx.get(keyTenantIdx); } else { subdictTenantIdx = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByTenantIdx.put(keyTenantIdx, subdictTenantIdx); } subdictTenantIdx.put(pkey, Buff); SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictGroupIdx; if (dictByGroupIdx.containsKey(keyGroupIdx)) { subdictGroupIdx = dictByGroupIdx.get(keyGroupIdx); } else { subdictGroupIdx = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByGroupIdx.put(keyGroupIdx, subdictGroupIdx); } subdictGroupIdx.put(pkey, Buff); SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictUserIdx; if (dictByUserIdx.containsKey(keyUserIdx)) { subdictUserIdx = dictByUserIdx.get(keyUserIdx); } else { subdictUserIdx = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByUserIdx.put(keyUserIdx, subdictUserIdx); } subdictUserIdx.put(pkey, Buff); dictByUUserIdx.put(keyUUserIdx, Buff); } public CFSecurityTSecGroupMemberBuff readDerived(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberPKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerived() "; CFSecurityTSecGroupMemberPKey key = schema.getFactoryTSecGroupMember().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupMemberId(PKey.getRequiredTSecGroupMemberId()); CFSecurityTSecGroupMemberBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff lockDerived(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberPKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerived() "; CFSecurityTSecGroupMemberPKey key = schema.getFactoryTSecGroupMember().newPKey(); key.setRequiredTenantId(PKey.getRequiredTenantId()); key.setRequiredTSecGroupMemberId(PKey.getRequiredTSecGroupMemberId()); CFSecurityTSecGroupMemberBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff[] readAllDerived(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readAllDerived() "; CFSecurityTSecGroupMemberBuff[] retList = new CFSecurityTSecGroupMemberBuff[dictByPKey.values().size()]; Iterator<CFSecurityTSecGroupMemberBuff> iter = dictByPKey.values().iterator(); int idx = 0; while (iter.hasNext()) { retList[idx++] = iter.next(); } return (retList); } public CFSecurityTSecGroupMemberBuff[] readDerivedByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerivedByTenantIdx() "; CFSecurityTSecGroupMemberByTenantIdxKey key = schema.getFactoryTSecGroupMember().newTenantIdxKey(); key.setRequiredTenantId(TenantId); CFSecurityTSecGroupMemberBuff[] recArray; if (dictByTenantIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictTenantIdx = dictByTenantIdx .get(key); recArray = new CFSecurityTSecGroupMemberBuff[subdictTenantIdx.size()]; Iterator<CFSecurityTSecGroupMemberBuff> iter = subdictTenantIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupMemberBuff[0]; } return (recArray); } public CFSecurityTSecGroupMemberBuff[] readDerivedByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerivedByGroupIdx() "; CFSecurityTSecGroupMemberByGroupIdxKey key = schema.getFactoryTSecGroupMember().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); CFSecurityTSecGroupMemberBuff[] recArray; if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictGroupIdx = dictByGroupIdx .get(key); recArray = new CFSecurityTSecGroupMemberBuff[subdictGroupIdx.size()]; Iterator<CFSecurityTSecGroupMemberBuff> iter = subdictGroupIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupMemberBuff[0]; } return (recArray); } public CFSecurityTSecGroupMemberBuff[] readDerivedByUserIdx(CFSecurityAuthorization Authorization, UUID SecUserId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerivedByUserIdx() "; CFSecurityTSecGroupMemberByUserIdxKey key = schema.getFactoryTSecGroupMember().newUserIdxKey(); key.setRequiredSecUserId(SecUserId); CFSecurityTSecGroupMemberBuff[] recArray; if (dictByUserIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictUserIdx = dictByUserIdx .get(key); recArray = new CFSecurityTSecGroupMemberBuff[subdictUserIdx.size()]; Iterator<CFSecurityTSecGroupMemberBuff> iter = subdictUserIdx.values().iterator(); int idx = 0; while (iter.hasNext()) { recArray[idx++] = iter.next(); } } else { recArray = new CFSecurityTSecGroupMemberBuff[0]; } return (recArray); } public CFSecurityTSecGroupMemberBuff readDerivedByUUserIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId, UUID SecUserId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerivedByUUserIdx() "; CFSecurityTSecGroupMemberByUUserIdxKey key = schema.getFactoryTSecGroupMember().newUUserIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); key.setRequiredSecUserId(SecUserId); CFSecurityTSecGroupMemberBuff buff; if (dictByUUserIdx.containsKey(key)) { buff = dictByUUserIdx.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff readDerivedByIdIdx(CFSecurityAuthorization Authorization, long TenantId, long TSecGroupMemberId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readDerivedByIdIdx() "; CFSecurityTSecGroupMemberPKey key = schema.getFactoryTSecGroupMember().newPKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupMemberId(TSecGroupMemberId); CFSecurityTSecGroupMemberBuff buff; if (dictByPKey.containsKey(key)) { buff = dictByPKey.get(key); } else { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff readBuff(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberPKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuff() "; CFSecurityTSecGroupMemberBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGMB"))) { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff lockBuff(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberPKey PKey) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuff() "; CFSecurityTSecGroupMemberBuff buff = readDerived(Authorization, PKey); if ((buff != null) && (!buff.getClassCode().equals("TGMB"))) { buff = null; } return (buff); } public CFSecurityTSecGroupMemberBuff[] readAllBuff(CFSecurityAuthorization Authorization) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readAllBuff() "; CFSecurityTSecGroupMemberBuff buff; ArrayList<CFSecurityTSecGroupMemberBuff> filteredList = new ArrayList<CFSecurityTSecGroupMemberBuff>(); CFSecurityTSecGroupMemberBuff[] buffList = readAllDerived(Authorization); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGMB")) { filteredList.add(buff); } } return (filteredList.toArray(new CFSecurityTSecGroupMemberBuff[0])); } public CFSecurityTSecGroupMemberBuff readBuffByIdIdx(CFSecurityAuthorization Authorization, long TenantId, long TSecGroupMemberId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByIdIdx() "; CFSecurityTSecGroupMemberBuff buff = readDerivedByIdIdx(Authorization, TenantId, TSecGroupMemberId); if ((buff != null) && buff.getClassCode().equals("TGMB")) { return ((CFSecurityTSecGroupMemberBuff) buff); } else { return (null); } } public CFSecurityTSecGroupMemberBuff[] readBuffByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByTenantIdx() "; CFSecurityTSecGroupMemberBuff buff; ArrayList<CFSecurityTSecGroupMemberBuff> filteredList = new ArrayList<CFSecurityTSecGroupMemberBuff>(); CFSecurityTSecGroupMemberBuff[] buffList = readDerivedByTenantIdx(Authorization, TenantId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGMB")) { filteredList.add((CFSecurityTSecGroupMemberBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupMemberBuff[0])); } public CFSecurityTSecGroupMemberBuff[] readBuffByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByGroupIdx() "; CFSecurityTSecGroupMemberBuff buff; ArrayList<CFSecurityTSecGroupMemberBuff> filteredList = new ArrayList<CFSecurityTSecGroupMemberBuff>(); CFSecurityTSecGroupMemberBuff[] buffList = readDerivedByGroupIdx(Authorization, TenantId, TSecGroupId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGMB")) { filteredList.add((CFSecurityTSecGroupMemberBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupMemberBuff[0])); } public CFSecurityTSecGroupMemberBuff[] readBuffByUserIdx(CFSecurityAuthorization Authorization, UUID SecUserId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByUserIdx() "; CFSecurityTSecGroupMemberBuff buff; ArrayList<CFSecurityTSecGroupMemberBuff> filteredList = new ArrayList<CFSecurityTSecGroupMemberBuff>(); CFSecurityTSecGroupMemberBuff[] buffList = readDerivedByUserIdx(Authorization, SecUserId); for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; if ((buff != null) && buff.getClassCode().equals("TGMB")) { filteredList.add((CFSecurityTSecGroupMemberBuff) buff); } } return (filteredList.toArray(new CFSecurityTSecGroupMemberBuff[0])); } public CFSecurityTSecGroupMemberBuff readBuffByUUserIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId, UUID SecUserId) { final String S_ProcName = "CFSecurityRamTSecGroupMember.readBuffByUUserIdx() "; CFSecurityTSecGroupMemberBuff buff = readDerivedByUUserIdx(Authorization, TenantId, TSecGroupId, SecUserId); if ((buff != null) && buff.getClassCode().equals("TGMB")) { return ((CFSecurityTSecGroupMemberBuff) buff); } else { return (null); } } public void updateTSecGroupMember(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberBuff Buff) { CFSecurityTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupMemberId(Buff.getRequiredTSecGroupMemberId()); CFSecurityTSecGroupMemberBuff existing = dictByPKey.get(pkey); if (existing == null) { throw CFLib.getDefaultExceptionFactory().newStaleCacheDetectedException(getClass(), "updateTSecGroupMember", "Existing record not found", "TSecGroupMember", pkey); } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "updateTSecGroupMember", pkey); } Buff.setRequiredRevision(Buff.getRequiredRevision() + 1); CFSecurityTSecGroupMemberByTenantIdxKey existingKeyTenantIdx = schema.getFactoryTSecGroupMember() .newTenantIdxKey(); existingKeyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFSecurityTSecGroupMemberByTenantIdxKey newKeyTenantIdx = schema.getFactoryTSecGroupMember() .newTenantIdxKey(); newKeyTenantIdx.setRequiredTenantId(Buff.getRequiredTenantId()); CFSecurityTSecGroupMemberByGroupIdxKey existingKeyGroupIdx = schema.getFactoryTSecGroupMember() .newGroupIdxKey(); existingKeyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFSecurityTSecGroupMemberByGroupIdxKey newKeyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey(); newKeyGroupIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyGroupIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); CFSecurityTSecGroupMemberByUserIdxKey existingKeyUserIdx = schema.getFactoryTSecGroupMember() .newUserIdxKey(); existingKeyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecurityTSecGroupMemberByUserIdxKey newKeyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey(); newKeyUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); CFSecurityTSecGroupMemberByUUserIdxKey existingKeyUUserIdx = schema.getFactoryTSecGroupMember() .newUUserIdxKey(); existingKeyUUserIdx.setRequiredTenantId(existing.getRequiredTenantId()); existingKeyUUserIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); existingKeyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecurityTSecGroupMemberByUUserIdxKey newKeyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey(); newKeyUUserIdx.setRequiredTenantId(Buff.getRequiredTenantId()); newKeyUUserIdx.setRequiredTSecGroupId(Buff.getRequiredTSecGroupId()); newKeyUUserIdx.setRequiredSecUserId(Buff.getRequiredSecUserId()); // Check unique indexes if (!existingKeyUUserIdx.equals(newKeyUUserIdx)) { if (dictByUUserIdx.containsKey(newKeyUUserIdx)) { throw CFLib.getDefaultExceptionFactory().newUniqueIndexViolationException(getClass(), "updateTSecGroupMember", "TSecGroupMemberUUserIdx", newKeyUUserIdx); } } // Validate foreign keys { boolean allNull = true; if (allNull) { if (null == schema.getTableTenant().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTSecGroupMember", "Owner", "TSecGroupMemberTenant", "Tenant", null); } } } { boolean allNull = true; if (allNull) { if (null == schema.getTableTSecGroup().readDerivedByIdIdx(Authorization, Buff.getRequiredTenantId(), Buff.getRequiredTSecGroupId())) { throw CFLib.getDefaultExceptionFactory().newUnresolvedRelationException(getClass(), "updateTSecGroupMember", "Container", "TSecGroupMemberGroup", "TSecGroup", null); } } } // Update is valid SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdict; dictByPKey.remove(pkey); dictByPKey.put(pkey, Buff); subdict = dictByTenantIdx.get(existingKeyTenantIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByTenantIdx.containsKey(newKeyTenantIdx)) { subdict = dictByTenantIdx.get(newKeyTenantIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByTenantIdx.put(newKeyTenantIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByGroupIdx.get(existingKeyGroupIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByGroupIdx.containsKey(newKeyGroupIdx)) { subdict = dictByGroupIdx.get(newKeyGroupIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByGroupIdx.put(newKeyGroupIdx, subdict); } subdict.put(pkey, Buff); subdict = dictByUserIdx.get(existingKeyUserIdx); if (subdict != null) { subdict.remove(pkey); } if (dictByUserIdx.containsKey(newKeyUserIdx)) { subdict = dictByUserIdx.get(newKeyUserIdx); } else { subdict = new TreeMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff>(); dictByUserIdx.put(newKeyUserIdx, subdict); } subdict.put(pkey, Buff); dictByUUserIdx.remove(existingKeyUUserIdx); dictByUUserIdx.put(newKeyUUserIdx, Buff); } public void deleteTSecGroupMember(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberBuff Buff) { final String S_ProcName = "CFSecurityRamTSecGroupMemberTable.deleteTSecGroupMember() "; CFSecurityTSecGroupMemberPKey pkey = schema.getFactoryTSecGroupMember().newPKey(); pkey.setRequiredTenantId(Buff.getRequiredTenantId()); pkey.setRequiredTSecGroupMemberId(Buff.getRequiredTSecGroupMemberId()); CFSecurityTSecGroupMemberBuff existing = dictByPKey.get(pkey); if (existing == null) { return; } if (existing.getRequiredRevision() != Buff.getRequiredRevision()) { throw CFLib.getDefaultExceptionFactory().newCollisionDetectedException(getClass(), "deleteTSecGroupMember", pkey); } CFSecurityTSecGroupMemberByTenantIdxKey keyTenantIdx = schema.getFactoryTSecGroupMember().newTenantIdxKey(); keyTenantIdx.setRequiredTenantId(existing.getRequiredTenantId()); CFSecurityTSecGroupMemberByGroupIdxKey keyGroupIdx = schema.getFactoryTSecGroupMember().newGroupIdxKey(); keyGroupIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyGroupIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); CFSecurityTSecGroupMemberByUserIdxKey keyUserIdx = schema.getFactoryTSecGroupMember().newUserIdxKey(); keyUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); CFSecurityTSecGroupMemberByUUserIdxKey keyUUserIdx = schema.getFactoryTSecGroupMember().newUUserIdxKey(); keyUUserIdx.setRequiredTenantId(existing.getRequiredTenantId()); keyUUserIdx.setRequiredTSecGroupId(existing.getRequiredTSecGroupId()); keyUUserIdx.setRequiredSecUserId(existing.getRequiredSecUserId()); // Validate reverse foreign keys // Delete is valid SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdict; dictByPKey.remove(pkey); subdict = dictByTenantIdx.get(keyTenantIdx); subdict.remove(pkey); subdict = dictByGroupIdx.get(keyGroupIdx); subdict.remove(pkey); subdict = dictByUserIdx.get(keyUserIdx); subdict.remove(pkey); dictByUUserIdx.remove(keyUUserIdx); } public void deleteTSecGroupMemberByIdIdx(CFSecurityAuthorization Authorization, long argTenantId, long argTSecGroupMemberId) { CFSecurityTSecGroupMemberPKey key = schema.getFactoryTSecGroupMember().newPKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupMemberId(argTSecGroupMemberId); deleteTSecGroupMemberByIdIdx(Authorization, key); } public void deleteTSecGroupMemberByIdIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberPKey argKey) { CFSecurityTSecGroupMemberBuff cur; LinkedList<CFSecurityTSecGroupMemberBuff> matchSet = new LinkedList<CFSecurityTSecGroupMemberBuff>(); Iterator<CFSecurityTSecGroupMemberBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupMemberBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupMember(Authorization, cur); } } public void deleteTSecGroupMemberByTenantIdx(CFSecurityAuthorization Authorization, long argTenantId) { CFSecurityTSecGroupMemberByTenantIdxKey key = schema.getFactoryTSecGroupMember().newTenantIdxKey(); key.setRequiredTenantId(argTenantId); deleteTSecGroupMemberByTenantIdx(Authorization, key); } public void deleteTSecGroupMemberByTenantIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberByTenantIdxKey argKey) { CFSecurityTSecGroupMemberBuff cur; LinkedList<CFSecurityTSecGroupMemberBuff> matchSet = new LinkedList<CFSecurityTSecGroupMemberBuff>(); Iterator<CFSecurityTSecGroupMemberBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupMemberBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupMember(Authorization, cur); } } public void deleteTSecGroupMemberByGroupIdx(CFSecurityAuthorization Authorization, long argTenantId, int argTSecGroupId) { CFSecurityTSecGroupMemberByGroupIdxKey key = schema.getFactoryTSecGroupMember().newGroupIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); deleteTSecGroupMemberByGroupIdx(Authorization, key); } public void deleteTSecGroupMemberByGroupIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberByGroupIdxKey argKey) { CFSecurityTSecGroupMemberBuff cur; LinkedList<CFSecurityTSecGroupMemberBuff> matchSet = new LinkedList<CFSecurityTSecGroupMemberBuff>(); Iterator<CFSecurityTSecGroupMemberBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupMemberBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupMember(Authorization, cur); } } public void deleteTSecGroupMemberByUserIdx(CFSecurityAuthorization Authorization, UUID argSecUserId) { CFSecurityTSecGroupMemberByUserIdxKey key = schema.getFactoryTSecGroupMember().newUserIdxKey(); key.setRequiredSecUserId(argSecUserId); deleteTSecGroupMemberByUserIdx(Authorization, key); } public void deleteTSecGroupMemberByUserIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberByUserIdxKey argKey) { CFSecurityTSecGroupMemberBuff cur; LinkedList<CFSecurityTSecGroupMemberBuff> matchSet = new LinkedList<CFSecurityTSecGroupMemberBuff>(); Iterator<CFSecurityTSecGroupMemberBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupMemberBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupMember(Authorization, cur); } } public void deleteTSecGroupMemberByUUserIdx(CFSecurityAuthorization Authorization, long argTenantId, int argTSecGroupId, UUID argSecUserId) { CFSecurityTSecGroupMemberByUUserIdxKey key = schema.getFactoryTSecGroupMember().newUUserIdxKey(); key.setRequiredTenantId(argTenantId); key.setRequiredTSecGroupId(argTSecGroupId); key.setRequiredSecUserId(argSecUserId); deleteTSecGroupMemberByUUserIdx(Authorization, key); } public void deleteTSecGroupMemberByUUserIdx(CFSecurityAuthorization Authorization, CFSecurityTSecGroupMemberByUUserIdxKey argKey) { CFSecurityTSecGroupMemberBuff cur; LinkedList<CFSecurityTSecGroupMemberBuff> matchSet = new LinkedList<CFSecurityTSecGroupMemberBuff>(); Iterator<CFSecurityTSecGroupMemberBuff> values = dictByPKey.values().iterator(); while (values.hasNext()) { cur = values.next(); if (argKey.equals(cur)) { matchSet.add(cur); } } Iterator<CFSecurityTSecGroupMemberBuff> iterMatch = matchSet.iterator(); while (iterMatch.hasNext()) { cur = iterMatch.next(); deleteTSecGroupMember(Authorization, cur); } } public CFSecurityCursor openTSecGroupMemberCursorAll(CFSecurityAuthorization Authorization) { CFSecurityCursor cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, dictByPKey.values()); return (cursor); } public CFSecurityCursor openTSecGroupMemberCursorByTenantIdx(CFSecurityAuthorization Authorization, long TenantId) { CFSecurityCursor cursor; CFSecurityTSecGroupMemberByTenantIdxKey key = schema.getFactoryTSecGroupMember().newTenantIdxKey(); key.setRequiredTenantId(TenantId); if (dictByTenantIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictTenantIdx = dictByTenantIdx .get(key); cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, subdictTenantIdx.values()); } else { cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupMemberBuff>()); } return (cursor); } public CFSecurityCursor openTSecGroupMemberCursorByGroupIdx(CFSecurityAuthorization Authorization, long TenantId, int TSecGroupId) { CFSecurityCursor cursor; CFSecurityTSecGroupMemberByGroupIdxKey key = schema.getFactoryTSecGroupMember().newGroupIdxKey(); key.setRequiredTenantId(TenantId); key.setRequiredTSecGroupId(TSecGroupId); if (dictByGroupIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictGroupIdx = dictByGroupIdx .get(key); cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, subdictGroupIdx.values()); } else { cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupMemberBuff>()); } return (cursor); } public CFSecurityCursor openTSecGroupMemberCursorByUserIdx(CFSecurityAuthorization Authorization, UUID SecUserId) { CFSecurityCursor cursor; CFSecurityTSecGroupMemberByUserIdxKey key = schema.getFactoryTSecGroupMember().newUserIdxKey(); key.setRequiredSecUserId(SecUserId); if (dictByUserIdx.containsKey(key)) { SortedMap<CFSecurityTSecGroupMemberPKey, CFSecurityTSecGroupMemberBuff> subdictUserIdx = dictByUserIdx .get(key); cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, subdictUserIdx.values()); } else { cursor = new CFSecurityRamTSecGroupMemberCursor(Authorization, schema, new ArrayList<CFSecurityTSecGroupMemberBuff>()); } return (cursor); } public void closeTSecGroupMemberCursor(CFSecurityCursor Cursor) { // Cursor.DataReader.Close(); } public CFSecurityTSecGroupMemberBuff nextTSecGroupMemberCursor(CFSecurityCursor Cursor) { CFSecurityRamTSecGroupMemberCursor cursor = (CFSecurityRamTSecGroupMemberCursor) Cursor; CFSecurityTSecGroupMemberBuff rec = cursor.getCursor().next(); cursor.setRowIdx(cursor.getRowIdx() + 1); return (rec); } public CFSecurityTSecGroupMemberBuff prevTSecGroupMemberCursor(CFSecurityCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFSecurityTSecGroupMemberBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupMemberCursor(Cursor); } return (rec); } public CFSecurityTSecGroupMemberBuff firstTSecGroupMemberCursor(CFSecurityCursor Cursor) { int targetRowIdx = 1; CFSecurityTSecGroupMemberBuff rec = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupMemberCursor(Cursor); } return (rec); } public CFSecurityTSecGroupMemberBuff lastTSecGroupMemberCursor(CFSecurityCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastTSecGroupMemberCursor"); } public CFSecurityTSecGroupMemberBuff nthTSecGroupMemberCursor(CFSecurityCursor Cursor, int Idx) { int targetRowIdx = Idx; CFSecurityTSecGroupMemberBuff rec = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { rec = nextTSecGroupMemberCursor(Cursor); } return (rec); } public void releasePreparedStatements() { } }