diff --git a/pom.xml b/pom.xml
index 8016c34..301e51a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,7 +50,7 @@
com.loafle.overflow
commons-java
- 1.0.112-SNAPSHOT
+ 1.0.113-SNAPSHOT
diff --git a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaDisplayItemMappingDAO.java b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaDisplayItemMappingDAO.java
index 99fd533..4fab9ff 100644
--- a/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaDisplayItemMappingDAO.java
+++ b/src/main/java/com/loafle/overflow/central/module/meta/dao/MetaDisplayItemMappingDAO.java
@@ -16,4 +16,6 @@ public interface MetaDisplayItemMappingDAO extends JpaRepository findAllByMetaCrawlerMappingId(Long metaCrawlerMappingID);
List findAllByMetaDisplayItemId(Long metaDisplayItemID);
+
+ List findAllByMetaCrawlerMappingIdAndIsDefaultTrueAndIsRequiredTrue(Long metaDisplayItemID);
}
diff --git a/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaDisplayItemMappingService.java b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaDisplayItemMappingService.java
index 1432ed8..a6e1eec 100644
--- a/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaDisplayItemMappingService.java
+++ b/src/main/java/com/loafle/overflow/central/module/meta/service/CentralMetaDisplayItemMappingService.java
@@ -15,8 +15,8 @@ import java.util.List;
*/
@Service("MetaDisplayItemMappingService")
public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMappingService {
- @Autowired
- private MetaDisplayItemMappingDAO metaDisplayItemMappingDAO;
+ @Autowired
+ private MetaDisplayItemMappingDAO metaDisplayItemMappingDAO;
@Override
public MetaDisplayItemMapping regist(MetaDisplayItemMapping metaDisplayItemMapping) throws OverflowException {
@@ -29,7 +29,8 @@ public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMapp
}
@Override
- public List readAllByMetaCrawlerMappingID(Long metaCrawlerMappingID) throws OverflowException {
+ public List readAllByMetaCrawlerMappingID(Long metaCrawlerMappingID)
+ throws OverflowException {
return this.metaDisplayItemMappingDAO.findAllByMetaCrawlerMappingId(metaCrawlerMappingID);
}
@@ -37,4 +38,9 @@ public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMapp
public List readAll() throws OverflowException {
return this.metaDisplayItemMappingDAO.findAll();
}
+
+ public List readAllDefault(Long metaCrawlerMappingID) throws OverflowException {
+ return this.metaDisplayItemMappingDAO
+ .findAllByMetaCrawlerMappingIdAndIsDefaultTrueAndIsRequiredTrue(metaCrawlerMappingID);
+ }
}
diff --git a/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java
new file mode 100644
index 0000000..750883e
--- /dev/null
+++ b/src/main/java/com/loafle/overflow/central/module/sensor/service/CentralSensorConfigService.java
@@ -0,0 +1,13 @@
+package com.loafle.overflow.central.module.sensor.service;
+
+import com.loafle.overflow.model.sensor.Sensor;
+
+import org.springframework.stereotype.Service;
+
+@Service("SensorConfigService")
+public class CentralSensorConfigService {
+
+ public void regist(Sensor sensor) {
+
+ }
+}
\ No newline at end of file
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 1624ae9..7041774 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
@@ -1,13 +1,16 @@
package com.loafle.overflow.central.module.sensor.service;
+import com.loafle.overflow.central.module.meta.service.CentralMetaCrawlerMappingService;
+import com.loafle.overflow.central.module.meta.service.CentralMetaDisplayItemMappingService;
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
+import com.loafle.overflow.central.module.target.service.CentralTargetService;
import com.loafle.overflow.core.exception.OverflowException;
+import com.loafle.overflow.model.meta.MetaCrawlerMapping;
import com.loafle.overflow.model.meta.MetaDisplayItemMapping;
import com.loafle.overflow.model.meta.MetaSensorStatus;
import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.sensor.SensorService;
-import com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -23,12 +26,37 @@ public class CentralSensorService implements SensorService {
@Autowired
private SensorDAO sensorDAO;
-
@Autowired
private CentralSensorItemService sensorItemService;
-
@Autowired
- private TargetService targetService;
+ private CentralTargetService targetService;
+ @Autowired
+ private CentralMetaCrawlerMappingService metaCrawlerMappingService;
+ @Autowired
+ private CentralMetaDisplayItemMappingService metaDisplayItemMappingService;
+ @Autowired
+ private CentralSensorConfigService sensorConfigService;
+
+ public void registDefaults(List targets) throws OverflowException {
+ for (Target target : targets) {
+ this.registDefault(target);
+ }
+ }
+
+ private void registDefault(Target target) throws OverflowException {
+ List metaCrawlerMappings = this.metaCrawlerMappingService
+ .readAllByMetaTargetTypeKey(target.getMetaTargetType().getKey());
+ for (MetaCrawlerMapping metaCrawlerMapping : metaCrawlerMappings) {
+ if (metaCrawlerMapping.getDefault()) {
+ Sensor sensor = new Sensor();
+ sensor.setMetaCrawlerMapping(metaCrawlerMapping);
+ sensor.setInterval(metaCrawlerMapping.getDefaultInterval());
+ sensor.setTarget(target);
+
+ this.regist(sensor, this.metaDisplayItemMappingService.readAllDefault(metaCrawlerMapping.getId()));
+ }
+ }
+ }
@Transactional
@Override
@@ -44,14 +72,17 @@ public class CentralSensorService implements SensorService {
sensor.setName(targetTypeName + " Sensor via " + crawlerName);
}
sensor.setMetaSensorStatus(MetaSensorStatus.Enum.RUNNING.to());
- Sensor s = this.sensorDAO.save(sensor);
- s.setItemCount(0);
+ Sensor retSensor = this.sensorDAO.save(sensor);
+ retSensor.setItemCount(0);
this.targetService.increaseSensorCount(targetID);
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
- this.sensorItemService.regist(s, metaDisplayItemMapping);
+ this.sensorItemService.regist(retSensor, metaDisplayItemMapping);
}
- return s;
+
+ this.sensorConfigService.regist(retSensor);
+
+ return retSensor;
}
@Transactional
@@ -61,7 +92,7 @@ public class CentralSensorService implements SensorService {
if (null == sensor) {
throw new OverflowException(String.format("ID[%d] of Sensor is not valid", sensorID));
}
- this.sensorItemService.readAllBySensorID(sensorID);
+ this.sensorItemService.removeAllBySensorID(sensorID);
for (MetaDisplayItemMapping metaDisplayItemMapping : metaDisplayItemMappings) {
this.sensorItemService.regist(sensor, metaDisplayItemMapping);
}
diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java
index 715fae6..d93b80d 100644
--- a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java
+++ b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import com.loafle.overflow.central.module.probe.service.CentralProbeService;
+import com.loafle.overflow.central.module.sensor.service.CentralSensorService;
import com.loafle.overflow.central.module.target.dao.TargetDAO;
import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.infra.Infra;
@@ -30,6 +31,8 @@ public class CentralTargetService implements TargetService {
private InfraService infraService;
@Autowired
private CentralProbeService probeService;
+ @Autowired
+ private CentralSensorService sensorService;
@Transactional
public Target regist(Target target, Long probeID) throws OverflowException {
@@ -105,6 +108,9 @@ public class CentralTargetService implements TargetService {
probe.setTargetCount(targetCount);
this.probeService.modify(probe);
+ // FIXME : process asynchronously
+ this.sensorService.registDefaults(registered);
+
return registered;
}
diff --git a/src/main/resources/common/init.meta.sql b/src/main/resources/common/init.meta.sql
index ff70694..1c17783 100644
--- a/src/main/resources/common/init.meta.sql
+++ b/src/main/resources/common/init.meta.sql
@@ -1212,11 +1212,7 @@ VALUES
( 1 , 'service.health.response_time' , 'Service Response Time' );
-INSERT INTO public.meta_display_item_mapping
- ( id , meta_crawler_mapping_id , meta_display_item_id , is_default , priority )
-VALUES
- ( 1 , 252 , 1 , 'true' , 1 );
-
+INSERT INTO public.meta_display_item_mapping ( id , meta_crawler_mapping_id , meta_display_item_id , is_default , priority , is_required , meta_display_item_category_id ) VALUES ( 1 , 252 , 1 , 'true' , 1 , 'true' , 1 );
INSERT INTO public.meta_collection_item
( id , key , item , item_class )