Search in sources :

Example 1 with EventNotificationMessageDataContainerDto

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());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) EventNotificationMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with EventNotificationMessageDataContainerDto

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);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SetEventNotificationsDeviceRequest(org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest) JMSException(javax.jms.JMSException) EventNotificationMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto)

Example 3 with EventNotificationMessageDataContainerDto

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);
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) EventNotificationType(org.opensmartgridplatform.domain.core.valueobjects.EventNotificationType) EventNotificationMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto) Test(org.junit.jupiter.api.Test)

Example 4 with EventNotificationMessageDataContainerDto

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);
}
Also used : Iec61850DeviceResponseHandler(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) SetEventNotificationsDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetEventNotificationsDeviceRequest) JMSException(javax.jms.JMSException) SetEventNotificationsDeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetEventNotificationsDeviceRequest) DeviceRequest(org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest) EventNotificationMessageDataContainerDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto) RequestMessageData(org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)

Aggregations

EventNotificationMessageDataContainerDto (org.opensmartgridplatform.dto.valueobjects.EventNotificationMessageDataContainerDto)4 JMSException (javax.jms.JMSException)2 Device (org.opensmartgridplatform.domain.core.entities.Device)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)2 Test (org.junit.jupiter.api.Test)1 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)1 SetEventNotificationsDeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.ssld.requests.SetEventNotificationsDeviceRequest)1 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)1 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)1 SetEventNotificationsDeviceRequest (org.opensmartgridplatform.adapter.protocol.oslp.elster.device.requests.SetEventNotificationsDeviceRequest)1 EventNotificationType (org.opensmartgridplatform.domain.core.valueobjects.EventNotificationType)1 Transactional (org.springframework.transaction.annotation.Transactional)1