Search in sources :

Example 1 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class ScheduledTaskSteps method createUpdateFirmwareScheduledTask.

private static ScheduledTask createUpdateFirmwareScheduledTask(final Map<String, String> settings) {
    final String deviceIdentification = ReadSettingsHelper.getString(settings, KEY_DEVICE_IDENTIFICATION, DEFAULT_DEVICE_IDENTIFICATION);
    final String organisationIdentification = ReadSettingsHelper.getString(settings, KEY_ORGANIZATION_IDENTIFICATION, DEFAULT_ORGANIZATION_IDENTIFICATION);
    final String correlationUid = ReadSettingsHelper.getString(settings, KEY_CORRELATION_UID, DEFAULT_CORRELATION_UID);
    final String messageType = MessageType.UPDATE_FIRMWARE.toString();
    final int messagePriority = 4;
    final Long scheduleTime = DateTimeHelper.getDateTime(ReadSettingsHelper.getString(settings, KEY_SCHEDULED_TIME, DEFAULT_SCHEDULED_TIME)).getMillis();
    final MessageMetadata messageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(messageType).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).build();
    final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(null, "FW-01", null, null, null, null, null);
    final String firmwareUrl = "firmware-url";
    final Serializable messageData = new FirmwareUpdateMessageDataContainer(firmwareModuleData, firmwareUrl);
    return new ScheduledTask(messageMetadata, "CORE", "1.0", messageData, new Timestamp(scheduleTime));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Serializable(java.io.Serializable) FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer) ScheduledTask(org.opensmartgridplatform.domain.core.entities.ScheduledTask) Timestamp(java.sql.Timestamp)

Example 2 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class CommonRelayStatusUpdatedMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    MessageMetadata messageMetadata;
    try {
        messageMetadata = MessageMetadata.fromMessage(message);
    } catch (final JMSException e) {
        LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
        return;
    }
    final RequestMessage requestMsg = new RequestMessage(messageMetadata.getCorrelationUid(), messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification(), null);
    this.webServiceRequestMessageSender.send(requestMsg, messageMetadata.getMessageType());
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) JMSException(javax.jms.JMSException)

Example 3 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class AddDeviceRequestMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    final MessageMetadata deviceMessageMetadata = MessageMetadata.fromMessage(message);
    final AddRtuDeviceRequest addRtuDeviceRequest = (AddRtuDeviceRequest) message.getObject();
    try {
        this.deviceManagementService.addDevice(deviceMessageMetadata, addRtuDeviceRequest);
    } catch (final FunctionalException e) {
        this.handleError(e, deviceMessageMetadata.getCorrelationUid(), deviceMessageMetadata.getOrganisationIdentification(), deviceMessageMetadata.getDeviceIdentification(), deviceMessageMetadata.getMessageType());
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) AddRtuDeviceRequest(org.opensmartgridplatform.domain.core.valueobjects.AddRtuDeviceRequest) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 4 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method enqueueGetStatusRequest.

public String enqueueGetStatusRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.GET_STATUS);
    LOGGER.debug("enqueueGetStatusRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.GET_LIGHT_STATUS.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Example 5 with MessageMetadata

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method enqueueTransitionRequest.

public String enqueueTransitionRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, final TransitionMessageDataContainer transitionMessageDataContainer, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findActiveDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_TRANSITION);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueTransitionRequest called with organisation {}, device {} ", organisationIdentification, deviceIdentification);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_TRANSITION.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(transitionMessageDataContainer).build();
    this.messageSender.send(message);
    return correlationUid;
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Organisation(org.opensmartgridplatform.domain.core.entities.Organisation) Device(org.opensmartgridplatform.domain.core.entities.Device) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) PublicLightingRequestMessage(org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)

Aggregations

MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)147 JMSException (javax.jms.JMSException)65 Device (org.opensmartgridplatform.domain.core.entities.Device)29 Test (org.junit.jupiter.api.Test)25 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)23 ProtocolResponseMessage (org.opensmartgridplatform.shared.infra.jms.ProtocolResponseMessage)22 DeviceRequest (org.opensmartgridplatform.adapter.protocol.iec61850.device.DeviceRequest)20 RequestMessageData (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.helper.RequestMessageData)20 Iec61850DeviceResponseHandler (org.opensmartgridplatform.adapter.protocol.iec61850.infra.networking.services.Iec61850DeviceResponseHandler)20 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)19 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)18 CommonRequestMessage (org.opensmartgridplatform.adapter.ws.core.infra.jms.CommonRequestMessage)15 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)14 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)14 ObjectMessage (javax.jms.ObjectMessage)13 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)13 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)13 Serializable (java.io.Serializable)12 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)12 UpdateFirmwareRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.UpdateFirmwareRequestDto)10