Search in sources :

Example 1 with FirmwareModuleData

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

the class DeviceFirmwareModuleSteps method getFirmwareModuleVersions.

public Map<FirmwareModule, String> getFirmwareModuleVersions(final Map<String, String> settings, final boolean isForSmartMeters) {
    final String comm;
    if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_COMM)) {
        comm = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_COMM, null);
    } else {
        comm = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_COMM, null);
    }
    final String func;
    if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_FUNC_SMART_METERING)) {
        func = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_FUNC_SMART_METERING, null);
    } else {
        func = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_FUNC, null);
    }
    final String ma;
    if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_MA)) {
        ma = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_MA, null);
    } else {
        ma = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_MA, null);
    }
    final String mbus = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_MBUS, null);
    final String sec = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_SEC, null);
    final String mBusDriverActive = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_M_BUS_DRIVER_ACTIVE, null);
    final String simpleVersionInfo = getNullOrNonEmptyString(settings, PlatformKeys.SIMPLE_VERSION_INFO, null);
    final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(comm, func, ma, mbus, sec, mBusDriverActive, simpleVersionInfo);
    return firmwareModuleData.getVersionsByModule(this.firmwareModuleRepository, isForSmartMeters);
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) ReadSettingsHelper.getNullOrNonEmptyString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getNullOrNonEmptyString) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)

Example 2 with FirmwareModuleData

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

the class ScheduledTaskSteps method createUpdateFirmwareScheduledTask.

private static ScheduledTask createUpdateFirmwareScheduledTask(final Map<String, String> settings) {
    final String deviceIdentification = ReadSettingsHelper.getString(settings, KEY_DEVICE_IDENTIFICATION, DEFAULT_DEVICE_IDENTIFICATION);
    final String organisationIdentification = ReadSettingsHelper.getString(settings, KEY_ORGANIZATION_IDENTIFICATION, DEFAULT_ORGANIZATION_IDENTIFICATION);
    final String correlationUid = ReadSettingsHelper.getString(settings, KEY_CORRELATION_UID, DEFAULT_CORRELATION_UID);
    final String messageType = MessageType.UPDATE_FIRMWARE.toString();
    final int messagePriority = 4;
    final Long scheduleTime = DateTimeHelper.getDateTime(ReadSettingsHelper.getString(settings, KEY_SCHEDULED_TIME, DEFAULT_SCHEDULED_TIME)).getMillis();
    final MessageMetadata messageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(messageType).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).build();
    final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(null, "FW-01", null, null, null, null, null);
    final String firmwareUrl = "firmware-url";
    final Serializable messageData = new FirmwareUpdateMessageDataContainer(firmwareModuleData, firmwareUrl);
    return new ScheduledTask(messageMetadata, "CORE", "1.0", messageData, new Timestamp(scheduleTime));
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Serializable(java.io.Serializable) FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer) ScheduledTask(org.opensmartgridplatform.domain.core.entities.ScheduledTask) Timestamp(java.sql.Timestamp)

Example 3 with FirmwareModuleData

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

the class FirmwareManagementMapperTest method mapsFirmwareModuleData.

@Test
public void mapsFirmwareModuleData() {
    final org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleData source = new FirmwareModuleDataBuilder().build();
    final FirmwareModuleData mappedValue = this.map(source);
    assertThat(this.mapper.map(source, FirmwareModuleData.class)).usingRecursiveComparison().isEqualTo(mappedValue);
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) FirmwareModuleDataBuilder(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleDataBuilder) Test(org.junit.jupiter.api.Test)

Example 4 with FirmwareModuleData

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

the class FirmwareFileBuilder method build.

public FirmwareFile build(final FirmwareModuleRepository firmwareModuleRepository, final boolean isForSmartMeters) {
    final FirmwareFile.Builder firmwareFileBuilder = new FirmwareFile.Builder();
    firmwareFileBuilder.withFilename(this.filename).withDescription(this.description).withPushToNewDevices(this.pushToNewDevices).withFile(this.file).withHash(this.hash);
    final FirmwareFile firmwareFile = firmwareFileBuilder.build();
    if (this.deviceModel != null) {
        firmwareFile.addDeviceModel(this.deviceModel);
    }
    firmwareFile.updateFirmwareModuleData(new FirmwareModuleData(this.moduleVersionComm, this.moduleVersionFunc, this.moduleVersionMa, this.moduleVersionMbus, this.moduleVersionSec, this.moduleVersionMBusDriverActive, this.moduleVersionSimple).getVersionsByModule(firmwareModuleRepository, isForSmartMeters));
    return firmwareFile;
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) FirmwareFile(org.opensmartgridplatform.domain.core.entities.FirmwareFile)

Example 5 with FirmwareModuleData

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

the class FirmwareManagementEndpoint method mapFirmwareModuleTypes.

private FirmwareUpdateMessageDataContainer mapFirmwareModuleTypes(final String firmwareIndentification, final List<FirmwareModuleType> firmwareModuleTypes) {
    String moduleVersionComm = null;
    String moduleVersionFunc = null;
    String moduleVersionMa = null;
    String moduleVersionMbus = null;
    String moduleVersionSec = null;
    String moduleVersionMBusDriverActive = null;
    String moduleVersionSimple = null;
    for (final FirmwareModuleType firmwareModuleType : firmwareModuleTypes) {
        final String firmwareModuleTypeString = firmwareModuleType.toString();
        if (FirmwareModuleType.COMMUNICATION.equals(firmwareModuleType)) {
            moduleVersionComm = firmwareModuleTypeString;
        } else if (FirmwareModuleType.FUNCTIONAL.equals(firmwareModuleType)) {
            moduleVersionFunc = firmwareModuleTypeString;
        } else if (FirmwareModuleType.MODULE_ACTIVE.equals(firmwareModuleType)) {
            moduleVersionMa = firmwareModuleTypeString;
        } else if (FirmwareModuleType.M_BUS.equals(firmwareModuleType)) {
            moduleVersionMbus = firmwareModuleTypeString;
        } else if (FirmwareModuleType.SECURITY.equals(firmwareModuleType)) {
            moduleVersionSec = firmwareModuleTypeString;
        } else if (FirmwareModuleType.M_BUS_DRIVER_ACTIVE.equals(firmwareModuleType)) {
            moduleVersionMBusDriverActive = firmwareModuleTypeString;
        } else if (FirmwareModuleType.SIMPLE_VERSION_INFO.equals(firmwareModuleType)) {
            moduleVersionSimple = firmwareModuleTypeString;
        }
    }
    final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(moduleVersionComm, moduleVersionFunc, moduleVersionMa, moduleVersionMbus, moduleVersionSec, moduleVersionMBusDriverActive, moduleVersionSimple);
    return new FirmwareUpdateMessageDataContainer(firmwareModuleData, firmwareIndentification);
}
Also used : FirmwareModuleData(org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData) FirmwareUpdateMessageDataContainer(org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer) FirmwareModuleType(org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleType)

Aggregations

FirmwareModuleData (org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData)8 ConstraintViolationException (javax.validation.ConstraintViolationException)3 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)3 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)3 PayloadRoot (org.springframework.ws.server.endpoint.annotation.PayloadRoot)3 ResponsePayload (org.springframework.ws.server.endpoint.annotation.ResponsePayload)3 AddOrChangeFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddOrChangeFirmwareResponse)2 FirmwareUpdateMessageDataContainer (org.opensmartgridplatform.domain.core.valueobjects.FirmwareUpdateMessageDataContainer)2 Serializable (java.io.Serializable)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1 AddFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.AddFirmwareResponse)1 ChangeFirmwareResponse (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.ChangeFirmwareResponse)1 FirmwareModuleDataBuilder (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleDataBuilder)1 FirmwareModuleType (org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleType)1 ReadSettingsHelper.getNullOrNonEmptyString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getNullOrNonEmptyString)1 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1 DeviceModel (org.opensmartgridplatform.domain.core.entities.DeviceModel)1 FirmwareFile (org.opensmartgridplatform.domain.core.entities.FirmwareFile)1