Source:
public void insertSmartMeter(final Map<String, String> inputSettings) { final SmartMeter smartMeter = new SmartMeter( getString(inputSettings, Keys.KEY_DEVICE_IDENTIFICATION, Defaults.DEFAULT_DEVICE_IDENTIFICATION), getString(inputSettings, Keys.KEY_ALIAS, Defaults.DEFAULT_ALIAS), getString(inputSettings, Keys.KEY_CITY, Defaults.DEFAULT_CONTAINER_CITY), getString(inputSettings, Keys.KEY_POSTCODE, Defaults.DEFAULT_CONTAINER_POSTALCODE), getString(inputSettings, Keys.KEY_STREET, Defaults.DEFAULT_CONTAINER_STREET), getString(inputSettings, Keys.KEY_NUMBER, Defaults.DEFAULT_CONTAINER_NUMBER), getString(inputSettings, Keys.KEY_MUNICIPALITY, Defaults.DEFAULT_CONTAINER_MUNICIPALITY), getFloat(inputSettings, Keys.KEY_LATITUDE, Defaults.DEFAULT_LATITUDE), getFloat(inputSettings, Keys.KEY_LONGITUDE, Defaults.DEFAULT_LONGITUDE) ); final Protocol protocol = ProtocolHelper.getProtocol(Protocol.ProtocolType.DSMR); Map<String, String> settings = this.putSetting(inputSettings, Keys.KEY_PROTOCOL, protocol.getProtocol()); settings = this.putSetting(settings, Keys.KEY_PROTOCOL_VERSION, protocol.getVersion()); if (settings.containsKey(Keys.KEY_GATEWAY_DEVICE_ID)) { smartMeter.setChannel(getShort(settings, Keys.KEY_CHANNEL, Defaults.DEFAULT_CHANNEL)); final Device smartEMeter = this.deviceRepository.findByDeviceIdentification(settings.get(Keys.KEY_GATEWAY_DEVICE_ID)); smartMeter.updateGatewayDevice(smartEMeter); } this.smartMeterRepository.save(smartMeter); final Device device = this.deviceRepository.findByDeviceIdentification(getString(inputSettings, Keys.KEY_DEVICE_IDENTIFICATION, Defaults.DEFAULT_DEVICE_IDENTIFICATION)); this.updateDevice(device, settings); }

Target:
public void insertSmartMeter(final Map<String, String> inputSettings) { final SmartMeter smartMeter = new SmartMeter( getString(inputSettings, Keys.KEY_DEVICE_IDENTIFICATION, Defaults.DEFAULT_DEVICE_IDENTIFICATION), getString(inputSettings, Keys.KEY_ALIAS, Defaults.DEFAULT_ALIAS), getString(inputSettings, Keys.KEY_CITY, Defaults.DEFAULT_CONTAINER_CITY), getString(inputSettings, Keys.KEY_POSTCODE, Defaults.DEFAULT_CONTAINER_POSTALCODE), getString(inputSettings, Keys.KEY_STREET, Defaults.DEFAULT_CONTAINER_STREET), getString(inputSettings, Keys.KEY_NUMBER, Defaults.DEFAULT_CONTAINER_NUMBER), getString(inputSettings, Keys.KEY_MUNICIPALITY, Defaults.DEFAULT_CONTAINER_MUNICIPALITY), getFloat(inputSettings, Keys.KEY_LATITUDE, Defaults.DEFAULT_LATITUDE), getFloat(inputSettings, Keys.KEY_LONGITUDE, Defaults.DEFAULT_LONGITUDE) ); final Protocol protocol = ProtocolHelper.getProtocol(Protocol.ProtocolType.DSMR); Map<String, String> settings = Helpers.addSetting(inputSettings, Keys.KEY_PROTOCOL, protocol.getProtocol()); settings = Helpers.addSetting(settings, Keys.KEY_PROTOCOL_VERSION, protocol.getVersion()); if (settings.containsKey(Keys.KEY_GATEWAY_DEVICE_ID)) { smartMeter.setChannel(getShort(settings, Keys.KEY_CHANNEL, Defaults.DEFAULT_CHANNEL)); final Device smartEMeter = this.deviceRepository.findByDeviceIdentification(settings.get(Keys.KEY_GATEWAY_DEVICE_ID)); smartMeter.updateGatewayDevice(smartEMeter); } this.smartMeterRepository.save(smartMeter); final Device device = this.deviceRepository.findByDeviceIdentification(getString(inputSettings, Keys.KEY_DEVICE_IDENTIFICATION, Defaults.DEFAULT_DEVICE_IDENTIFICATION)); this.updateDevice(device, settings); }