Search in sources :

Example 1 with FirmwareModuleType

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

the class FirmwareFileSteps method aPendingFirmwareUpdateRecordForAnSsld.

@Given("^a pending firmware update record for an ssld$")
@Transactional("txMgrCore")
public void aPendingFirmwareUpdateRecordForAnSsld(final Map<String, String> settings) {
    final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
    final FirmwareModuleType firmwareModuleType = getEnum(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_FUNC, FirmwareModuleType.class);
    final String firmwareVersion = getString(settings, PlatformKeys.FIRMWARE_VERSION);
    final String organisationIdentification = getString(settings, PlatformKeys.KEY_ORGANIZATION_IDENTIFICATION);
    SsldPendingFirmwareUpdate ssldPendingFirmwareUpdate = new SsldPendingFirmwareUpdate(deviceIdentification, firmwareModuleType, firmwareVersion, organisationIdentification, "correlationUid");
    ssldPendingFirmwareUpdate = this.ssldPendingFirmwareUpdateRepository.save(ssldPendingFirmwareUpdate);
}
Also used : SsldPendingFirmwareUpdate(org.opensmartgridplatform.domain.core.entities.SsldPendingFirmwareUpdate) FirmwareModuleType(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString) Given(io.cucumber.java.en.Given) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with FirmwareModuleType

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

the class FirmwareManagementService method checkSsldPendingFirmwareUpdate.

boolean checkSsldPendingFirmwareUpdate(final CorrelationIds ids, final List<FirmwareVersion> firmwareVersions) {
    final String deviceIdentification = ids.getDeviceIdentification();
    final SsldPendingFirmwareUpdate ssldPendingFirmwareUpdate = this.ssldPendingFirmwareUpdateRepository.findByDeviceIdentification(deviceIdentification).stream().filter(pendingUpdate -> pendingUpdate.getCorrelationUid().equals(ids.getCorrelationUid())).findAny().orElse(null);
    if (ssldPendingFirmwareUpdate == null) {
        return false;
    }
    LOGGER.info("Found SSLD pending firmware update record for device identification: {}, {}.", deviceIdentification, ssldPendingFirmwareUpdate);
    final FirmwareModuleType expectedFirmwareModuleType = ssldPendingFirmwareUpdate.getFirmwareModuleType();
    final String expectedFirmwareVersion = ssldPendingFirmwareUpdate.getFirmwareVersion();
    final boolean foundExpectedFirmwareVersion = firmwareVersions.stream().anyMatch(fv -> expectedFirmwareModuleType.equals(fv.getFirmwareModuleType()) && expectedFirmwareVersion.equals(fv.getVersion()));
    if (foundExpectedFirmwareVersion) {
        LOGGER.info("Expected firmware version from SSLD pending firmware update record matches firmware version as retrieved from device identification: {}, firmware version: {}, firmware module type: {}.", deviceIdentification, expectedFirmwareVersion, expectedFirmwareModuleType);
    } else {
        LOGGER.error("Expected firmware version from SSLD pending firmware update record does )not match firmware version as retrieved from device identification: {}, expected firmware version: {}, expected firmware module type: {}, actual firmware version and module type list: {}", deviceIdentification, expectedFirmwareVersion, expectedFirmwareModuleType, firmwareVersions);
    }
    this.ssldPendingFirmwareUpdateRepository.delete(ssldPendingFirmwareUpdate);
    return true;
}
Also used : SsldPendingFirmwareUpdate(org.opensmartgridplatform.domain.core.entities.SsldPendingFirmwareUpdate) FirmwareModuleType(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType)

Example 3 with FirmwareModuleType

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

the class FirmwareManagementService method createSsldPendingFirmwareUpdateRecord.

private void createSsldPendingFirmwareUpdateRecord(final CorrelationIds ids, final String firmwareUrl) {
    try {
        final String firmwareFilename = getFirmwareFilename(firmwareUrl);
        final List<FirmwareFile> firmwareFiles = this.firmwareFileRepository.findByFilename(firmwareFilename);
        Assert.isTrue(firmwareFiles.size() == 1, "Expected 1 firmware file for filename: " + firmwareFilename);
        final FirmwareFile firmwareFile = firmwareFiles.get(0);
        final Map<FirmwareModule, String> firmwareModuleVersions = firmwareFile.getModuleVersions();
        Assert.isTrue(firmwareModuleVersions.size() == 1, "Expected 1 firmware module for: " + firmwareModuleVersions);
        final Entry<FirmwareModule, String> firmwareModuleVersion = firmwareModuleVersions.entrySet().iterator().next();
        final FirmwareModuleType firmwareModuleType = FirmwareModuleType.valueOf(firmwareModuleVersion.getKey().getDescription().toUpperCase());
        final String firmwareVersion = firmwareModuleVersion.getValue();
        SsldPendingFirmwareUpdate ssldPendingFirmwareUpdate = new SsldPendingFirmwareUpdate(ids.getDeviceIdentification(), firmwareModuleType, firmwareVersion, ids.getOrganisationIdentification(), ids.getCorrelationUid());
        ssldPendingFirmwareUpdate = this.ssldPendingFirmwareUpdateRepository.save(ssldPendingFirmwareUpdate);
        LOGGER.info("Saved pending fimware update record for SSLD: {}, {}", ids.getDeviceIdentification(), ssldPendingFirmwareUpdate);
    } catch (final Exception e) {
        LOGGER.error("Caught exception when creating pending firmware update record for SSLD: {}", ids.getDeviceIdentification(), e);
    }
}
Also used : SsldPendingFirmwareUpdate(org.opensmartgridplatform.domain.core.entities.SsldPendingFirmwareUpdate) FirmwareModuleType(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType) FirmwareModule(org.opensmartgridplatform.domain.core.entities.FirmwareModule) DeviceFirmwareFile(org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile) TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException)

Example 4 with FirmwareModuleType

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

the class FirmwareManagementServiceTest method anSsldPendingFirmwareUpdate.

private SsldPendingFirmwareUpdate anSsldPendingFirmwareUpdate(final Long id, final Date creationTime, final String deviceIdentification, final String correlationUid) {
    final FirmwareModuleType firmwareModuleType = FirmwareModuleType.FUNCTIONAL;
    final String firmwareVersion = "test-version";
    final SsldPendingFirmwareUpdate ssldPendingFirmwareUpdate = new SsldPendingFirmwareUpdate(deviceIdentification, firmwareModuleType, firmwareVersion, ORGANISATION_IDENTIFICATION, correlationUid);
    ReflectionTestUtils.setField(ssldPendingFirmwareUpdate, "id", id, Long.class);
    ReflectionTestUtils.setField(ssldPendingFirmwareUpdate, "creationTime", creationTime, Date.class);
    return ssldPendingFirmwareUpdate;
}
Also used : SsldPendingFirmwareUpdate(org.opensmartgridplatform.domain.core.entities.SsldPendingFirmwareUpdate) FirmwareModuleType(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 5 with FirmwareModuleType

use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType 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);
}
Also used : FirmwareModuleType(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType) FirmwareVersion(org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)

Aggregations

FirmwareModuleType (org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleType)6 SsldPendingFirmwareUpdate (org.opensmartgridplatform.domain.core.entities.SsldPendingFirmwareUpdate)4 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)2 Given (io.cucumber.java.en.Given)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 DeviceFirmwareFile (org.opensmartgridplatform.domain.core.entities.DeviceFirmwareFile)1 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)1 FirmwareModule (org.opensmartgridplatform.domain.core.entities.FirmwareModule)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)1 Transactional (org.springframework.transaction.annotation.Transactional)1