Search in sources :

Example 1 with Builder

use of org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder 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)

Example 2 with Builder

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

the class AdHocManagementService method coupleLightMeasurementDeviceForSsld.

/**
 * Send request message to domain component to couple an SSLD with a light measurement device.
 *
 * @param organisationIdentification Organization issuing the request.
 * @param deviceIdentification The SSLD.
 * @param lightMeasurementDeviceIdentification The light measurement device.
 * @param messagePriority The priority of the message.
 * @return Correlation UID.
 * @throws FunctionalException In case the organization is not authorized or the SSLD or LMD can
 *     not be found.
 */
public String coupleLightMeasurementDeviceForSsld(final String organisationIdentification, final String deviceIdentification, final String lightMeasurementDeviceIdentification, final int messagePriority) throws FunctionalException {
    final Organisation organisation = this.domainHelperService.findOrganisation(organisationIdentification);
    final Device device = this.domainHelperService.findDevice(deviceIdentification);
    this.domainHelperService.isAllowed(organisation, device, DeviceFunction.SET_LIGHT_MEASUREMENT_DEVICE);
    final Device lightMeasurementDevice = this.domainHelperService.findDevice(lightMeasurementDeviceIdentification);
    LOGGER.info("Found lightMeasurementDevice: {}", lightMeasurementDevice.getDeviceIdentification());
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT_MEASUREMENT_DEVICE.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightMeasurementDeviceIdentification).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 3 with Builder

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

the class DlmsChannelHandlerServer method processPushedAlarm.

private void processPushedAlarm(final DlmsPushNotification message, final String correlationId, final String deviceIdentification, final String ipAddress) {
    this.logMessage(message);
    final PushNotificationAlarmDto pushNotificationAlarm = new PushNotificationAlarmDto(deviceIdentification, message.getAlarms(), message.toByteArray());
    final RequestMessage requestMessage = new RequestMessage(correlationId, "no-organisation", deviceIdentification, ipAddress, null, null, pushNotificationAlarm);
    final MessageMetadata messageMetadata = new Builder().withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).build();
    log.info("Sending push notification alarm to GXF with correlation ID: {}", correlationId);
    this.osgpRequestMessageSender.send(requestMessage, MessageType.PUSH_NOTIFICATION_ALARM.name(), messageMetadata);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) PushNotificationAlarmDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder)

Example 4 with Builder

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

the class AdHocManagementService method enqueueResumeScheduleRequest.

public String enqueueResumeScheduleRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Valid final ResumeScheduleData resumeScheduleData, 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.RESUME_SCHEDULE);
    this.domainHelperService.isInMaintenance(device);
    LOGGER.debug("enqueueResumeScheduleRequest called with organisation {}, device {} and resumeScheduleData {} ", organisationIdentification, deviceIdentification, resumeScheduleData);
    final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
    final MessageMetadata deviceMessageMetadata = new Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.RESUME_SCHEDULE.name()).withMessagePriority(messagePriority).build();
    final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(resumeScheduleData).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 Builder

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

the class SystemEventService method verifySystemEventThresholdReachedEvent.

public void verifySystemEventThresholdReachedEvent(final DlmsDevice device, final MessageMetadata sourceMessageMetadata) {
    if (device.getInvocationCounter() == null || device.getInvocationCounter() < this.invocationCounterEventThreshold) {
        return;
    }
    final String message = String.format("Invocation counter for device %s, has a higher value %s than the threshold configured %s, an event will be published", device.getDeviceIdentification(), device.getInvocationCounter(), this.invocationCounterEventThreshold);
    log.info(message);
    final SystemEventDto systemEventDto = new SystemEventDto(device.getDeviceIdentification(), SystemEventTypeDto.INVOCATION_COUNTER_THRESHOLD_REACHED, new Date(), message);
    final String correlationId = this.correlationIdProviderService.getCorrelationId(sourceMessageMetadata.getOrganisationIdentification(), device.getDeviceIdentification());
    final MessageMetadata messageMetadata = new Builder().withDeviceIdentification(device.getDeviceIdentification()).withCorrelationUid(correlationId).withOrganisationIdentification(sourceMessageMetadata.getOrganisationIdentification()).withIpAddress(sourceMessageMetadata.getIpAddress()).withMessagePriority(MessagePriorityEnum.HIGH.getPriority()).withMessageType(MessageType.SYSTEM_EVENT.name()).withDomain(sourceMessageMetadata.getDomain()).withDomainVersion(sourceMessageMetadata.getDomainVersion()).build();
    final RequestMessage requestMessage = new RequestMessage(messageMetadata, systemEventDto);
    log.info("Sending system event to GXF with correlation ID: {}", correlationId);
    this.osgpRequestMessageSender.send(requestMessage, MessageType.SYSTEM_EVENT.name(), messageMetadata);
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Builder(org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) SystemEventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto) Date(java.util.Date)

Aggregations

MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)8 Builder (org.opensmartgridplatform.shared.infra.jms.MessageMetadata.Builder)8 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)5 Test (org.junit.jupiter.api.Test)3 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)3 DlmsDeviceBuilder (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDeviceBuilder)3 PublicLightingRequestMessage (org.opensmartgridplatform.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessage)3 Device (org.opensmartgridplatform.domain.core.entities.Device)3 Organisation (org.opensmartgridplatform.domain.core.entities.Organisation)3 SystemEventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SystemEventDto)2 Date (java.util.Date)1 PushNotificationAlarmDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PushNotificationAlarmDto)1