test
This commit is contained in:
parent
f0c498c980
commit
e92de9d97d
2
pom.xml
2
pom.xml
@ -50,7 +50,7 @@
|
||||
<dependency>
|
||||
<groupId>com.loafle.overflow</groupId>
|
||||
<artifactId>commons-java</artifactId>
|
||||
<version>1.0.101-SNAPSHOT</version>
|
||||
<version>1.0.102-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -1,96 +1,100 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaCrawler;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
||||
// import com.loafle.overflow.core.exception.OverflowException;
|
||||
// import com.loafle.overflow.model.meta.MetaCrawler;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
// import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
// import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("GenerateUtil")
|
||||
public class GenerateUtil {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("GenerateUtil")
|
||||
// public class GenerateUtil {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemKeyService metaSensorItemKeyService;
|
||||
// @Autowired
|
||||
// private MetaSensorItemKeyService metaSensorItemKeyService;
|
||||
|
||||
private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null;
|
||||
// private Map<Short, Map<Integer, MetaSensorItemKey>> mappingMap = null;
|
||||
|
||||
public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler metaCrawler) throws OverflowException {
|
||||
// public Map<Integer, MetaSensorItemKey> initMappingMap(MetaCrawler
|
||||
// metaCrawler) throws OverflowException {
|
||||
|
||||
if (this.mappingMap == null) {
|
||||
this.mappingMap = new HashMap<>();
|
||||
}
|
||||
// if (this.mappingMap == null) {
|
||||
// this.mappingMap = new HashMap<>();
|
||||
// }
|
||||
|
||||
Map<Integer, MetaSensorItemKey> resultMap = this.mappingMap.get(metaCrawler.getId());
|
||||
// Map<Integer, MetaSensorItemKey> resultMap =
|
||||
// this.mappingMap.get(metaCrawler.getId());
|
||||
|
||||
if (resultMap != null) {
|
||||
return resultMap;
|
||||
}
|
||||
// if (resultMap != null) {
|
||||
// return resultMap;
|
||||
// }
|
||||
|
||||
resultMap = this.metaSensorItemKeyService.readAllMapByMetaCrawlerID(metaCrawler.getId());
|
||||
this.mappingMap.put(metaCrawler.getId(), resultMap);
|
||||
// resultMap =
|
||||
// this.metaSensorItemKeyService.readAllMapByMetaCrawlerID(metaCrawler.getId());
|
||||
// this.mappingMap.put(metaCrawler.getId(), resultMap);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
// return resultMap;
|
||||
// }
|
||||
|
||||
public Crawler getCrawler(MetaCrawler metaCrawler) throws OverflowException {
|
||||
// public Crawler getCrawler(MetaCrawler metaCrawler) throws OverflowException {
|
||||
|
||||
Crawler crawler = new Crawler();
|
||||
crawler.setName(metaCrawler.getName());
|
||||
// Crawler crawler = new Crawler();
|
||||
// crawler.setName(metaCrawler.getName());
|
||||
|
||||
String container = "";
|
||||
// String container = "";
|
||||
|
||||
// if (metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
|
||||
// || metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// container = "java_proxy";
|
||||
// } else {
|
||||
// container = "network_proxy";
|
||||
// }
|
||||
// // if (metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
|
||||
// // || metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// // container = "java_proxy";
|
||||
// // } else {
|
||||
// // container = "network_proxy";
|
||||
// // }
|
||||
|
||||
crawler.setContainer(container);
|
||||
// crawler.setContainer(container);
|
||||
|
||||
return crawler;
|
||||
}
|
||||
// return crawler;
|
||||
// }
|
||||
|
||||
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems,
|
||||
Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException {
|
||||
// public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem>
|
||||
// sensorItems,
|
||||
// Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException {
|
||||
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>();
|
||||
// Map<String, List<MetaSensorItemKey>> metricMap = new HashMap<>();
|
||||
|
||||
MetaSensorItemKey itemKey = null;
|
||||
// MetaSensorItemKey itemKey = null;
|
||||
|
||||
for (SensorItem sItem : sensorItems) {
|
||||
itemKey = keyMap.get(sItem.getMetaSensorDisplayItem().getId());
|
||||
if (metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
}
|
||||
metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
}
|
||||
// for (SensorItem sItem : sensorItems) {
|
||||
// itemKey = keyMap.get(sItem.getMetaSensorDisplayItem().getId());
|
||||
// if (metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
// metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
// }
|
||||
// metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
// }
|
||||
|
||||
return metricMap;
|
||||
}
|
||||
// return metricMap;
|
||||
// }
|
||||
|
||||
public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
|
||||
Keys keys = new Keys();
|
||||
keys.setKey(itemKey.getKey());
|
||||
keys.setMetric(itemKey.getMetaSensorItem().getKey());
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
// public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
|
||||
// Keys keys = new Keys();
|
||||
// keys.setKey(itemKey.getKey());
|
||||
// keys.setMetric(itemKey.getMetaSensorItem().getKey());
|
||||
// return keys;
|
||||
// }
|
||||
// }
|
||||
|
@ -1,110 +1,114 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||
import com.loafle.overflow.model.infra.Infra;
|
||||
import com.loafle.overflow.model.infra.InfraHost;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Connection;
|
||||
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
import com.loafle.overflow.model.sensorconfig.Target;
|
||||
// import com.loafle.overflow.model.auth.AuthCrawler;
|
||||
// import com.loafle.overflow.model.infra.Infra;
|
||||
// import com.loafle.overflow.model.infra.InfraHost;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Connection;
|
||||
// import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
// import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||
// import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
// import com.loafle.overflow.model.sensorconfig.Target;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.core.type.TypeReference;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraHostGenerator")
|
||||
public class InfraHostGenerator {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("InfraHostGenerator")
|
||||
// public class InfraHostGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
// @Autowired
|
||||
// private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private InfraHostWMIGenerator infraHostWMIGenerator;
|
||||
// @Autowired
|
||||
// private InfraHostWMIGenerator infraHostWMIGenerator;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
|
||||
// public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra
|
||||
// infra) throws Exception {
|
||||
|
||||
InfraHost infraHost = (InfraHost) infra;
|
||||
// InfraHost infraHost = (InfraHost) infra;
|
||||
|
||||
SensorConfig sensorConfig = new SensorConfig();
|
||||
sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||
// SensorConfig sensorConfig = new SensorConfig();
|
||||
// sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||
|
||||
Target target = this.createTarget(infraHost, dbSensor);
|
||||
// Target target = this.createTarget(infraHost, dbSensor);
|
||||
|
||||
if (target == null) {
|
||||
return null;
|
||||
}
|
||||
// if (target == null) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
sensorConfig.setTarget(target);
|
||||
// sensorConfig.setTarget(target);
|
||||
|
||||
// FIXME: Interval
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setInterval("5");
|
||||
sensorConfig.setSchedule(schedule);
|
||||
// // FIXME: Interval
|
||||
// Schedule schedule = new Schedule();
|
||||
// schedule.setInterval("5");
|
||||
// sensorConfig.setSchedule(schedule);
|
||||
|
||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||
sensorConfig.setCrawler(crawler);
|
||||
// Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||
// sensorConfig.setCrawler(crawler);
|
||||
|
||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||
// Map<Integer, MetaSensorItemKey> keyMap =
|
||||
// this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||
|
||||
// if (dbSensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
// this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// sensorConfig);
|
||||
// }
|
||||
// // if (dbSensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
// // this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// // sensorConfig);
|
||||
// // }
|
||||
|
||||
return objectMapper.writeValueAsString(sensorConfig);
|
||||
}
|
||||
// return objectMapper.writeValueAsString(sensorConfig);
|
||||
// }
|
||||
|
||||
private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws Exception {
|
||||
// private Target createTarget(InfraHost infraHost, Sensor dbSensor) throws
|
||||
// Exception {
|
||||
|
||||
// AuthCrawler authCrawler =
|
||||
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(),
|
||||
// dbSensor.getTarget().getId());
|
||||
// // AuthCrawler authCrawler =
|
||||
// //
|
||||
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(),
|
||||
// // dbSensor.getTarget().getId());
|
||||
|
||||
// if (authCrawler == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // if (authCrawler == null) {
|
||||
// // return null;
|
||||
// // }
|
||||
|
||||
// Target target = new Target();
|
||||
// Connection connection = new Connection();
|
||||
// // connection.setIp(infraHost.getIpv4());
|
||||
// // Target target = new Target();
|
||||
// // Connection connection = new Connection();
|
||||
// // // connection.setIp(infraHost.getIpv4());
|
||||
|
||||
// HashMap<String, String> optionMap =
|
||||
// this.objectMapper.readValue(authCrawler.getAuthJson(),
|
||||
// new TypeReference<Map<String, String>>() {
|
||||
// });
|
||||
// // HashMap<String, String> optionMap =
|
||||
// // this.objectMapper.readValue(authCrawler.getAuthJson(),
|
||||
// // new TypeReference<Map<String, String>>() {
|
||||
// // });
|
||||
|
||||
// if (dbSensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
// connection.setPort(135);
|
||||
// connection.setPortType(PortType.TCP);
|
||||
// connection.setSsl(false);
|
||||
// // if (dbSensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
|
||||
// // connection.setPort(135);
|
||||
// // connection.setPortType(PortType.TCP);
|
||||
// // connection.setSsl(false);
|
||||
|
||||
// target.setConnection(connection);
|
||||
// // target.setConnection(connection);
|
||||
|
||||
// Map<String, Object> auth = new HashMap<>();
|
||||
// auth.put("id", optionMap.get("ID"));
|
||||
// auth.put("pw", optionMap.get("PassWord"));
|
||||
// // Map<String, Object> auth = new HashMap<>();
|
||||
// // auth.put("id", optionMap.get("ID"));
|
||||
// // auth.put("pw", optionMap.get("PassWord"));
|
||||
|
||||
// target.setAuth(auth);
|
||||
// // target.setAuth(auth);
|
||||
|
||||
// }
|
||||
// // }
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
@ -1,141 +1,144 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Item;
|
||||
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Item;
|
||||
// import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
// import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.core.type.TypeReference;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraHostWMIGenerator")
|
||||
public class InfraHostWMIGenerator {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("InfraHostWMIGenerator")
|
||||
// public class InfraHostWMIGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
// @Autowired
|
||||
// private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
SensorConfig sensorConfig) throws Exception {
|
||||
// public void process(List<SensorItem> sensorItems, Map<Integer,
|
||||
// MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
// SensorConfig sensorConfig) throws Exception {
|
||||
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
// Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
// metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
// MetaSensorItemKey itemKey = null;
|
||||
//
|
||||
// for(SensorItem sItem : sensorItems) {
|
||||
// itemKey = keyMap.get(sItem.getItem().getId());
|
||||
// if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
// metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
// }
|
||||
// metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
// }
|
||||
// // MetaSensorItemKey itemKey = null;
|
||||
// //
|
||||
// // for(SensorItem sItem : sensorItems) {
|
||||
// // itemKey = keyMap.get(sItem.getItem().getId());
|
||||
// // if(metricMap.containsKey(itemKey.getFroms()) == false) {
|
||||
// // metricMap.put(itemKey.getFroms(), new ArrayList<>());
|
||||
// // }
|
||||
// // metricMap.get(itemKey.getFroms()).add(itemKey);
|
||||
// // }
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
Item item = null;
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
// List<Item> itemList = new ArrayList<>();
|
||||
// Item item = null;
|
||||
// QueryInfo queryInfo = null;
|
||||
// MappingInfo mappingInfo = null;
|
||||
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
// StringBuffer stringBuffer = new StringBuffer();
|
||||
|
||||
Map<String, Object> extendMap = new HashMap<>();
|
||||
extendMap.put("nameSpace", "root/cimv2");
|
||||
extendMap.put("wmicPath", "/home/snoop/temp/wmic");
|
||||
// Map<String, Object> extendMap = new HashMap<>();
|
||||
// extendMap.put("nameSpace", "root/cimv2");
|
||||
// extendMap.put("wmicPath", "/home/snoop/temp/wmic");
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) {
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
stringBuffer.setLength(0);
|
||||
// List<Keys> keysList = null;
|
||||
// MetaSensorItemKey tempItemKey = null;
|
||||
// Keys keys = null;
|
||||
// for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet())
|
||||
// {
|
||||
// keysList = new ArrayList<>();
|
||||
// item = new Item();
|
||||
// stringBuffer.setLength(0);
|
||||
|
||||
stringBuffer.append("SELECT ");
|
||||
// stringBuffer.append("SELECT ");
|
||||
|
||||
for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
// for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
|
||||
tempItemKey = elems.getValue().get(indexI);
|
||||
stringBuffer.append(tempItemKey.getKey());
|
||||
if (indexI + 1 < elems.getValue().size()) {
|
||||
stringBuffer.append(", ");
|
||||
}
|
||||
// tempItemKey = elems.getValue().get(indexI);
|
||||
// stringBuffer.append(tempItemKey.getKey());
|
||||
// if (indexI + 1 < elems.getValue().size()) {
|
||||
// stringBuffer.append(", ");
|
||||
// }
|
||||
|
||||
// keys = new Keys();
|
||||
// keys.setKey(tempItemKey.getKey());
|
||||
// keys.setMetric(tempItemKey.getItem().getKey());
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
// // keys = new Keys();
|
||||
// // keys.setKey(tempItemKey.getKey());
|
||||
// // keys.setMetric(tempItemKey.getItem().getKey());
|
||||
// keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
// }
|
||||
|
||||
List<String> arrayColumns = null;
|
||||
// List<String> arrayColumns = null;
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
if (json != null && json.length() > 0) {
|
||||
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
|
||||
});
|
||||
// String json = tempItemKey.getOption();
|
||||
// if (json != null && json.length() > 0) {
|
||||
// HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
|
||||
// TypeReference<Map<String, String>>() {
|
||||
// });
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("appends");
|
||||
if (obj != null) {
|
||||
List<String> appendsList = (List<String>) obj;
|
||||
for (String append : appendsList) {
|
||||
stringBuffer.append(", ");
|
||||
stringBuffer.append(append);
|
||||
}
|
||||
}
|
||||
// Object obj = null;
|
||||
// obj = optionMap.get("appends");
|
||||
// if (obj != null) {
|
||||
// List<String> appendsList = (List<String>) obj;
|
||||
// for (String append : appendsList) {
|
||||
// stringBuffer.append(", ");
|
||||
// stringBuffer.append(append);
|
||||
// }
|
||||
// }
|
||||
|
||||
stringBuffer.append(" FROM ");
|
||||
stringBuffer.append(elems.getKey());
|
||||
// stringBuffer.append(" FROM ");
|
||||
// stringBuffer.append(elems.getKey());
|
||||
|
||||
obj = optionMap.get("where");
|
||||
if (obj != null) {
|
||||
String where = (String) obj;
|
||||
stringBuffer.append(" WHERE ");
|
||||
stringBuffer.append(where);
|
||||
}
|
||||
// obj = optionMap.get("where");
|
||||
// if (obj != null) {
|
||||
// String where = (String) obj;
|
||||
// stringBuffer.append(" WHERE ");
|
||||
// stringBuffer.append(where);
|
||||
// }
|
||||
|
||||
obj = optionMap.get("arrayColumns");
|
||||
if (obj != null) {
|
||||
arrayColumns = (List<String>) obj;
|
||||
}
|
||||
// obj = optionMap.get("arrayColumns");
|
||||
// if (obj != null) {
|
||||
// arrayColumns = (List<String>) obj;
|
||||
// }
|
||||
|
||||
} else {
|
||||
stringBuffer.append(" FROM ");
|
||||
stringBuffer.append(elems.getKey());
|
||||
}
|
||||
// } else {
|
||||
// stringBuffer.append(" FROM ");
|
||||
// stringBuffer.append(elems.getKey());
|
||||
// }
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(stringBuffer.toString());
|
||||
queryInfo.setExtend(extendMap);
|
||||
// queryInfo = new QueryInfo();
|
||||
// queryInfo.setQuery(stringBuffer.toString());
|
||||
// queryInfo.setExtend(extendMap);
|
||||
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setParseDirection("col");
|
||||
mappingInfo.setArrayColumns(arrayColumns);
|
||||
// mappingInfo = new MappingInfo();
|
||||
// mappingInfo.setParseDirection("col");
|
||||
// mappingInfo.setArrayColumns(arrayColumns);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
// item.setMappingInfo(mappingInfo);
|
||||
// item.setQueryInfo(queryInfo);
|
||||
// item.setKeys(keysList);
|
||||
|
||||
itemList.add(item);
|
||||
// itemList.add(item);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
sensorConfig.setItems(itemList);
|
||||
// sensorConfig.setItems(itemList);
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
// }
|
||||
|
@ -1,125 +1,131 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.model.auth.AuthCrawler;
|
||||
import com.loafle.overflow.model.infra.Infra;
|
||||
import com.loafle.overflow.model.infra.InfraService;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Connection;
|
||||
import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
import com.loafle.overflow.model.sensorconfig.Target;
|
||||
import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
||||
// import com.loafle.overflow.model.auth.AuthCrawler;
|
||||
// import com.loafle.overflow.model.infra.Infra;
|
||||
// import com.loafle.overflow.model.infra.InfraService;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Connection;
|
||||
// import com.loafle.overflow.model.sensorconfig.Crawler;
|
||||
// import com.loafle.overflow.model.sensorconfig.Schedule;
|
||||
// import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
// import com.loafle.overflow.model.sensorconfig.Target;
|
||||
// import com.loafle.overflow.service.central.auth.AuthCrawlerService;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.core.type.TypeReference;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraServiceGenerator")
|
||||
public class InfraServiceGenerator {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("InfraServiceGenerator")
|
||||
// public class InfraServiceGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
// @Autowired
|
||||
// private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceMysqlGenerator infraServiceMysqlGenerator;
|
||||
// @Autowired
|
||||
// private InfraServiceMysqlGenerator infraServiceMysqlGenerator;
|
||||
|
||||
@Autowired
|
||||
private InfraServiceJMXGenerator infraServiceJMXGenerator;
|
||||
// @Autowired
|
||||
// private InfraServiceJMXGenerator infraServiceJMXGenerator;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception {
|
||||
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService) infra;
|
||||
// public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra
|
||||
// infra) throws Exception {
|
||||
// com.loafle.overflow.model.infra.InfraService infraService =
|
||||
// (com.loafle.overflow.model.infra.InfraService) infra;
|
||||
|
||||
SensorConfig sensorConfig = new SensorConfig();
|
||||
sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||
// SensorConfig sensorConfig = new SensorConfig();
|
||||
// sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
|
||||
|
||||
Target target = this.createTarget(infraService, dbSensor);
|
||||
// Target target = this.createTarget(infraService, dbSensor);
|
||||
|
||||
if (target == null) {
|
||||
return null;
|
||||
}
|
||||
// if (target == null) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
sensorConfig.setTarget(target);
|
||||
// sensorConfig.setTarget(target);
|
||||
|
||||
// FIXME: Interval
|
||||
Schedule schedule = new Schedule();
|
||||
schedule.setInterval("5");
|
||||
sensorConfig.setSchedule(schedule);
|
||||
// // FIXME: Interval
|
||||
// Schedule schedule = new Schedule();
|
||||
// schedule.setInterval("5");
|
||||
// sensorConfig.setSchedule(schedule);
|
||||
|
||||
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||
sensorConfig.setCrawler(crawler);
|
||||
// Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
|
||||
// sensorConfig.setCrawler(crawler);
|
||||
|
||||
Map<Integer, MetaSensorItemKey> keyMap = this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||
// Map<Integer, MetaSensorItemKey> keyMap =
|
||||
// this.generateUtil.initMappingMap(dbSensor.getMetaCrawler());
|
||||
|
||||
// if (dbSensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
// this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// sensorConfig);
|
||||
// } else if (dbSensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// sensorConfig);
|
||||
// }
|
||||
// // if (dbSensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
// // this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// // sensorConfig);
|
||||
// // } else if (dbSensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// // this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor,
|
||||
// // sensorConfig);
|
||||
// // }
|
||||
|
||||
return objectMapper.writeValueAsString(sensorConfig);
|
||||
}
|
||||
// return objectMapper.writeValueAsString(sensorConfig);
|
||||
// }
|
||||
|
||||
private Target createTarget(InfraService infraService, Sensor sensor) throws Exception {
|
||||
// private Target createTarget(InfraService infraService, Sensor sensor) throws
|
||||
// Exception {
|
||||
|
||||
// AuthCrawler authCrawler =
|
||||
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(),
|
||||
// sensor.getTarget().getId());
|
||||
// // AuthCrawler authCrawler =
|
||||
// //
|
||||
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(),
|
||||
// // sensor.getTarget().getId());
|
||||
|
||||
// if (authCrawler == null) {
|
||||
// return null;
|
||||
// }
|
||||
// // if (authCrawler == null) {
|
||||
// // return null;
|
||||
// // }
|
||||
|
||||
// Target target = new Target();
|
||||
// Connection connection = new Connection();
|
||||
// // connection.setIp(infraService.getInfraHost().getIpv4());
|
||||
// // connection.setPort(infraService.getPort());
|
||||
// // connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
||||
// // connection.setSsl(infraService.isTlsType());
|
||||
// // Target target = new Target();
|
||||
// // Connection connection = new Connection();
|
||||
// // // connection.setIp(infraService.getInfraHost().getIpv4());
|
||||
// // // connection.setPort(infraService.getPort());
|
||||
// // // connection.setPortType(PortType.valueOf(infraService.getPortType()));
|
||||
// // // connection.setSsl(infraService.isTlsType());
|
||||
|
||||
// target.setConnection(connection);
|
||||
// // target.setConnection(connection);
|
||||
|
||||
// HashMap<String, String> optionMap =
|
||||
// this.objectMapper.readValue(authCrawler.getAuthJson(),
|
||||
// new TypeReference<Map<String, String>>() {
|
||||
// });
|
||||
// // HashMap<String, String> optionMap =
|
||||
// // this.objectMapper.readValue(authCrawler.getAuthJson(),
|
||||
// // new TypeReference<Map<String, String>>() {
|
||||
// // });
|
||||
|
||||
// Map<String, Object> auth = new HashMap<>();
|
||||
// // Map<String, Object> auth = new HashMap<>();
|
||||
|
||||
// // if (sensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
// // auth.put("url", "jdbc:mysql://" + infraService.getInfraHost().getIpv4() +
|
||||
// ":" + infraService.getPort());
|
||||
// // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
// // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
// // } else if (sensor.getMetaCrawler().getId() ==
|
||||
// MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
// // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
// // connection.setPort(9840);
|
||||
// // }
|
||||
// // // if (sensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
|
||||
// // // auth.put("url", "jdbc:mysql://" + infraService.getInfraHost().getIpv4()
|
||||
// +
|
||||
// // ":" + infraService.getPort());
|
||||
// // // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
// // // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
// // // } else if (sensor.getMetaCrawler().getId() ==
|
||||
// // MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
|
||||
// // // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
|
||||
// // // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
|
||||
// // // connection.setPort(9840);
|
||||
// // // }
|
||||
|
||||
// target.setAuth(auth);
|
||||
// // target.setAuth(auth);
|
||||
|
||||
// return target;
|
||||
return null;
|
||||
}
|
||||
// // return target;
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -1,108 +1,111 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Item;
|
||||
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Item;
|
||||
// import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
// import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.core.type.TypeReference;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by geek on 17. 9. 11.
|
||||
*/
|
||||
@Service("InfraServiceJMXGenerator")
|
||||
public class InfraServiceJMXGenerator {
|
||||
// /**
|
||||
// * Created by geek on 17. 9. 11.
|
||||
// */
|
||||
// @Service("InfraServiceJMXGenerator")
|
||||
// public class InfraServiceJMXGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
// @Autowired
|
||||
// private GenerateUtil generateUtil;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
SensorConfig sensorConfig) throws Exception {
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
// public void process(List<SensorItem> sensorItems, Map<Integer,
|
||||
// MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
// SensorConfig sensorConfig) throws Exception {
|
||||
// Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
// metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
Item item = null;
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
// List<Item> itemList = new ArrayList<>();
|
||||
// Item item = null;
|
||||
// QueryInfo queryInfo = null;
|
||||
// MappingInfo mappingInfo = null;
|
||||
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
// StringBuffer buffer = new StringBuffer();
|
||||
|
||||
Map<String, Object> extendMap = new HashMap<>();
|
||||
// Map<String, Object> extendMap = new HashMap<>();
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
// List<Keys> keysList = null;
|
||||
// MetaSensorItemKey tempItemKey = null;
|
||||
// Keys keys = null;
|
||||
|
||||
for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet()) {
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
buffer.setLength(0);
|
||||
// for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet())
|
||||
// {
|
||||
// keysList = new ArrayList<>();
|
||||
// item = new Item();
|
||||
// buffer.setLength(0);
|
||||
|
||||
buffer.append(elms.getKey());
|
||||
// buffer.append(elms.getKey());
|
||||
|
||||
for (int idx = 0; idx < elms.getValue().size(); idx++) {
|
||||
tempItemKey = elms.getValue().get(idx);
|
||||
// for (int idx = 0; idx < elms.getValue().size(); idx++) {
|
||||
// tempItemKey = elms.getValue().get(idx);
|
||||
|
||||
buffer.append(tempItemKey.getKey());
|
||||
// buffer.append(tempItemKey.getKey());
|
||||
|
||||
keys = new Keys();
|
||||
keys.setKey(tempItemKey.getKey());
|
||||
keys.setMetric(tempItemKey.getMetaSensorItem().getKey());
|
||||
// keys = new Keys();
|
||||
// keys.setKey(tempItemKey.getKey());
|
||||
// keys.setMetric(tempItemKey.getMetaSensorItem().getKey());
|
||||
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
// keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
// }
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
List<String> aliases = null;
|
||||
List<String> arrayCol = null;
|
||||
// String json = tempItemKey.getOption();
|
||||
// List<String> aliases = null;
|
||||
// List<String> arrayCol = null;
|
||||
|
||||
if (json != null && json.length() > 0) {
|
||||
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
|
||||
});
|
||||
// if (json != null && json.length() > 0) {
|
||||
// HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
|
||||
// TypeReference<Map<String, String>>() {
|
||||
// });
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("aliases");
|
||||
// Object obj = null;
|
||||
// obj = optionMap.get("aliases");
|
||||
|
||||
if (obj != null) {
|
||||
aliases = (List<String>) obj;
|
||||
}
|
||||
// if (obj != null) {
|
||||
// aliases = (List<String>) obj;
|
||||
// }
|
||||
|
||||
obj = optionMap.get("arrayColumns");
|
||||
if (obj != null) {
|
||||
arrayCol = (List<String>) obj;
|
||||
}
|
||||
}
|
||||
// obj = optionMap.get("arrayColumns");
|
||||
// if (obj != null) {
|
||||
// arrayCol = (List<String>) obj;
|
||||
// }
|
||||
// }
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(tempItemKey.getFroms());
|
||||
queryInfo.setExtend(extendMap);
|
||||
// queryInfo = new QueryInfo();
|
||||
// queryInfo.setQuery(tempItemKey.getFroms());
|
||||
// queryInfo.setExtend(extendMap);
|
||||
|
||||
extendMap.put("aliases", aliases);
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setArrayColumns(arrayCol);
|
||||
// extendMap.put("aliases", aliases);
|
||||
// mappingInfo = new MappingInfo();
|
||||
// mappingInfo.setArrayColumns(arrayCol);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
itemList.add(item);
|
||||
}
|
||||
sensorConfig.setItems(itemList);
|
||||
}
|
||||
// item.setMappingInfo(mappingInfo);
|
||||
// item.setQueryInfo(queryInfo);
|
||||
// item.setKeys(keysList);
|
||||
// itemList.add(item);
|
||||
// }
|
||||
// sensorConfig.setItems(itemList);
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -1,156 +1,160 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.model.sensorconfig.Item;
|
||||
import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
// import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.model.sensorconfig.Item;
|
||||
// import com.loafle.overflow.model.sensorconfig.Keys;
|
||||
// import com.loafle.overflow.model.sensorconfig.MappingInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.QueryInfo;
|
||||
// import com.loafle.overflow.model.sensorconfig.SensorConfig;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
// import com.fasterxml.jackson.core.type.TypeReference;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
// import java.util.ArrayList;
|
||||
// import java.util.HashMap;
|
||||
// import java.util.List;
|
||||
// import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("InfraServiceMysqlGenerator")
|
||||
public class InfraServiceMysqlGenerator {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("InfraServiceMysqlGenerator")
|
||||
// public class InfraServiceMysqlGenerator {
|
||||
|
||||
@Autowired
|
||||
private GenerateUtil generateUtil;
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
// @Autowired
|
||||
// private GenerateUtil generateUtil;
|
||||
// @Autowired
|
||||
// private ObjectMapper objectMapper;
|
||||
|
||||
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
SensorConfig sensorConfig) throws Exception {
|
||||
// public void process(List<SensorItem> sensorItems, Map<Integer,
|
||||
// MetaSensorItemKey> keyMap, Sensor dbSensor,
|
||||
// SensorConfig sensorConfig) throws Exception {
|
||||
|
||||
// List<Keys> keysList = new ArrayList<>();
|
||||
// for(SensorItem sItem : sensorItems) {
|
||||
// keys = new Keys();
|
||||
// keys.setMetric(sItem.getItem().getKey());
|
||||
// keys.setKey(KeyMap.get(sItem.getItem().getId()).getKey());
|
||||
// keysList.add(keys);
|
||||
// }
|
||||
// item.setKeys(keysList);
|
||||
Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
// // List<Keys> keysList = new ArrayList<>();
|
||||
// // for(SensorItem sItem : sensorItems) {
|
||||
// // keys = new Keys();
|
||||
// // keys.setMetric(sItem.getItem().getKey());
|
||||
// // keys.setKey(KeyMap.get(sItem.getItem().getId()).getKey());
|
||||
// // keysList.add(keys);
|
||||
// // }
|
||||
// // item.setKeys(keysList);
|
||||
// Map<String, List<MetaSensorItemKey>> metricMap = null;
|
||||
// metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
|
||||
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
// List<Item> itemList = new ArrayList<>();
|
||||
|
||||
QueryInfo queryInfo = null;
|
||||
MappingInfo mappingInfo = null;
|
||||
// QueryInfo queryInfo = null;
|
||||
// MappingInfo mappingInfo = null;
|
||||
|
||||
List<Keys> keysList = null;
|
||||
MetaSensorItemKey tempItemKey = null;
|
||||
Keys keys = null;
|
||||
Item item = null;
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) {
|
||||
// List<Keys> keysList = null;
|
||||
// MetaSensorItemKey tempItemKey = null;
|
||||
// Keys keys = null;
|
||||
// Item item = null;
|
||||
// StringBuffer stringBuffer = new StringBuffer();
|
||||
// for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet())
|
||||
// {
|
||||
|
||||
keysList = new ArrayList<>();
|
||||
item = new Item();
|
||||
stringBuffer.setLength(0);
|
||||
// keysList = new ArrayList<>();
|
||||
// item = new Item();
|
||||
// stringBuffer.setLength(0);
|
||||
|
||||
stringBuffer.append(elems.getKey());
|
||||
// stringBuffer.append(elems.getKey());
|
||||
|
||||
stringBuffer.append(" where ");
|
||||
for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
tempItemKey = elems.getValue().get(indexI);
|
||||
// stringBuffer.append(" where ");
|
||||
// for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
|
||||
// tempItemKey = elems.getValue().get(indexI);
|
||||
|
||||
stringBuffer.append("variable_name = '");
|
||||
stringBuffer.append(tempItemKey.getKey());
|
||||
stringBuffer.append("'");
|
||||
// stringBuffer.append("variable_name = '");
|
||||
// stringBuffer.append(tempItemKey.getKey());
|
||||
// stringBuffer.append("'");
|
||||
|
||||
if (indexI + 1 < elems.getValue().size()) {
|
||||
stringBuffer.append(" or ");
|
||||
}
|
||||
keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
}
|
||||
// if (indexI + 1 < elems.getValue().size()) {
|
||||
// stringBuffer.append(" or ");
|
||||
// }
|
||||
// keysList.add(this.generateUtil.createKeys(tempItemKey));
|
||||
// }
|
||||
|
||||
List<String> keyColumns = null;
|
||||
String valueColumn = null;
|
||||
// List<String> keyColumns = null;
|
||||
// String valueColumn = null;
|
||||
|
||||
String json = tempItemKey.getOption();
|
||||
if (json != null && json.length() > 0) {
|
||||
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() {
|
||||
});
|
||||
// String json = tempItemKey.getOption();
|
||||
// if (json != null && json.length() > 0) {
|
||||
// HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
|
||||
// TypeReference<Map<String, String>>() {
|
||||
// });
|
||||
|
||||
Object obj = null;
|
||||
obj = optionMap.get("valueColumn");
|
||||
if (obj != null) {
|
||||
valueColumn = (String) obj;
|
||||
}
|
||||
// Object obj = null;
|
||||
// obj = optionMap.get("valueColumn");
|
||||
// if (obj != null) {
|
||||
// valueColumn = (String) obj;
|
||||
// }
|
||||
|
||||
obj = optionMap.get("keyColumns");
|
||||
if (obj != null) {
|
||||
keyColumns = (List<String>) obj;
|
||||
}
|
||||
}
|
||||
// obj = optionMap.get("keyColumns");
|
||||
// if (obj != null) {
|
||||
// keyColumns = (List<String>) obj;
|
||||
// }
|
||||
// }
|
||||
|
||||
queryInfo = new QueryInfo();
|
||||
queryInfo.setQuery(stringBuffer.toString());
|
||||
// queryInfo = new QueryInfo();
|
||||
// queryInfo.setQuery(stringBuffer.toString());
|
||||
|
||||
mappingInfo = new MappingInfo();
|
||||
mappingInfo.setParseDirection("row");
|
||||
mappingInfo.setValueColumn(valueColumn);
|
||||
mappingInfo.setKeyColumns(keyColumns);
|
||||
// mappingInfo = new MappingInfo();
|
||||
// mappingInfo.setParseDirection("row");
|
||||
// mappingInfo.setValueColumn(valueColumn);
|
||||
// mappingInfo.setKeyColumns(keyColumns);
|
||||
|
||||
item.setMappingInfo(mappingInfo);
|
||||
item.setQueryInfo(queryInfo);
|
||||
item.setKeys(keysList);
|
||||
// item.setMappingInfo(mappingInfo);
|
||||
// item.setQueryInfo(queryInfo);
|
||||
// item.setKeys(keysList);
|
||||
|
||||
itemList.add(item);
|
||||
// itemList.add(item);
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
sensorConfig.setItems(itemList);
|
||||
// sensorConfig.setItems(itemList);
|
||||
|
||||
// ObjectMapper objectMapper = new ObjectMapper();
|
||||
//
|
||||
// return objectMapper.writeValueAsString(config);
|
||||
}
|
||||
// // ObjectMapper objectMapper = new ObjectMapper();
|
||||
// //
|
||||
// // return objectMapper.writeValueAsString(config);
|
||||
// }
|
||||
|
||||
// public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList,
|
||||
// QueryInfo queryInfo, MappingInfo mappingInfo) {
|
||||
//
|
||||
// switch (metaCrawler.getId()) {
|
||||
// case 11: // mysql
|
||||
// {
|
||||
// String query = "show status where ";
|
||||
//// queryInfo.setQuery("show status where ");
|
||||
//
|
||||
// Keys keys = null;
|
||||
// for(int indexI = 0 ; indexI < keysList.size(); ++indexI) {
|
||||
// keys = keysList.get(indexI);
|
||||
// query += "variable_name = '";
|
||||
// query += keys.getKey();
|
||||
// query += "'";
|
||||
// if(indexI + 1 < keysList.size()) {
|
||||
// query += " or ";
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// queryInfo.setQuery(query);
|
||||
//
|
||||
// mappingInfo.setParseDirection("row");
|
||||
// mappingInfo.setValueColumn("Value");
|
||||
//
|
||||
// List<String> keyColumns = new ArrayList<>();
|
||||
// keyColumns.add("Variable_name");
|
||||
//
|
||||
// mappingInfo.setKeyColumns(keyColumns);
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
// // public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys>
|
||||
// keysList,
|
||||
// // QueryInfo queryInfo, MappingInfo mappingInfo) {
|
||||
// //
|
||||
// // switch (metaCrawler.getId()) {
|
||||
// // case 11: // mysql
|
||||
// // {
|
||||
// // String query = "show status where ";
|
||||
// //// queryInfo.setQuery("show status where ");
|
||||
// //
|
||||
// // Keys keys = null;
|
||||
// // for(int indexI = 0 ; indexI < keysList.size(); ++indexI) {
|
||||
// // keys = keysList.get(indexI);
|
||||
// // query += "variable_name = '";
|
||||
// // query += keys.getKey();
|
||||
// // query += "'";
|
||||
// // if(indexI + 1 < keysList.size()) {
|
||||
// // query += " or ";
|
||||
// // }
|
||||
// // }
|
||||
// //
|
||||
// // queryInfo.setQuery(query);
|
||||
// //
|
||||
// // mappingInfo.setParseDirection("row");
|
||||
// // mappingInfo.setValueColumn("Value");
|
||||
// //
|
||||
// // List<String> keyColumns = new ArrayList<>();
|
||||
// // keyColumns.add("Variable_name");
|
||||
// //
|
||||
// // mappingInfo.setKeyColumns(keyColumns);
|
||||
// // }
|
||||
// // break;
|
||||
// // }
|
||||
// //
|
||||
// // }
|
||||
// }
|
||||
|
@ -1,26 +1,26 @@
|
||||
package com.loafle.overflow.central.module.generator.service;
|
||||
// package com.loafle.overflow.central.module.generator.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
// import org.springframework.beans.factory.annotation.Autowired;
|
||||
// import org.springframework.data.domain.Page;
|
||||
// import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
// import java.util.List;
|
||||
|
||||
import com.loafle.overflow.core.model.PageParams;
|
||||
import com.loafle.overflow.model.infra.Infra;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.sensor.SensorItem;
|
||||
import com.loafle.overflow.service.central.infra.InfraService;
|
||||
import com.loafle.overflow.service.central.sensor.SensorItemService;
|
||||
// import com.loafle.overflow.core.model.PageParams;
|
||||
// import com.loafle.overflow.model.infra.Infra;
|
||||
// import com.loafle.overflow.model.sensor.Sensor;
|
||||
// import com.loafle.overflow.model.sensor.SensorItem;
|
||||
// import com.loafle.overflow.service.central.infra.InfraService;
|
||||
// import com.loafle.overflow.service.central.sensor.SensorItemService;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 6.
|
||||
*/
|
||||
@Service("SensorConfigGenerator")
|
||||
public class SensorConfigGenerator {
|
||||
// /**
|
||||
// * Created by snoop on 17. 9. 6.
|
||||
// */
|
||||
// @Service("SensorConfigGenerator")
|
||||
// public class SensorConfigGenerator {
|
||||
|
||||
public String generate(Sensor sensor) throws Exception {
|
||||
return null;
|
||||
}
|
||||
// public String generate(Sensor sensor) throws Exception {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
@ -1,8 +1,6 @@
|
||||
package com.loafle.overflow.central.module.infra.dao;
|
||||
|
||||
import com.loafle.overflow.model.infra.Infra;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemType;
|
||||
import com.loafle.overflow.model.meta.MetaCollectionItem;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -8,5 +9,5 @@ import org.springframework.stereotype.Repository;
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorItemTypeDAO extends JpaRepository<MetaSensorItemType, Short> {
|
||||
public interface MetaCollectionItemDAO extends JpaRepository<MetaCollectionItem, Integer> {
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItem;
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItemCategory;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@ -8,5 +9,5 @@ import org.springframework.stereotype.Repository;
|
||||
* Created by insanity on 17. 6. 23.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorItemDAO extends JpaRepository<MetaSensorItem, Integer> {
|
||||
public interface MetaDisplayItemCategoryDAO extends JpaRepository<MetaDisplayItemCategory, Short> {
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemUnit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItem;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface MetaSensorItemUnitDAO extends JpaRepository<MetaSensorItemUnit, Short> {
|
||||
public interface MetaDisplayItemDAO extends JpaRepository<MetaDisplayItem, Long> {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItemMapping;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaDisplayItemMappingDAO extends JpaRepository<MetaDisplayItemMapping, Short> {
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaItemUnit;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Repository
|
||||
public interface MetaItemUnitDAO extends JpaRepository<MetaItemUnit, Short> {
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorDisplayItemDAO extends JpaRepository<MetaSensorDisplayItem, Long> {
|
||||
public List<MetaSensorDisplayItem> findAllByMetaCrawlerId(Short metaCrawlerId);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorDisplayMappingDAO extends JpaRepository<MetaSensorDisplayMapping, Short> {
|
||||
|
||||
@Query("SELECT m.metaSensorItemKey from MetaSensorDisplayMapping m where m.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
|
||||
public List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(
|
||||
@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 29.
|
||||
*/
|
||||
@Repository
|
||||
public interface MetaSensorItemKeyDAO extends JpaRepository<MetaSensorItemKey, Long> {
|
||||
List<MetaSensorItemKey> findAllByMetaCrawlerId(Short metaCrawlerId);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaCollectionItem;
|
||||
import com.loafle.overflow.service.central.meta.MetaCollectionItemService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
@Service("MetaCollectionItemService")
|
||||
public class CentralMetaCollectionItemService implements MetaCollectionItemService {
|
||||
|
||||
@Override
|
||||
public List<MetaCollectionItem> readAll() throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItemCategory;
|
||||
import com.loafle.overflow.service.central.meta.MetaDisplayItemCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
|
||||
@Service("MetaDisplayItemCategoryService")
|
||||
public class CentralMetaDisplayItemCategoryService implements MetaDisplayItemCategoryService {
|
||||
|
||||
@Override
|
||||
public List<MetaDisplayItemCategory> readAll() throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaDisplayItemCategory regist(MetaDisplayItemCategory metaDisplayItemCategory) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaDisplayItemCategory> registAll(List<MetaDisplayItemCategory> metaDisplayItemCategories)
|
||||
throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItemMapping;
|
||||
import com.loafle.overflow.service.central.meta.MetaDisplayItemMappingService;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Service("MetaDisplayItemMappingService")
|
||||
public class CentralMetaDisplayItemMappingService implements MetaDisplayItemMappingService {
|
||||
// @Autowired
|
||||
// private MetaSensorDisplayMappingDAO mappingDAO;
|
||||
|
||||
@Override
|
||||
public MetaDisplayItemMapping regist(MetaDisplayItemMapping metaDisplayItemMapping) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaDisplayItem;
|
||||
import com.loafle.overflow.service.central.meta.MetaDisplayItemService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Service("MetaDisplayItemService")
|
||||
public class CentralMetaDisplayItemService implements MetaDisplayItemService {
|
||||
// @Autowired
|
||||
// private MetaSensorDisplayItemDAO metaSensorDisplayItemDAO;
|
||||
|
||||
@Override
|
||||
public MetaDisplayItem regist(MetaDisplayItem metaDisplayItem) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaDisplayItem read(Long id) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaItemUnit;
|
||||
import com.loafle.overflow.service.central.meta.MetaItemUnitService;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Service("MetaSensorItemUnitService")
|
||||
public class CentralMetaItemUnitService implements MetaItemUnitService {
|
||||
|
||||
@Override
|
||||
public MetaItemUnit regist(MetaItemUnit metaItemUnit) throws OverflowException {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayItemDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorDisplayItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Service("MetaSensorDisplayItemService")
|
||||
public class CentralMetaSensorDisplayItemService implements MetaSensorDisplayItemService {
|
||||
@Autowired
|
||||
private MetaSensorDisplayItemDAO displayItemDAO;
|
||||
|
||||
public MetaSensorDisplayItem regist(MetaSensorDisplayItem item) throws OverflowException {
|
||||
return this.displayItemDAO.save(item);
|
||||
}
|
||||
|
||||
public MetaSensorDisplayItem read(Long id) throws OverflowException {
|
||||
return this.displayItemDAO.findById(id).get();
|
||||
}
|
||||
|
||||
public List<MetaSensorDisplayItem> readAllByCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||
return this.displayItemDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorDisplayMappingDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorDisplayMapping;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorDisplayMappingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 11. 7.
|
||||
*/
|
||||
@Service("MetaSensorDisplayMappingService")
|
||||
public class CentralMetaSensorDisplayMappingService implements MetaSensorDisplayMappingService {
|
||||
@Autowired
|
||||
private MetaSensorDisplayMappingDAO mappingDAO;
|
||||
|
||||
public MetaSensorDisplayMapping regist(MetaSensorDisplayMapping m) throws OverflowException {
|
||||
return this.mappingDAO.save(m);
|
||||
}
|
||||
|
||||
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByDisplayItemID(Long metaSensorDisplayItemID)
|
||||
throws OverflowException {
|
||||
return this.mappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemKeyDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 8. 29.
|
||||
*/
|
||||
|
||||
@Service("MetaSensorItemKeyService")
|
||||
public class CentralMetaSensorItemKeyService implements MetaSensorItemKeyService {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemKeyDAO metaSensorItemKeyDAO;
|
||||
|
||||
public List<MetaSensorItemKey> readAllByMetaCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||
return this.metaSensorItemKeyDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||
}
|
||||
|
||||
public Map<Integer, MetaSensorItemKey> readAllMapByMetaCrawlerID(Short metaCrawlerID) throws OverflowException {
|
||||
|
||||
Map<Integer, MetaSensorItemKey> resultMap = new HashMap<>();
|
||||
|
||||
List<MetaSensorItemKey> resultList = this.metaSensorItemKeyDAO.findAllByMetaCrawlerId(metaCrawlerID);
|
||||
|
||||
for (MetaSensorItemKey oa : resultList) {
|
||||
resultMap.put(oa.getMetaSensorItem().getId(), oa);
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItem;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorItemService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
@Service("MetaSensorItemService")
|
||||
public class CentralMetaSensorItemService implements MetaSensorItemService {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemDAO metaSensorItemDAO;
|
||||
|
||||
|
||||
public List<MetaSensorItem> readAll() throws OverflowException {
|
||||
return this.metaSensorItemDAO.findAll();
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemTypeDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemType;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorItemTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 7. 27.
|
||||
*/
|
||||
|
||||
@Service("MetaSensorItemTypeService")
|
||||
public class CentralMetaSensorItemTypeService implements MetaSensorItemTypeService {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorItemTypeDAO sensorItemTypeDAO;
|
||||
|
||||
public List<MetaSensorItemType> readAll() throws OverflowException {
|
||||
return this.sensorItemTypeDAO.findAll();
|
||||
}
|
||||
|
||||
public MetaSensorItemType regist(MetaSensorItemType type) throws OverflowException {
|
||||
return this.sensorItemTypeDAO.save(type);
|
||||
}
|
||||
|
||||
public List<MetaSensorItemType> registAll(List<MetaSensorItemType> list) throws OverflowException {
|
||||
return (List<MetaSensorItemType>) this.sensorItemTypeDAO.saveAll(list);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.service;
|
||||
|
||||
import com.loafle.overflow.central.module.meta.dao.MetaSensorItemUnitDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemUnit;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorItemUnitService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Service("MetaSensorItemUnitService")
|
||||
public class CentralMetaSensorItemUnitService implements MetaSensorItemUnitService {
|
||||
@Autowired
|
||||
private MetaSensorItemUnitDAO sensorItemUnitDAO;
|
||||
|
||||
public MetaSensorItemUnit regist(MetaSensorItemUnit sensorItemUnit) throws OverflowException {
|
||||
return this.sensorItemUnitDAO.save(sensorItemUnit);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.loafle.overflow.central.module.sensor.dao;
|
||||
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
@Repository
|
||||
public interface SensorItemDependencyDAO extends JpaRepository<SensorItemDependency, Long> {
|
||||
|
||||
@Query("SELECT s.metaSensorItemKey from SensorItemDependency s where s.metaSensorDisplayItem.id = :metaSensorDisplayItemId")
|
||||
List<MetaSensorItemKey> findAllMetaSensorItemKeyByMetaSensorDisplayItemId(
|
||||
@Param("metaSensorDisplayItemId") Long metaSensorDisplayItemId);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.loafle.overflow.central.module.sensor.service;
|
||||
|
||||
import com.loafle.overflow.central.module.sensor.dao.SensorItemDependencyDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.MetaSensorDisplayItem;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
import com.loafle.overflow.model.sensor.SensorItemDependency;
|
||||
|
||||
import com.loafle.overflow.service.central.sensor.SensorItemDependencyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by insanity on 17. 9. 20.
|
||||
*/
|
||||
|
||||
@Service("SensorItemDependencyService")
|
||||
public class CentralSensorItemDependencyService implements SensorItemDependencyService {
|
||||
|
||||
@Autowired
|
||||
private SensorItemDependencyDAO sensorItemDependencyDAO;
|
||||
|
||||
public SensorItemDependency regist(SensorItemDependency dependency) throws OverflowException {
|
||||
return this.sensorItemDependencyDAO.save(dependency);
|
||||
}
|
||||
|
||||
public List<MetaSensorItemKey> readAllMetaSensorItemKeyByMetaSensorDisplayItemID(Long metaSensorDisplayItemID)
|
||||
throws OverflowException {
|
||||
return this.sensorItemDependencyDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(metaSensorDisplayItemID);
|
||||
}
|
||||
|
||||
public Map<String, List<MetaSensorItemKey>> readAllMapByMetaSensorDisplayItems(
|
||||
List<MetaSensorDisplayItem> metaSensorDisplayItems) throws OverflowException {
|
||||
|
||||
Map<String, List<MetaSensorItemKey>> map = new HashMap<String, List<MetaSensorItemKey>>();
|
||||
|
||||
for (MetaSensorDisplayItem displayItem : metaSensorDisplayItems) {
|
||||
List<MetaSensorItemKey> itemKeys = this.sensorItemDependencyDAO
|
||||
.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(displayItem.getId());
|
||||
map.put(displayItem.getKey(), itemKeys);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.loafle.overflow.central.module.sensor.service;
|
||||
|
||||
import com.loafle.overflow.central.commons.utils.PageUtil;
|
||||
import com.loafle.overflow.central.module.generator.service.SensorConfigGenerator;
|
||||
import com.loafle.overflow.central.module.sensor.dao.SensorDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.core.model.PageParams;
|
||||
@ -30,9 +29,6 @@ public class CentralSensorService implements SensorService {
|
||||
@Autowired
|
||||
private SensorItemService sensorItemService;
|
||||
|
||||
@Autowired
|
||||
private SensorConfigGenerator sensorConfigGenerator;
|
||||
|
||||
@Autowired
|
||||
private TargetService targetService;
|
||||
|
||||
@ -103,11 +99,9 @@ public class CentralSensorService implements SensorService {
|
||||
return sensor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String generateSensorConfig(Sensor sensor) throws OverflowException {
|
||||
try {
|
||||
return this.sensorConfigGenerator.generate(sensor);
|
||||
} catch (Exception e) {
|
||||
throw new OverflowException("", new Throwable());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -8,13 +8,11 @@ import com.loafle.overflow.central.module.target.dao.TargetDAO;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.infra.Infra;
|
||||
import com.loafle.overflow.model.infra.InfraHost;
|
||||
import com.loafle.overflow.model.meta.MetaInfraType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetHostType;
|
||||
import com.loafle.overflow.model.meta.MetaTargetStatus;
|
||||
import com.loafle.overflow.model.probe.Probe;
|
||||
import com.loafle.overflow.model.target.Target;
|
||||
import com.loafle.overflow.service.central.infra.InfraService;
|
||||
import com.loafle.overflow.service.central.meta.MetaTargetServiceTypeService;
|
||||
import com.loafle.overflow.service.central.target.TargetService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -1,34 +0,0 @@
|
||||
package com.loafle.overflow.central.module.meta.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 14.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {AppConfigTest.class})
|
||||
public class MetaSensorDisplayMappingDAOTest {
|
||||
|
||||
@Autowired
|
||||
private MetaSensorDisplayMappingDAO metaSensorDisplayMappingDAO;
|
||||
|
||||
@Test
|
||||
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
|
||||
|
||||
List<MetaSensorItemKey> metaSensorItemKeys = this.metaSensorDisplayMappingDAO.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
|
||||
|
||||
assertNotNull(metaSensorItemKeys);
|
||||
}
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.loafle.overflow.central.module.sensor.dao;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.model.meta.MetaSensorItemKey;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* Created by snoop on 17. 9. 14.
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class SensorItemDependencyDAOTest {
|
||||
|
||||
@Autowired
|
||||
private SensorItemDependencyDAO sensorItemDependencyDAO;
|
||||
|
||||
@Test
|
||||
public void findAllMetaSensorItemKeyByMetaSensorDisplayItemId() throws Exception {
|
||||
|
||||
List<MetaSensorItemKey> metaSensorItemKeys = this.sensorItemDependencyDAO
|
||||
.findAllMetaSensorItemKeyByMetaSensorDisplayItemId(Long.valueOf(1));
|
||||
|
||||
assertNotNull(metaSensorItemKeys);
|
||||
}
|
||||
|
||||
}
|
@ -1,78 +1,14 @@
|
||||
package com.loafle.overflow.central.module.target.service;
|
||||
|
||||
import com.loafle.overflow.central.spring.AppConfigTest;
|
||||
import com.loafle.overflow.core.exception.OverflowException;
|
||||
import com.loafle.overflow.model.meta.*;
|
||||
import com.loafle.overflow.model.sensor.Sensor;
|
||||
import com.loafle.overflow.model.target.Target;
|
||||
import com.loafle.overflow.service.central.infra.InfraService;
|
||||
import com.loafle.overflow.service.central.meta.MetaCrawlerService;
|
||||
import com.loafle.overflow.service.central.meta.MetaSensorStatusService;
|
||||
import com.loafle.overflow.service.central.target.TargetService;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ActiveProfiles("test")
|
||||
@ContextConfiguration(classes = { AppConfigTest.class })
|
||||
public class CentralTargetServiceTest {
|
||||
|
||||
@Autowired
|
||||
TargetService targetService;
|
||||
|
||||
@Autowired
|
||||
InfraService infraService;
|
||||
|
||||
@Autowired
|
||||
MetaCrawlerService metaCrawlerService;
|
||||
|
||||
@Autowired
|
||||
MetaSensorStatusService metaSensorStatusService;
|
||||
|
||||
@Test
|
||||
public void regist() {
|
||||
}
|
||||
|
||||
// List<Target> targets, Long probeID
|
||||
@Test
|
||||
public void registAll() throws OverflowException {
|
||||
List<Target> targets = new ArrayList<>();
|
||||
List<Sensor> sensors = new ArrayList<>();
|
||||
|
||||
List<MetaCrawler> metaCrawlers = this.metaCrawlerService.readAll();
|
||||
List<MetaSensorStatus> metaSensorStatusList = this.metaSensorStatusService.readAll();
|
||||
// MetaSensorDisplayItem metaSensorDisplayItem =
|
||||
// this.metaSensorDisplayItemService.read(Long.valueOf(1));
|
||||
|
||||
Target target = new Target();
|
||||
target.setMetaTargetType(MetaTargetServiceType.Enum.UNKNOWN.to());
|
||||
target.setInfra(new com.loafle.overflow.model.infra.InfraService(Long.valueOf((long) 3)));
|
||||
|
||||
Sensor sensor = new Sensor();
|
||||
sensor.setItemCount(0);
|
||||
sensor.setCrawlerInputItems(null);
|
||||
sensor.setMetaCrawler(metaCrawlers.get(5));
|
||||
sensor.setName("Test Sensor");
|
||||
sensor.setTarget(target);
|
||||
sensor.setMetaSensorStatus(metaSensorStatusList.get(0));
|
||||
|
||||
sensors.add(sensor);
|
||||
|
||||
target.setSensors(sensors);
|
||||
|
||||
targets.add(target);
|
||||
// List<Target> targetList = this.targetService.registAll(targets,
|
||||
// Long.valueOf(1));
|
||||
|
||||
// System.out.println("Target List Size: " + targetList.size());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user