From ed72bf084b3e6c184fca2018fe13571b37704ae0 Mon Sep 17 00:00:00 2001 From: insanity Date: Thu, 28 Jun 2018 20:05:40 +0900 Subject: [PATCH] Sensor modify --- .../sensor/service/CentralSensorItemService.java | 4 ++++ .../module/sensor/service/CentralSensorService.java | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java index 374aacd..471e6bd 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorItemService.java @@ -58,4 +58,8 @@ public class CentralSensorItemService implements SensorItemService { this.sensorItemDAO.deleteById(sensorItemID); } + public void removeAllBySensorID(Long sensorID) throws OverflowException { + this.sensorItemDAO.deleteAll(this.readAllBySensorID(sensorID)); + } + } diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java index d213b59..1624ae9 100644 --- a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java +++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorService.java @@ -57,8 +57,15 @@ public class CentralSensorService implements SensorService { @Transactional @Override public Sensor modify(Long sensorID, List metaDisplayItemMappings) throws OverflowException { - // FIXME : not impl - return null; + Sensor sensor = this.read(sensorID); + if (null == sensor) { + throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID)); + } + this.sensorItemService.readAllBySensorID(sensorID); + for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) { + this.sensorItemService.regist(sensor, metaDisplayItemMapping); + } + return sensor; } @Override