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