Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
024f49fd10
2
pom.xml
2
pom.xml
|
@ -50,7 +50,7 @@
|
|||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>commons-java</artifactId>
|
||||
<version>1.0.111-SNAPSHOT</version>
|
||||
<version>1.0.113-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -16,4 +16,6 @@ public interface MetaDisplayItemMappingDAO extends JpaRepository<MetaDisplayItem
|
|||
List<MetaDisplayItemMapping> findAllByMetaCrawlerMappingId(Long metaCrawlerMappingID);
|
||||
|
||||
List<MetaDisplayItemMapping> findAllByMetaDisplayItemId(Long metaDisplayItemID);
|
||||
|
||||
List<MetaDisplayItemMapping> findAllByMetaCrawlerMappingIdAndIsDefaultTrueAndIsRequiredTrue(Long metaDisplayItemID);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMapp
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<MetaDisplayItemMapping> readAllByMetaCrawlerMappingID(Long metaCrawlerMappingID) throws OverflowException {
|
||||
public List<MetaDisplayItemMapping> readAllByMetaCrawlerMappingID(Long metaCrawlerMappingID)
|
||||
throws OverflowException {
|
||||
return this.metaDisplayItemMappingDAO.findAllByMetaCrawlerMappingId(metaCrawlerMappingID);
|
||||
}
|
||||
|
||||
|
@ -37,4 +38,9 @@ public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMapp
|
|||
public List<MetaDisplayItemMapping> readAll() throws OverflowException {
|
||||
return this.metaDisplayItemMappingDAO.findAll();
|
||||
}
|
||||
|
||||
public List<MetaDisplayItemMapping> readAllDefault(Long metaCrawlerMappingID) throws OverflowException {
|
||||
return this.metaDisplayItemMappingDAO
|
||||
.findAllByMetaCrawlerMappingIdAndIsDefaultTrueAndIsRequiredTrue(metaCrawlerMappingID);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
|
@ -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<Target> targets) throws OverflowException {
|
||||
for (Target target : targets) {
|
||||
this.registDefault(target);
|
||||
}
|
||||
}
|
||||
|
||||
private void registDefault(Target target) throws OverflowException {
|
||||
List<MetaCrawlerMapping> 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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -49,6 +49,8 @@ public class SensorServiceTest {
|
|||
List<MetaCrawlerMapping> metaCrawlerMappings = this.metaCrawlerMappingDAO.findAll();
|
||||
sensor.setMetaCrawlerMapping(metaCrawlerMappings.get(0));
|
||||
|
||||
sensor.setInterval(metaCrawlerMappings.get(0).getDefaultInterval());
|
||||
|
||||
Sensor result = this.sensorService.regist(sensor, this.metaDisplayItemMappingService.findAll());
|
||||
Assert.assertNotNull(result);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user