@Test public void testClearAlarmsOnDevice() { EntityDataStoreManager manager = m_persistenceManager.getEntityDataStoreManager(); Timestamp timestamp = new Timestamp(System.currentTimeMillis()); createAlarms(timestamp, 3); AlarmInfo alarm1 = buildAlarmInfoWithResourceTypeString(); AlarmInfo alarm2 = buildAlarmInfoWithResourceTypeString_Device2(); m_alarmService.raiseAlarm(alarm1); m_alarmService.raiseAlarm(alarm2); manager.beginTransaction(); m_alarmQueue.clearQueue(); manager.commitTransaction(); List<Alarm> alarms = getAlarmsFor(0, 10); assertEquals(5, alarms.size()); m_alarmService.clearAlarm(alarm1); m_alarmService.clearAlarm(alarm2); m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID, MOUNT_KEY); m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID2, MOUNT_KEY); m_alarmService.clearAlarmsOnDevice(DEVICE_ID); m_alarmService.clearAlarmsOnNodeAndSubtree(MODEL_NODE_ID2, MOUNT_KEY); m_alarmService.clearAlarmsOnDevice(DEVICE_ID2); m_alarmService.clearAlarmsOnDevice(DEVICE_ID); manager.beginTransaction(); m_alarmQueue.clearQueue(); manager.commitTransaction(); alarms = getAlarmsFor(0, 10); assertEquals(1, alarms.size()); }
@Override public void clearAlarmsOnDevice(String deviceId) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(deviceId); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnDevice(String deviceId) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(deviceId); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnDevice(String deviceId) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(deviceId); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnDevice(String deviceId) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(deviceId); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); void init(); void close(); @Override void raiseAlarm(AlarmInfo alarm); @Override void raiseAlarms(List<AlarmInfo> alarmInfoList); @Override void clearAlarm(AlarmInfo alarm); @Override void clearAlarms(List<AlarmInfo> alarmInfoList); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput, String deviceId); @Override void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey); @Override void clearAlarmsOnDevice(String deviceId); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarmsUnderResource(String resourceDbIdLike); @Override void updateAlarmsForResync(List<AlarmInfo> newRaiseAlarms, List<AlarmInfo> updateAlarms, List<AlarmInfo> clearAlarms); @Override void updateAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override void removeAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override Set<String> retrieveAdapterTypeVersionsFromAlarmNotificationQName(QName alarmNotificationQName); }
AlarmServiceImpl implements AlarmService { @Override public void clearAlarmsOnDevice(String deviceId) { AlarmChange alarmChange = AlarmChange.createForClearSubtree(deviceId); m_alarmQueue.addAlarmChanges(Collections.singletonList(alarmChange)); } AlarmServiceImpl(PersistenceManagerUtil persistenceManagerUtil, AlarmQueue alarmQueue); void init(); void close(); @Override void raiseAlarm(AlarmInfo alarm); @Override void raiseAlarms(List<AlarmInfo> alarmInfoList); @Override void clearAlarm(AlarmInfo alarm); @Override void clearAlarms(List<AlarmInfo> alarmInfoList); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarms(PagingInput pagingInput, String deviceId); @Override void clearAlarmsOnNodeAndSubtree(ModelNodeId identifier, String mountKey); @Override void clearAlarmsOnDevice(String deviceId); @Override @Transactional(value = TxType.REQUIRED, rollbackOn = {RuntimeException.class}) List<Alarm> getAlarmsUnderResource(String resourceDbIdLike); @Override void updateAlarmsForResync(List<AlarmInfo> newRaiseAlarms, List<AlarmInfo> updateAlarms, List<AlarmInfo> clearAlarms); @Override void updateAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override void removeAlarmNotificationQNameToAdapterTypeVersion(QName alarmNotificationQName, String typeVersion); @Override Set<String> retrieveAdapterTypeVersionsFromAlarmNotificationQName(QName alarmNotificationQName);  }