public void deleteSecDeviceByUserIdx(UUID SecUserId) { CFSecuritySecDeviceByUserIdxKey key = ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey(); key.setRequiredSecUserId(SecUserId); if (indexByUserIdx == null) { indexByUserIdx = new HashMap< CFSecuritySecDeviceByUserIdxKey, Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>>(); } if (indexByUserIdx.containsKey(key)) { Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> dict = indexByUserIdx.get(key); ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .deleteSecDeviceByUserIdx(schema.getAuthorization(), SecUserId); Iterator<ICFSecuritySecDeviceObj> iter = dict.values().iterator(); ICFSecuritySecDeviceObj obj; List<ICFSecuritySecDeviceObj> toForget = new LinkedList<ICFSecuritySecDeviceObj>(); while (iter.hasNext()) { obj = iter.next(); toForget.add(obj); } iter = toForget.iterator(); while (iter.hasNext()) { obj = iter.next(); obj.forget(true); } indexByUserIdx.remove(key); } else { ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .deleteSecDeviceByUserIdx(schema.getAuthorization(), SecUserId); } }
public void deleteSecDevice(ICFSecuritySecDeviceObj Obj) { ICFSecuritySecDeviceObj obj = Obj; ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .deleteSecDevice(schema.getAuthorization(), obj.getSecDeviceBuff()); obj.forget(true); }
public ICFSecuritySecDeviceObj updateSecDevice(ICFSecuritySecDeviceObj Obj) { ICFSecuritySecDeviceObj obj = Obj; ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .updateSecDevice(schema.getAuthorization(), Obj.getSecDeviceBuff()); obj = (ICFSecuritySecDeviceObj) Obj.realize(); return (obj); }
public ICFSecuritySecDeviceObj createSecDevice(ICFSecuritySecDeviceObj Obj) { ICFSecuritySecDeviceObj obj = Obj; CFSecuritySecDeviceBuff buff = obj.getSecDeviceBuff(); ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .createSecDevice(schema.getAuthorization(), buff); obj.copyBuffToPKey(); obj = obj.realize(); return (obj); }
public ICFSecuritySecDeviceObj lockSecDevice(CFSecuritySecDevicePKey pkey) { ICFSecuritySecDeviceObj locked = null; CFSecuritySecDeviceBuff lockBuff = ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .lockDerived(schema.getAuthorization(), pkey); if (lockBuff != null) { locked = schema.getSecDeviceTableObj().newInstance(); locked.setPKey( ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey()); locked.setBuff(lockBuff); locked = (ICFSecuritySecDeviceObj) locked.realize(); } else { throw CFLib.getDefaultExceptionFactory() .newCollisionDetectedException(getClass(), "lockSecDevice", pkey); } return (locked); }
public ICFSecuritySecDeviceObj readSecDevice(CFSecuritySecDevicePKey pkey, boolean forceRead) { ICFSecuritySecDeviceObj obj = null; if ((!forceRead) && members.containsKey(pkey)) { obj = members.get(pkey); } else { CFSecuritySecDeviceBuff readBuff = ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .readDerivedByIdIdx( schema.getAuthorization(), pkey.getRequiredSecUserId(), pkey.getRequiredDevName()); if (readBuff != null) { obj = schema.getSecDeviceTableObj().newInstance(); obj.setPKey(((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey()); obj.setBuff(readBuff); obj = (ICFSecuritySecDeviceObj) obj.realize(); } else if (schema.getCacheMisses()) { members.put(pkey, null); } } return (obj); }
public List<ICFSecuritySecDeviceObj> readSecDeviceByUserIdx(UUID SecUserId, boolean forceRead) { final String S_ProcName = "readSecDeviceByUserIdx"; CFSecuritySecDeviceByUserIdxKey key = ((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newUserIdxKey(); key.setRequiredSecUserId(SecUserId); Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> dict; if (indexByUserIdx == null) { indexByUserIdx = new HashMap< CFSecuritySecDeviceByUserIdxKey, Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>>(); } if ((!forceRead) && indexByUserIdx.containsKey(key)) { dict = indexByUserIdx.get(key); } else { dict = new HashMap<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>(); // Allow other threads to dirty-read while we're loading indexByUserIdx.put(key, dict); ICFSecuritySecDeviceObj obj; CFSecuritySecDeviceBuff[] buffList = ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .readDerivedByUserIdx(schema.getAuthorization(), SecUserId); CFSecuritySecDeviceBuff buff; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = schema.getSecDeviceTableObj().newInstance(); obj.setPKey(((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey()); obj.setBuff(buff); ICFSecuritySecDeviceObj realized = (ICFSecuritySecDeviceObj) obj.realize(); } } Comparator<ICFSecuritySecDeviceObj> cmp = new Comparator<ICFSecuritySecDeviceObj>() { public int compare(ICFSecuritySecDeviceObj lhs, ICFSecuritySecDeviceObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFSecuritySecDevicePKey lhsPKey = lhs.getPKey(); CFSecuritySecDevicePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = dict.size(); ICFSecuritySecDeviceObj arr[] = new ICFSecuritySecDeviceObj[len]; Iterator<ICFSecuritySecDeviceObj> valIter = dict.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFSecuritySecDeviceObj> arrayList = new ArrayList<ICFSecuritySecDeviceObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFSecuritySecDeviceObj> sortedList = arrayList; return (sortedList); }
public List<ICFSecuritySecDeviceObj> readAllSecDevice(boolean forceRead) { final String S_ProcName = "readAllSecDevice"; if ((allSecDevice == null) || forceRead) { Map<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj> map = new HashMap<CFSecuritySecDevicePKey, ICFSecuritySecDeviceObj>(); allSecDevice = map; CFSecuritySecDeviceBuff[] buffList = ((ICFAsteriskSchema) schema.getBackingStore()) .getTableSecDevice() .readAllDerived(schema.getAuthorization()); CFSecuritySecDeviceBuff buff; ICFSecuritySecDeviceObj obj; for (int idx = 0; idx < buffList.length; idx++) { buff = buffList[idx]; obj = newInstance(); obj.setPKey(((ICFAsteriskSchema) schema.getBackingStore()).getFactorySecDevice().newPKey()); obj.setBuff(buff); ICFSecuritySecDeviceObj realized = (ICFSecuritySecDeviceObj) obj.realize(); } } Comparator<ICFSecuritySecDeviceObj> cmp = new Comparator<ICFSecuritySecDeviceObj>() { public int compare(ICFSecuritySecDeviceObj lhs, ICFSecuritySecDeviceObj rhs) { if (lhs == null) { if (rhs == null) { return (0); } else { return (-1); } } else if (rhs == null) { return (1); } else { CFSecuritySecDevicePKey lhsPKey = lhs.getPKey(); CFSecuritySecDevicePKey rhsPKey = rhs.getPKey(); int ret = lhsPKey.compareTo(rhsPKey); return (ret); } } }; int len = allSecDevice.size(); ICFSecuritySecDeviceObj arr[] = new ICFSecuritySecDeviceObj[len]; Iterator<ICFSecuritySecDeviceObj> valIter = allSecDevice.values().iterator(); int idx = 0; while ((idx < len) && valIter.hasNext()) { arr[idx++] = valIter.next(); } if (idx < len) { throw CFLib.getDefaultExceptionFactory() .newArgumentUnderflowException(getClass(), S_ProcName, 0, "idx", idx, len); } else if (valIter.hasNext()) { throw CFLib.getDefaultExceptionFactory() .newArgumentOverflowException(getClass(), S_ProcName, 0, "idx", idx, len); } Arrays.sort(arr, cmp); ArrayList<ICFSecuritySecDeviceObj> arrayList = new ArrayList<ICFSecuritySecDeviceObj>(len); for (idx = 0; idx < len; idx++) { arrayList.add(arr[idx]); } List<ICFSecuritySecDeviceObj> sortedList = arrayList; return (sortedList); }