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 471e6bd..ecb7d27 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 @@ -25,11 +25,16 @@ public class CentralSensorItemService implements SensorItemService { @Autowired private CentralSensorService sensorService; + @Transactional public SensorItem regist(Sensor sensor, MetaDisplayItemMapping metaDisplayItemMapping) throws OverflowException { SensorItem sensorItem = new SensorItem(); sensorItem.setMetaDisplayItemMapping(metaDisplayItemMapping); sensorItem.setSensor(sensor); - return this.sensorItemDAO.save(sensorItem); + SensorItem retSensorItem = this.sensorItemDAO.save(sensorItem); + if (null != retSensorItem) { + this.sensorService.increaseSensorItemCount(sensor.getId()); + } + return retSensorItem; } @Override 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 7041774..377d643 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 @@ -37,6 +37,7 @@ public class CentralSensorService implements SensorService { @Autowired private CentralSensorConfigService sensorConfigService; + @Transactional public void registDefaults(List targets) throws OverflowException { for (Target target : targets) { this.registDefault(target); diff --git a/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java index 33eb920..7a01c62 100644 --- a/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java +++ b/src/test/java/com/loafle/overflow/central/module/sensor/service/SensorServiceTest.java @@ -44,9 +44,10 @@ public class SensorServiceTest { InfraService infraService; @Test + @Ignore public void registDefault() throws Exception { - Long tempInfraID = Long.valueOf(1); - Long tempProbeID = Long.valueOf(1); + Long tempInfraID = Long.valueOf(28); // ssh + Long tempProbeID = Long.valueOf(3); Infra infra = this.infraService.read(tempInfraID); List infraIDs = new ArrayList<>();