use of org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class DeviceManagementService method setEventNotifications.
@Transactional(value = "transactionManager")
public void setEventNotifications(final String organisationIdentification, final String deviceIdentification, final String correlationUid, final List<EventNotificationType> eventNotifications, final String messageType, final int messagePriority) throws FunctionalException {
LOGGER.debug("setEventNotifications called with organisation {} and device {}", organisationIdentification, deviceIdentification);
this.findOrganisation(organisationIdentification);
final Device device = this.findActiveDevice(deviceIdentification);
final List<org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto> eventNotificationsDto = this.domainCoreMapper.mapAsList(eventNotifications, org.opensmartgridplatform.dto.valueobjects.EventNotificationTypeDto.class);
final EventNotificationMessageDataContainerDto eventNotificationMessageDataContainer = new EventNotificationMessageDataContainerDto(eventNotificationsDto);
this.osgpCoreRequestMessageSender.send(new RequestMessage(correlationUid, organisationIdentification, deviceIdentification, eventNotificationMessageDataContainer), messageType, messagePriority, device.getIpAddress());
}
use of org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class CommonSetEventNotificationsRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing common set event notifications request message");
MessageMetadata messageMetadata;
EventNotificationMessageDataContainerDto eventNotificationMessageDataContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
eventNotificationMessageDataContainer = (EventNotificationMessageDataContainerDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
this.printDomainInfo(messageMetadata.getMessageType(), messageMetadata.getDomain(), messageMetadata.getDomainVersion());
final SetEventNotificationsDeviceRequest deviceRequest = new SetEventNotificationsDeviceRequest(DeviceRequest.newBuilder().messageMetaData(messageMetadata), eventNotificationMessageDataContainer);
this.deviceService.setEventNotifications(deviceRequest);
} catch (final RuntimeException e) {
this.handleError(e, messageMetadata);
}
}
use of org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class DeviceManagementServiceTest method testSetEventNotifications.
@Test
public void testSetEventNotifications() throws FunctionalException {
final List<EventNotificationType> eventNotifications = Arrays.asList(EventNotificationType.COMM_EVENTS, EventNotificationType.DIAG_EVENTS);
final Device device = mock(Device.class);
when(device.getIpAddress()).thenReturn(TEST_IP);
when(this.deviceDomainService.searchActiveDevice(TEST_DEVICE, ComponentType.DOMAIN_CORE)).thenReturn(device);
this.deviceManagementService.setEventNotifications(TEST_ORGANISATION, TEST_DEVICE, TEST_UID, eventNotifications, TEST_MESSAGE_TYPE, TEST_PRIORITY);
verify(this.osgpCoreRequestManager).send(this.argumentRequestMessage.capture(), this.argumentMessageType.capture(), this.argumentPriority.capture(), this.argumentIpAddress.capture());
final RequestMessage expectedRequestMessage = this.createNewRequestMessage(new EventNotificationMessageDataContainerDto(this.domainCoreMapper.mapAsList(eventNotifications, EventNotificationTypeDto.class)));
assertThat(this.argumentRequestMessage.getValue()).usingRecursiveComparison().isEqualTo(expectedRequestMessage);
assertThat(this.argumentMessageType.getValue()).isEqualTo(TEST_MESSAGE_TYPE);
assertThat(this.argumentPriority.getValue()).isEqualTo(TEST_PRIORITY);
assertThat(this.argumentIpAddress.getValue()).isEqualTo(TEST_IP);
}
use of org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto in project open-smart-grid-platform by OSGP.
the class CommonSetEventNotificationsRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) throws JMSException {
LOGGER.debug("Processing common set event notifications request message");
MessageMetadata messageMetadata;
EventNotificationMessageDataContainerDto eventNotificationsContainer;
try {
messageMetadata = MessageMetadata.fromMessage(message);
eventNotificationsContainer = (EventNotificationMessageDataContainerDto) message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
final RequestMessageData requestMessageData = RequestMessageData.newBuilder().messageMetadata(messageMetadata).build();
this.printDomainInfo(requestMessageData);
final Iec61850DeviceResponseHandler iec61850DeviceResponseHandler = this.createIec61850DeviceResponseHandler(requestMessageData, message);
final DeviceRequest.Builder deviceRequestBuilder = DeviceRequest.newBuilder().messageMetaData(messageMetadata);
this.deviceService.setEventNotifications(new SetEventNotificationsDeviceRequest(deviceRequestBuilder, eventNotificationsContainer), iec61850DeviceResponseHandler);
}
Aggregations