Search in sources :

Example 1 with GetPQValuesResponse

use of org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse in project open-smart-grid-platform by OSGP.

the class MonitoringService method handleGetPQValuesResponse.

public void handleGetPQValuesResponse(final GetPQValuesResponseDto getPQValuesResponseDto, final CorrelationIds ids, final String messageType, final ResponseMessageResultType responseMessageResultType, final OsgpException osgpException) {
    LOGGER.info("handleResponse for MessageType: {}", messageType);
    final String deviceIdentification = ids.getDeviceIdentification();
    final String organisationIdentification = ids.getOrganisationIdentification();
    ResponseMessageResultType result = ResponseMessageResultType.OK;
    GetPQValuesResponse getPQValuesResponse = null;
    OsgpException exception = osgpException;
    try {
        if (responseMessageResultType == ResponseMessageResultType.NOT_OK || osgpException != null) {
            LOGGER.error("Device Response not ok.", osgpException);
            throw osgpException;
        }
        this.rtuResponseService.handleResponseMessageReceived(LOGGER, deviceIdentification, true);
        getPQValuesResponse = this.mapper.map(getPQValuesResponseDto, GetPQValuesResponse.class);
    } catch (final Exception e) {
        LOGGER.error("Unexpected Exception", e);
        result = ResponseMessageResultType.NOT_OK;
        exception = this.ensureOsgpException(e, "Exception occurred while getting PQ Values Response Data");
    }
    // Support for Push messages, generate correlationUid
    String actualCorrelationUid = ids.getCorrelationUid();
    if ("no-correlationUid".equals(actualCorrelationUid)) {
        actualCorrelationUid = getCorrelationId("DeviceGenerated", deviceIdentification);
    }
    final CorrelationIds actualIds = new CorrelationIds(organisationIdentification, deviceIdentification, actualCorrelationUid);
    final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(actualIds).withResult(result).withOsgpException(exception).withDataObject(getPQValuesResponse).build();
    this.responseMessageRouter.send(responseMessage, messageType);
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) GetPQValuesResponse(org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse) ResponseMessage(org.opensmartgridplatform.shared.infra.jms.ResponseMessage) ResponseMessageResultType(org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) CorrelationIds(org.opensmartgridplatform.shared.infra.jms.CorrelationIds)

Aggregations

GetPQValuesResponse (org.opensmartgridplatform.domain.da.valueobjects.GetPQValuesResponse)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 CorrelationIds (org.opensmartgridplatform.shared.infra.jms.CorrelationIds)1 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)1 ResponseMessageResultType (org.opensmartgridplatform.shared.infra.jms.ResponseMessageResultType)1