use of org.opensmartgridplatform.adapter.domain.shared.GetStatusResponse in project open-smart-grid-platform by OSGP.
the class AdHocManagementService method handleGetStatusResponse.
public void handleGetStatusResponse(final DeviceStatusDto deviceStatusDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
LOGGER.info("handleResponse for MessageType: {}", messageType);
final GetStatusResponse response = new GetStatusResponse();
response.setOsgpException(exception);
response.setResult(deviceResult);
if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) {
LOGGER.error("Device Response not ok.", exception);
} else {
final DeviceStatus status = this.domainCoreMapper.map(deviceStatusDto, DeviceStatus.class);
try {
final Device dev = this.deviceDomainService.searchDevice(ids.getDeviceIdentification());
if (LightMeasurementDevice.LMD_TYPE.equals(dev.getDeviceType())) {
this.handleLmd(status, response);
} else {
this.handleSsld(ids.getDeviceIdentification(), status, DomainType.PUBLIC_LIGHTING, response);
}
} catch (final FunctionalException e) {
LOGGER.error("Caught FunctionalException", e);
}
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(response.getResult()).withOsgpException(response.getOsgpException()).withDataObject(response.getDeviceStatusMapped()).withMessagePriority(messagePriority).build();
this.webServiceResponseMessageSender.send(responseMessage);
}
use of org.opensmartgridplatform.adapter.domain.shared.GetStatusResponse in project open-smart-grid-platform by OSGP.
the class DeviceInstallationService method handleGetStatusResponse.
public void handleGetStatusResponse(final DeviceStatusDto deviceStatusDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
LOGGER.info("handleResponse for MessageType: {}", messageType);
final GetStatusResponse response = new GetStatusResponse();
response.setOsgpException(exception);
response.setResult(deviceResult);
if (deviceResult == ResponseMessageResultType.NOT_OK || exception != null) {
LOGGER.error("Device Response not ok.", exception);
} else {
final DeviceStatus status = this.domainCoreMapper.map(deviceStatusDto, DeviceStatus.class);
try {
final Device dev = this.deviceDomainService.searchDevice(ids.getDeviceIdentification());
if (LightMeasurementDevice.LMD_TYPE.equals(dev.getDeviceType())) {
this.handleLmd(status, response);
} else {
this.handleSsld(ids.getDeviceIdentification(), status, response);
}
} catch (final FunctionalException e) {
LOGGER.error("Caught FunctionalException", e);
}
}
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(response.getResult()).withOsgpException(response.getOsgpException()).withDataObject(response.getDeviceStatusMapped()).withMessagePriority(messagePriority).withMessageType(MessageType.GET_STATUS.name()).build();
this.webServiceResponseMessageSender.send(responseMessage);
}
Aggregations