use of org.opensmartgridplatform.domain.core.valueobjects.TransitionMessageDataContainer in project open-smart-grid-platform by OSGP.
the class PublicLightingSetTransitionRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.debug("Processing public lighting set transition request message");
final MessageMetadata metadata;
Object dataObject;
try {
metadata = MessageMetadata.fromMessage(message);
dataObject = message.getObject();
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
return;
}
try {
LOGGER.info("Calling application service function: {}", metadata.getMessageType());
final TransitionMessageDataContainer transitionMessageDataContainer = (TransitionMessageDataContainer) dataObject;
this.setTransitionService.setTransitionForDevice(metadata, transitionMessageDataContainer.getTransitionType(), transitionMessageDataContainer.getDateTime());
} catch (final Exception e) {
this.handleError(e, metadata.getCorrelationUid(), metadata.getOrganisationIdentification(), metadata.getDeviceIdentification(), metadata.getMessageType(), metadata.getMessagePriority());
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.TransitionMessageDataContainer in project open-smart-grid-platform by OSGP.
the class PublicLightingAdHocManagementEndpoint method setTransition.
// === SET TRANSITION ===
@PayloadRoot(localPart = "SetTransitionRequest", namespace = NAMESPACE)
@ResponsePayload
public SetTransitionAsyncResponse setTransition(@OrganisationIdentification final String organisationIdentification, @RequestPayload final SetTransitionRequest request, @MessagePriority final String messagePriority) throws OsgpException {
LOGGER.info("Set Transition Request received from organisation: {} for device: {} with message priority: {}.", organisationIdentification, request.getDeviceIdentification(), messagePriority);
final SetTransitionAsyncResponse response = new SetTransitionAsyncResponse();
try {
final TransitionMessageDataContainer transitionMessageDataContainer = new TransitionMessageDataContainer();
if (request.getTransitionType() != null) {
transitionMessageDataContainer.setTransitionType(this.adHocManagementMapper.map(request.getTransitionType(), org.opensmartgridplatform.domain.core.valueobjects.TransitionType.class));
}
DateTime dateTime = null;
if (request.getTime() != null) {
dateTime = new DateTime(request.getTime().toGregorianCalendar().getTime());
}
transitionMessageDataContainer.setDateTime(dateTime);
final String correlationUid = this.adHocManagementService.enqueueTransitionRequest(organisationIdentification, request.getDeviceIdentification(), transitionMessageDataContainer, MessagePriorityEnum.getMessagePriority(messagePriority));
final AsyncResponse asyncResponse = new AsyncResponse();
asyncResponse.setCorrelationUid(correlationUid);
asyncResponse.setDeviceId(request.getDeviceIdentification());
response.setAsyncResponse(asyncResponse);
} catch (final Exception e) {
this.handleException(e);
}
return response;
}
Aggregations