Source:
public void handleLightMeasurementDeviceTransition(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final EventMessageDataContainer eventMessageDataContainer) { final LightMeasurementDevice lmd = this.lightMeasurementDeviceRepository .findByDeviceIdentification(deviceIdentification); if (lmd == null) { return; } final List<Ssld> ssldsToTransition = this.ssldRepository .findByLightMeasurementDeviceAndIsActivatedTrueAndInMaintenanceFalseAndProtocolInfoNotNullAndNetworkAddressNotNullAndTechnicalInstallationDateNotNullAndDeviceLifecycleStatus( lmd, DeviceLifecycleStatus.IN_USE); if (ssldsToTransition == null) { return; } LOGGER.info("For light measurement device: {}, SSLDs were found", deviceIdentification, ssldsToTransition.size()); TransitionType transitionType; final String transitionTypeFromLightMeasurementDevice = eventMessageDataContainer.getEvents().get(0) .getEventType().name(); if (EventType.LIGHT_SENSOR_REPORTS_DARK.name().equals(transitionTypeFromLightMeasurementDevice)) { transitionType = TransitionType.DAY_NIGHT; } else { transitionType = TransitionType.NIGHT_DAY; } final DateTime transitionTime = DateTime.now(); final String messageType = DeviceFunction.SET_TRANSITION.name(); for (final Ssld ssld : ssldsToTransition) { try { this.setTransition(organisationIdentification, ssld.getDeviceIdentification(), correlationUid, transitionType, transitionTime, messageType); } catch (final FunctionalException e) { LOGGER.error("Caught unexpected FunctionalException", e); } } }

Target:
public void handleLightMeasurementDeviceTransition(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final EventMessageDataContainer eventMessageDataContainer) { final Event event = eventMessageDataContainer.getEvents().get(0); if (event == null) { LOGGER.info("No event received for light measurement device: {}", deviceIdentification); return; } final LightMeasurementDevice lmd = this.lightMeasurementDeviceRepository .findByDeviceIdentification(deviceIdentification); if (lmd == null) { LOGGER.info("No light measurement device found: {}", deviceIdentification); return; } if (this.isDuplicateEvent(event, lmd)) { LOGGER.info("Duplicate event detected for light measurement device: {}. Event[id:{} {}]", lmd.getDeviceIdentification(), event.getId(), event.getDateTime(), event.getDescription(), event.getEventType(), event.getIndex()); return; } final List<Ssld> ssldsToTransition = this.ssldRepository .findByLightMeasurementDeviceAndIsActivatedTrueAndInMaintenanceFalseAndProtocolInfoNotNullAndNetworkAddressNotNullAndTechnicalInstallationDateNotNullAndDeviceLifecycleStatus( lmd, DeviceLifecycleStatus.IN_USE); LOGGER.info("For light measurement device: {}, SSLDs were found", deviceIdentification, ssldsToTransition.size()); final String transitionTypeFromLightMeasurementDevice = event.getEventType().name(); TransitionType transitionType; if (EventType.LIGHT_SENSOR_REPORTS_DARK.name().equals(transitionTypeFromLightMeasurementDevice)) { transitionType = TransitionType.DAY_NIGHT; } else { transitionType = TransitionType.NIGHT_DAY; } this.transitionSslds(ssldsToTransition, organisationIdentification, correlationUid, transitionType, DateTime.now()); }