use of org.opensmartgridplatform.domain.core.valueobjects.LightValueMessageDataContainer in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method enqueueSetLightRequest.
public String enqueueSetLightRequest(@Identification final String organisationIdentification, @Identification final String deviceIdentification, @Size(min = 1, max = 6) @Valid final List<LightValue> lightValues, 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_LIGHT);
this.domainHelperService.isInMaintenance(device);
LOGGER.debug("enqueueSetLightRequest called with organisation {} and device {}", organisationIdentification, deviceIdentification);
final String correlationUid = this.correlationIdProviderService.getCorrelationId(organisationIdentification, deviceIdentification);
final LightValueMessageDataContainer lightValueMessageDataContainer = new LightValueMessageDataContainer(lightValues);
final MessageMetadata deviceMessageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(MessageType.SET_LIGHT.name()).withMessagePriority(messagePriority).build();
final PublicLightingRequestMessage message = new PublicLightingRequestMessage.Builder().messageMetadata(deviceMessageMetadata).request(lightValueMessageDataContainer).build();
this.messageSender.send(message);
return correlationUid;
}
use of org.opensmartgridplatform.domain.core.valueobjects.LightValueMessageDataContainer in project open-smart-grid-platform by OSGP.
the class PublicLightingSetLightRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing public lighting set light request message");
String correlationUid = null;
String messageType = null;
int messagePriority = MessagePriorityEnum.DEFAULT.getPriority();
String organisationIdentification = null;
String deviceIdentification = null;
Object dataObject = null;
try {
correlationUid = message.getJMSCorrelationID();
messageType = message.getJMSType();
messagePriority = message.getJMSPriority();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
dataObject = message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("messagePriority: {}", messagePriority);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
return;
}
try {
LOGGER.info("Calling application service function: {}", messageType);
final LightValueMessageDataContainer lightValueMessageDataContainer = (LightValueMessageDataContainer) dataObject;
this.adHocManagementService.setLight(organisationIdentification, deviceIdentification, correlationUid, lightValueMessageDataContainer.getLightValues(), messageType, messagePriority);
} catch (final Exception e) {
this.handleError(e, correlationUid, organisationIdentification, deviceIdentification, messageType, messagePriority);
}
}
Aggregations