use of org.opensmartgridplatform.cucumber.platform.smartmetering.builders.entities.SmartMeterBuilder in project open-smart-grid-platform by OSGP.
the class DlmsDeviceSteps method createDeviceInCoreDatabase.
private Device createDeviceInCoreDatabase(final Map<String, String> inputSettings) {
Device device;
final ProtocolInfo protocolInfo = this.getProtocolInfo(inputSettings);
final DeviceModel deviceModel = this.getDeviceModel(inputSettings);
final boolean isSmartMeter = this.isSmartMeter(inputSettings);
if (isSmartMeter) {
final SmartMeter smartMeter = new SmartMeterBuilder().withSettings(inputSettings).setProtocolInfo(protocolInfo).setDeviceModel(deviceModel).build();
device = this.smartMeterRepository.save(smartMeter);
} else {
device = new DeviceBuilder(this.deviceRepository).withSettings(inputSettings).setProtocolInfo(protocolInfo).setDeviceModel(deviceModel).build();
device = this.deviceRepository.save(device);
}
final Map<FirmwareModule, String> firmwareModuleVersions = this.deviceFirmwareModuleSteps.getFirmwareModuleVersions(inputSettings, isSmartMeter);
if (!firmwareModuleVersions.isEmpty()) {
device.setFirmwareVersions(firmwareModuleVersions);
device = this.deviceRepository.save(device);
}
if (inputSettings.containsKey(PlatformSmartmeteringKeys.GATEWAY_DEVICE_IDENTIFICATION)) {
final Device gatewayDevice = this.deviceRepository.findByDeviceIdentification(inputSettings.get(PlatformSmartmeteringKeys.GATEWAY_DEVICE_IDENTIFICATION));
device.updateGatewayDevice(gatewayDevice);
device = this.deviceRepository.save(device);
}
return device;
}
Aggregations