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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations