Search in sources :

Example 1 with TransitionMessageDataContainer

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());
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) TransitionMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.TransitionMessageDataContainer) JMSException(javax.jms.JMSException) JMSException(javax.jms.JMSException)

Example 2 with TransitionMessageDataContainer

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;
}
Also used : TransitionMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.TransitionMessageDataContainer) AsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncResponse) SetLightAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse) ResumeScheduleAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse) GetStatusAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse) SetTransitionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse) SetTransitionAsyncResponse(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse) DateTime(org.joda.time.DateTime) ValidationException(org.opensmartgridplatform.domain.core.exceptions.ValidationException) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) ConstraintViolationException(javax.validation.ConstraintViolationException) ResponsePayload(org.springframework.ws.server.endpoint.annotation.ResponsePayload) PayloadRoot(org.springframework.ws.server.endpoint.annotation.PayloadRoot)

Aggregations

TransitionMessageDataContainer (org.opensmartgridplatform.domain.core.valueobjects.TransitionMessageDataContainer)2 JMSException (javax.jms.JMSException)1 ConstraintViolationException (javax.validation.ConstraintViolationException)1 DateTime (org.joda.time.DateTime)1 GetStatusAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.GetStatusAsyncResponse)1 ResumeScheduleAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.ResumeScheduleAsyncResponse)1 SetLightAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetLightAsyncResponse)1 SetTransitionAsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.SetTransitionAsyncResponse)1 AsyncResponse (org.opensmartgridplatform.adapter.ws.schema.publiclighting.common.AsyncResponse)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)1 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)1