use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion in project open-smart-grid-platform by OSGP.
the class ConfigurationService method handleGetFirmwareVersionResponse.
/**
* Maps the firmware Dto's to value objects and sends it back to the ws-adapter layer
*
* @param messageMetadata contains the message meta data
* @param deviceResult indicates whether the execution was successful
* @param exception contains the exception if one was thrown
* @param firmwareVersionList contains the firmware result list
*/
public void handleGetFirmwareVersionResponse(final MessageMetadata messageMetadata, final ResponseMessageResultType deviceResult, final OsgpException exception, final List<FirmwareVersionDto> firmwareVersionList) {
log.info("handleGetFirmwareVersionResponse for MessageType: {}", messageMetadata.getMessageType());
ResponseMessageResultType result = deviceResult;
if (exception != null) {
log.error("Get firmware version response not ok. Unexpected Exception", exception);
result = ResponseMessageResultType.NOT_OK;
}
final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(firmwareVersionList, FirmwareVersion.class);
final FirmwareVersionResponse firmwareVersionResponse = new FirmwareVersionResponse(firmwareVersions);
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withMessageMetadata(messageMetadata).withResult(result).withOsgpException(exception).withDataObject(firmwareVersionResponse).build();
this.webServiceResponseMessageSender.send(responseMessage, messageMetadata.getMessageType());
this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion in project open-smart-grid-platform by OSGP.
the class FirmwareVersionGasConverter method convertFrom.
@Override
public FirmwareVersion convertFrom(final org.opensmartgridplatform.adapter.ws.schema.smartmetering.configuration.FirmwareVersionGas source, final Type<FirmwareVersion> destinationType, final MappingContext mappingContext) {
if (source == null) {
return null;
}
final FirmwareModuleType type = FirmwareModuleType.forDescription(source.getFirmwareModuleType().name());
final String version = Hex.encodeHexString(source.getVersion());
return new FirmwareVersion(type, version);
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion in project open-smart-grid-platform by OSGP.
the class FirmwareManagementServiceTest method checkSsldPendingFirmwareUpdateReturnsTrueAndDeletesPendingUpdateWithMatchingCorrelationUid.
@Test
void checkSsldPendingFirmwareUpdateReturnsTrueAndDeletesPendingUpdateWithMatchingCorrelationUid() {
final String correlationUid = "correlation-uid-matching-pending-update";
final CorrelationIds ids = new CorrelationIds(ORGANISATION_IDENTIFICATION, DEVICE_IDENTIFICATION, correlationUid);
final List<FirmwareVersion> firmwareVersions = Collections.singletonList(new FirmwareVersion(FirmwareModuleType.FUNCTIONAL, VERSION_2));
final SsldPendingFirmwareUpdate matchingPendingFirmwareUpdate = this.anSsldPendingFirmwareUpdate(437L, new Date(), DEVICE_IDENTIFICATION, correlationUid);
when(this.ssldPendingFirmwareUpdateRepository.findByDeviceIdentification(DEVICE_IDENTIFICATION)).thenReturn(Arrays.asList(this.anSsldPendingFirmwareUpdate(457198L, new Date(), DEVICE_IDENTIFICATION, "some-other-correlation-uid"), matchingPendingFirmwareUpdate, this.anSsldPendingFirmwareUpdate(94085089L, new Date(), DEVICE_IDENTIFICATION, "yet-another-correlation-uid")));
final boolean hasPendingFirmwareUpdate = this.firmwareManagementService.checkSsldPendingFirmwareUpdate(ids, firmwareVersions);
assertThat(hasPendingFirmwareUpdate).isTrue();
verify(this.ssldPendingFirmwareUpdateRepository).delete(matchingPendingFirmwareUpdate);
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion in project open-smart-grid-platform by OSGP.
the class BundleService method checkIfAdditionalActionIsNeeded.
private void checkIfAdditionalActionIsNeeded(final MessageMetadata messageMetadata, final BundleMessagesRequestDto bundleMessagesRequestDto) throws FunctionalException {
for (final ActionResponseDto action : bundleMessagesRequestDto.getAllResponses()) {
if (action instanceof CoupleMbusDeviceByChannelResponseDto) {
this.mBusGatewayService.handleCoupleMbusDeviceByChannelResponse(messageMetadata, (CoupleMbusDeviceByChannelResponseDto) action);
} else if (action instanceof DecoupleMbusDeviceResponseDto) {
this.mBusGatewayService.handleDecoupleMbusDeviceResponse(messageMetadata, (DecoupleMbusDeviceResponseDto) action);
} else if (action instanceof SetDeviceLifecycleStatusByChannelResponseDto) {
this.managementService.setDeviceLifecycleStatusByChannel((SetDeviceLifecycleStatusByChannelResponseDto) action);
} else if (action instanceof EventMessageDataResponseDto) {
this.eventService.enrichEvents(messageMetadata, (EventMessageDataResponseDto) action);
} else if (action instanceof FirmwareVersionResponseDto) {
final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(((FirmwareVersionResponseDto) action).getFirmwareVersions(), FirmwareVersion.class);
this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
} else if (action instanceof FirmwareVersionGasResponseDto) {
final FirmwareVersionGasResponseDto firmwareVersionGasResponseDto = (FirmwareVersionGasResponseDto) action;
final FirmwareVersion firmwareVersion = this.configurationMapper.map(firmwareVersionGasResponseDto.getFirmwareVersion(), FirmwareVersion.class);
this.firmwareService.saveFirmwareVersionsReturnedFromDevice(firmwareVersionGasResponseDto.getFirmwareVersion().getMbusDeviceIdentification(), Arrays.asList(firmwareVersion));
}
}
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion in project open-smart-grid-platform by OSGP.
the class FirmwareManagementService method handleGetFirmwareVersionResponse.
public void handleGetFirmwareVersionResponse(final List<FirmwareVersionDto> firmwareVersionsDto, final CorrelationIds ids, final String messageType, final int messagePriority, final ResponseMessageResultType deviceResult, final OsgpException exception) {
LOGGER.info("handleResponse for MessageType: {}", messageType);
ResponseMessageResultType result = ResponseMessageResultType.OK;
OsgpException osgpException = exception;
try {
if (deviceResult == ResponseMessageResultType.NOT_OK || osgpException != null) {
LOGGER.error("Device Response not ok.", osgpException);
throw osgpException;
}
} catch (final Exception e) {
LOGGER.error("Unexpected Exception", e);
result = ResponseMessageResultType.NOT_OK;
osgpException = new TechnicalException(ComponentType.UNKNOWN, "Exception occurred while getting device firmware version", e);
}
final List<FirmwareVersion> firmwareVersions = this.domainCoreMapper.mapAsList(firmwareVersionsDto, FirmwareVersion.class);
this.checkFirmwareHistory(ids.getDeviceIdentification(), firmwareVersions);
final boolean hasPendingFirmwareUpdate = this.checkSsldPendingFirmwareUpdate(ids, firmwareVersions);
if (!hasPendingFirmwareUpdate) {
final ResponseMessage responseMessage = ResponseMessage.newResponseMessageBuilder().withIds(ids).withResult(result).withOsgpException(osgpException).withDataObject((Serializable) firmwareVersions).withMessagePriority(messagePriority).withMessageType(MessageType.GET_FIRMWARE_VERSION.name()).build();
this.webServiceResponseMessageSender.send(responseMessage);
}
}
Aggregations