This commit is contained in:
insanity 2018-06-27 20:26:16 +09:00
parent f0c498c980
commit e92de9d97d
35 changed files with 774 additions and 1046 deletions

View File

@ -50,7 +50,7 @@
<dependency> <dependency>
<groupId>com.loafle.overflow</groupId> <groupId>com.loafle.overflow</groupId>
<artifactId>commons-java</artifactId> <artifactId>commons-java</artifactId>
<version>1.0.101-SNAPSHOT</version> <version>1.0.102-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -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.core.exception.OverflowException;
import com.loafle.overflow.model.meta.MetaCrawler; // import com.loafle.overflow.model.meta.MetaCrawler;
import com.loafle.overflow.model.meta.MetaSensorItemKey; // import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Crawler; // import com.loafle.overflow.model.sensorconfig.Crawler;
import com.loafle.overflow.model.sensorconfig.Keys; // import com.loafle.overflow.model.sensorconfig.Keys;
import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService; // import com.loafle.overflow.service.central.meta.MetaSensorItemKeyService;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.ArrayList; // import java.util.ArrayList;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("GenerateUtil") // @Service("GenerateUtil")
public class GenerateUtil { // public class GenerateUtil {
@Autowired // @Autowired
private MetaSensorItemKeyService metaSensorItemKeyService; // 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) { // if (this.mappingMap == null) {
this.mappingMap = new HashMap<>(); // 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) { // if (resultMap != null) {
return resultMap; // return resultMap;
} // }
resultMap = this.metaSensorItemKeyService.readAllMapByMetaCrawlerID(metaCrawler.getId()); // resultMap =
this.mappingMap.put(metaCrawler.getId(), 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 crawler = new Crawler();
crawler.setName(metaCrawler.getName()); // crawler.setName(metaCrawler.getName());
String container = ""; // String container = "";
// if (metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue() // // if (metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue() // // || metaCrawler.getId() == MetaCrawlerEnum.CASSANDRA_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue() // // || metaCrawler.getId() == MetaCrawlerEnum.MONGODB_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue() // // || metaCrawler.getId() == MetaCrawlerEnum.MSSQL_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue() // // || metaCrawler.getId() == MetaCrawlerEnum.ORACLE_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue() // // || metaCrawler.getId() == MetaCrawlerEnum.POSTGRESQL_CRAWLER.getValue()
// || metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) { // // || metaCrawler.getId() == MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
// container = "java_proxy"; // // container = "java_proxy";
// } else { // // } else {
// container = "network_proxy"; // // container = "network_proxy";
// } // // }
crawler.setContainer(container); // crawler.setContainer(container);
return crawler; // return crawler;
} // }
public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem> sensorItems, // public Map<String, List<MetaSensorItemKey>> sortItems(List<SensorItem>
Map<Integer, MetaSensorItemKey> keyMap) throws OverflowException { // 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) { // for (SensorItem sItem : sensorItems) {
itemKey = keyMap.get(sItem.getMetaSensorDisplayItem().getId()); // itemKey = keyMap.get(sItem.getMetaSensorDisplayItem().getId());
if (metricMap.containsKey(itemKey.getFroms()) == false) { // if (metricMap.containsKey(itemKey.getFroms()) == false) {
metricMap.put(itemKey.getFroms(), new ArrayList<>()); // metricMap.put(itemKey.getFroms(), new ArrayList<>());
} // }
metricMap.get(itemKey.getFroms()).add(itemKey); // metricMap.get(itemKey.getFroms()).add(itemKey);
} // }
return metricMap; // return metricMap;
} // }
public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException { // public Keys createKeys(MetaSensorItemKey itemKey) throws OverflowException {
Keys keys = new Keys(); // Keys keys = new Keys();
keys.setKey(itemKey.getKey()); // keys.setKey(itemKey.getKey());
keys.setMetric(itemKey.getMetaSensorItem().getKey()); // keys.setMetric(itemKey.getMetaSensorItem().getKey());
return keys; // return keys;
} // }
} // }

View File

@ -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.auth.AuthCrawler;
import com.loafle.overflow.model.infra.Infra; // import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.infra.InfraHost; // import com.loafle.overflow.model.infra.InfraHost;
import com.loafle.overflow.model.meta.MetaSensorItemKey; // import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Connection; // import com.loafle.overflow.model.sensorconfig.Connection;
import com.loafle.overflow.model.sensorconfig.Crawler; // import com.loafle.overflow.model.sensorconfig.Crawler;
import com.loafle.overflow.model.sensorconfig.Schedule; // import com.loafle.overflow.model.sensorconfig.Schedule;
import com.loafle.overflow.model.sensorconfig.SensorConfig; // import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.model.sensorconfig.Target; // import com.loafle.overflow.model.sensorconfig.Target;
import com.fasterxml.jackson.databind.ObjectMapper; // import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference; // import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("InfraHostGenerator") // @Service("InfraHostGenerator")
public class InfraHostGenerator { // public class InfraHostGenerator {
@Autowired // @Autowired
private GenerateUtil generateUtil; // private GenerateUtil generateUtil;
@Autowired // @Autowired
private InfraHostWMIGenerator infraHostWMIGenerator; // private InfraHostWMIGenerator infraHostWMIGenerator;
@Autowired // @Autowired
private ObjectMapper objectMapper; // 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 sensorConfig = new SensorConfig();
sensorConfig.setConfigID(String.valueOf(dbSensor.getId())); // sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
Target target = this.createTarget(infraHost, dbSensor); // Target target = this.createTarget(infraHost, dbSensor);
if (target == null) { // if (target == null) {
return null; // return null;
} // }
sensorConfig.setTarget(target); // sensorConfig.setTarget(target);
// FIXME: Interval // // FIXME: Interval
Schedule schedule = new Schedule(); // Schedule schedule = new Schedule();
schedule.setInterval("5"); // schedule.setInterval("5");
sensorConfig.setSchedule(schedule); // sensorConfig.setSchedule(schedule);
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler()); // Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
sensorConfig.setCrawler(crawler); // 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() == // // if (dbSensor.getMetaCrawler().getId() ==
// MetaCrawlerEnum.WMI_CRAWLER.getValue()) { // // MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
// this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor, // // this.infraHostWMIGenerator.process(sensorItems, keyMap, dbSensor,
// sensorConfig); // // 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 = // // AuthCrawler authCrawler =
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(), // //
// dbSensor.getTarget().getId()); // this.authCrawlerService.readByMetaCrawlerIDAndTargetID(dbSensor.getMetaCrawler().getId(),
// // dbSensor.getTarget().getId());
// if (authCrawler == null) { // // if (authCrawler == null) {
// return null; // // return null;
// } // // }
// Target target = new Target(); // // Target target = new Target();
// Connection connection = new Connection(); // // Connection connection = new Connection();
// // connection.setIp(infraHost.getIpv4()); // // // connection.setIp(infraHost.getIpv4());
// HashMap<String, String> optionMap = // // HashMap<String, String> optionMap =
// this.objectMapper.readValue(authCrawler.getAuthJson(), // // this.objectMapper.readValue(authCrawler.getAuthJson(),
// new TypeReference<Map<String, String>>() { // // new TypeReference<Map<String, String>>() {
// }); // // });
// if (dbSensor.getMetaCrawler().getId() == // // if (dbSensor.getMetaCrawler().getId() ==
// MetaCrawlerEnum.WMI_CRAWLER.getValue()) { // // MetaCrawlerEnum.WMI_CRAWLER.getValue()) {
// connection.setPort(135); // // connection.setPort(135);
// connection.setPortType(PortType.TCP); // // connection.setPortType(PortType.TCP);
// connection.setSsl(false); // // connection.setSsl(false);
// target.setConnection(connection); // // target.setConnection(connection);
// Map<String, Object> auth = new HashMap<>(); // // Map<String, Object> auth = new HashMap<>();
// auth.put("id", optionMap.get("ID")); // // auth.put("id", optionMap.get("ID"));
// auth.put("pw", optionMap.get("PassWord")); // // auth.put("pw", optionMap.get("PassWord"));
// target.setAuth(auth); // // target.setAuth(auth);
// } // // }
return null; // return null;
} // }
} // }

View File

@ -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.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Item; // import com.loafle.overflow.model.sensorconfig.Item;
import com.loafle.overflow.model.sensorconfig.Keys; // import com.loafle.overflow.model.sensorconfig.Keys;
import com.loafle.overflow.model.sensorconfig.MappingInfo; // import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; // import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; // import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.fasterxml.jackson.databind.ObjectMapper; // import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference; // import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.ArrayList; // import java.util.ArrayList;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("InfraHostWMIGenerator") // @Service("InfraHostWMIGenerator")
public class InfraHostWMIGenerator { // public class InfraHostWMIGenerator {
@Autowired // @Autowired
private GenerateUtil generateUtil; // private GenerateUtil generateUtil;
@Autowired // @Autowired
private ObjectMapper objectMapper; // private ObjectMapper objectMapper;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, // public void process(List<SensorItem> sensorItems, Map<Integer,
SensorConfig sensorConfig) throws Exception { // MetaSensorItemKey> keyMap, Sensor dbSensor,
// SensorConfig sensorConfig) throws Exception {
Map<String, List<MetaSensorItemKey>> metricMap = null; // Map<String, List<MetaSensorItemKey>> metricMap = null;
metricMap = this.generateUtil.sortItems(sensorItems, keyMap); // metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
// MetaSensorItemKey itemKey = null; // // MetaSensorItemKey itemKey = null;
// // //
// for(SensorItem sItem : sensorItems) { // // for(SensorItem sItem : sensorItems) {
// itemKey = keyMap.get(sItem.getItem().getId()); // // itemKey = keyMap.get(sItem.getItem().getId());
// if(metricMap.containsKey(itemKey.getFroms()) == false) { // // if(metricMap.containsKey(itemKey.getFroms()) == false) {
// metricMap.put(itemKey.getFroms(), new ArrayList<>()); // // metricMap.put(itemKey.getFroms(), new ArrayList<>());
// } // // }
// metricMap.get(itemKey.getFroms()).add(itemKey); // // metricMap.get(itemKey.getFroms()).add(itemKey);
// } // // }
List<Item> itemList = new ArrayList<>(); // List<Item> itemList = new ArrayList<>();
Item item = null; // Item item = null;
QueryInfo queryInfo = null; // QueryInfo queryInfo = null;
MappingInfo mappingInfo = null; // MappingInfo mappingInfo = null;
StringBuffer stringBuffer = new StringBuffer(); // StringBuffer stringBuffer = new StringBuffer();
Map<String, Object> extendMap = new HashMap<>(); // Map<String, Object> extendMap = new HashMap<>();
extendMap.put("nameSpace", "root/cimv2"); // extendMap.put("nameSpace", "root/cimv2");
extendMap.put("wmicPath", "/home/snoop/temp/wmic"); // extendMap.put("wmicPath", "/home/snoop/temp/wmic");
List<Keys> keysList = null; // List<Keys> keysList = null;
MetaSensorItemKey tempItemKey = null; // MetaSensorItemKey tempItemKey = null;
Keys keys = null; // Keys keys = null;
for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) { // for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet())
keysList = new ArrayList<>(); // {
item = new Item(); // keysList = new ArrayList<>();
stringBuffer.setLength(0); // 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); // tempItemKey = elems.getValue().get(indexI);
stringBuffer.append(tempItemKey.getKey()); // stringBuffer.append(tempItemKey.getKey());
if (indexI + 1 < elems.getValue().size()) { // if (indexI + 1 < elems.getValue().size()) {
stringBuffer.append(", "); // stringBuffer.append(", ");
} // }
// keys = new Keys(); // // keys = new Keys();
// keys.setKey(tempItemKey.getKey()); // // keys.setKey(tempItemKey.getKey());
// keys.setMetric(tempItemKey.getItem().getKey()); // // keys.setMetric(tempItemKey.getItem().getKey());
keysList.add(this.generateUtil.createKeys(tempItemKey)); // keysList.add(this.generateUtil.createKeys(tempItemKey));
} // }
List<String> arrayColumns = null; // List<String> arrayColumns = null;
String json = tempItemKey.getOption(); // String json = tempItemKey.getOption();
if (json != null && json.length() > 0) { // if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() { // HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
}); // TypeReference<Map<String, String>>() {
// });
Object obj = null; // Object obj = null;
obj = optionMap.get("appends"); // obj = optionMap.get("appends");
if (obj != null) { // if (obj != null) {
List<String> appendsList = (List<String>) obj; // List<String> appendsList = (List<String>) obj;
for (String append : appendsList) { // for (String append : appendsList) {
stringBuffer.append(", "); // stringBuffer.append(", ");
stringBuffer.append(append); // stringBuffer.append(append);
} // }
} // }
stringBuffer.append(" FROM "); // stringBuffer.append(" FROM ");
stringBuffer.append(elems.getKey()); // stringBuffer.append(elems.getKey());
obj = optionMap.get("where"); // obj = optionMap.get("where");
if (obj != null) { // if (obj != null) {
String where = (String) obj; // String where = (String) obj;
stringBuffer.append(" WHERE "); // stringBuffer.append(" WHERE ");
stringBuffer.append(where); // stringBuffer.append(where);
} // }
obj = optionMap.get("arrayColumns"); // obj = optionMap.get("arrayColumns");
if (obj != null) { // if (obj != null) {
arrayColumns = (List<String>) obj; // arrayColumns = (List<String>) obj;
} // }
} else { // } else {
stringBuffer.append(" FROM "); // stringBuffer.append(" FROM ");
stringBuffer.append(elems.getKey()); // stringBuffer.append(elems.getKey());
} // }
queryInfo = new QueryInfo(); // queryInfo = new QueryInfo();
queryInfo.setQuery(stringBuffer.toString()); // queryInfo.setQuery(stringBuffer.toString());
queryInfo.setExtend(extendMap); // queryInfo.setExtend(extendMap);
mappingInfo = new MappingInfo(); // mappingInfo = new MappingInfo();
mappingInfo.setParseDirection("col"); // mappingInfo.setParseDirection("col");
mappingInfo.setArrayColumns(arrayColumns); // mappingInfo.setArrayColumns(arrayColumns);
item.setMappingInfo(mappingInfo); // item.setMappingInfo(mappingInfo);
item.setQueryInfo(queryInfo); // item.setQueryInfo(queryInfo);
item.setKeys(keysList); // item.setKeys(keysList);
itemList.add(item); // itemList.add(item);
} // }
sensorConfig.setItems(itemList); // sensorConfig.setItems(itemList);
} // }
} // }

View File

@ -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.auth.AuthCrawler;
import com.loafle.overflow.model.infra.Infra; // import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.infra.InfraService; // import com.loafle.overflow.model.infra.InfraService;
import com.loafle.overflow.model.meta.MetaSensorItemKey; // import com.loafle.overflow.model.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Connection; // import com.loafle.overflow.model.sensorconfig.Connection;
import com.loafle.overflow.model.sensorconfig.Crawler; // import com.loafle.overflow.model.sensorconfig.Crawler;
import com.loafle.overflow.model.sensorconfig.Schedule; // import com.loafle.overflow.model.sensorconfig.Schedule;
import com.loafle.overflow.model.sensorconfig.SensorConfig; // import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.loafle.overflow.model.sensorconfig.Target; // import com.loafle.overflow.model.sensorconfig.Target;
import com.loafle.overflow.service.central.auth.AuthCrawlerService; // import com.loafle.overflow.service.central.auth.AuthCrawlerService;
import com.fasterxml.jackson.databind.ObjectMapper; // import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference; // import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("InfraServiceGenerator") // @Service("InfraServiceGenerator")
public class InfraServiceGenerator { // public class InfraServiceGenerator {
@Autowired // @Autowired
private GenerateUtil generateUtil; // private GenerateUtil generateUtil;
@Autowired // @Autowired
private InfraServiceMysqlGenerator infraServiceMysqlGenerator; // private InfraServiceMysqlGenerator infraServiceMysqlGenerator;
@Autowired // @Autowired
private InfraServiceJMXGenerator infraServiceJMXGenerator; // private InfraServiceJMXGenerator infraServiceJMXGenerator;
@Autowired // @Autowired
private ObjectMapper objectMapper; // private ObjectMapper objectMapper;
public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra infra) throws Exception { // public String process(Sensor dbSensor, List<SensorItem> sensorItems, Infra
com.loafle.overflow.model.infra.InfraService infraService = (com.loafle.overflow.model.infra.InfraService) infra; // infra) throws Exception {
// com.loafle.overflow.model.infra.InfraService infraService =
// (com.loafle.overflow.model.infra.InfraService) infra;
SensorConfig sensorConfig = new SensorConfig(); // SensorConfig sensorConfig = new SensorConfig();
sensorConfig.setConfigID(String.valueOf(dbSensor.getId())); // sensorConfig.setConfigID(String.valueOf(dbSensor.getId()));
Target target = this.createTarget(infraService, dbSensor); // Target target = this.createTarget(infraService, dbSensor);
if (target == null) { // if (target == null) {
return null; // return null;
} // }
sensorConfig.setTarget(target); // sensorConfig.setTarget(target);
// FIXME: Interval // // FIXME: Interval
Schedule schedule = new Schedule(); // Schedule schedule = new Schedule();
schedule.setInterval("5"); // schedule.setInterval("5");
sensorConfig.setSchedule(schedule); // sensorConfig.setSchedule(schedule);
Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler()); // Crawler crawler = this.generateUtil.getCrawler(dbSensor.getMetaCrawler());
sensorConfig.setCrawler(crawler); // 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() == // // if (dbSensor.getMetaCrawler().getId() ==
// MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) { // // MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
// this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor, // // this.infraServiceMysqlGenerator.process(sensorItems, keyMap, dbSensor,
// sensorConfig); // // sensorConfig);
// } else if (dbSensor.getMetaCrawler().getId() == // // } else if (dbSensor.getMetaCrawler().getId() ==
// MetaCrawlerEnum.JMX_CRAWLER.getValue()) { // // MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
// this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor, // // this.infraServiceJMXGenerator.process(sensorItems, keyMap, dbSensor,
// sensorConfig); // // 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 = // // AuthCrawler authCrawler =
// this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(), // //
// sensor.getTarget().getId()); // this.authCrawlerService.readByMetaCrawlerIDAndTargetID(sensor.getMetaCrawler().getId(),
// // sensor.getTarget().getId());
// if (authCrawler == null) { // // if (authCrawler == null) {
// return null; // // return null;
// } // // }
// Target target = new Target(); // // Target target = new Target();
// Connection connection = new Connection(); // // Connection connection = new Connection();
// // connection.setIp(infraService.getInfraHost().getIpv4()); // // // connection.setIp(infraService.getInfraHost().getIpv4());
// // connection.setPort(infraService.getPort()); // // // connection.setPort(infraService.getPort());
// // connection.setPortType(PortType.valueOf(infraService.getPortType())); // // // connection.setPortType(PortType.valueOf(infraService.getPortType()));
// // connection.setSsl(infraService.isTlsType()); // // // connection.setSsl(infraService.isTlsType());
// target.setConnection(connection); // // target.setConnection(connection);
// HashMap<String, String> optionMap = // // HashMap<String, String> optionMap =
// this.objectMapper.readValue(authCrawler.getAuthJson(), // // this.objectMapper.readValue(authCrawler.getAuthJson(),
// new TypeReference<Map<String, String>>() { // // new TypeReference<Map<String, String>>() {
// }); // // });
// Map<String, Object> auth = new HashMap<>(); // // Map<String, Object> auth = new HashMap<>();
// // if (sensor.getMetaCrawler().getId() == // // // if (sensor.getMetaCrawler().getId() ==
// MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) { // // MetaCrawlerEnum.MYSQL_CRAWLER.getValue()) {
// // auth.put("url", "jdbc:mysql://" + infraService.getInfraHost().getIpv4() + // // // auth.put("url", "jdbc:mysql://" + infraService.getInfraHost().getIpv4()
// ":" + infraService.getPort()); // +
// // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info // // ":" + infraService.getPort());
// // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info // // // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
// // } else if (sensor.getMetaCrawler().getId() == // // // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
// MetaCrawlerEnum.JMX_CRAWLER.getValue()) { // // // } else if (sensor.getMetaCrawler().getId() ==
// // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info // // MetaCrawlerEnum.JMX_CRAWLER.getValue()) {
// // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info // // // auth.put("id", optionMap.get("ID")); // FIXME: Auth Info
// // connection.setPort(9840); // // // auth.put("pw", optionMap.get("PassWord")); // FIXME: Auth Info
// // } // // // connection.setPort(9840);
// // // }
// target.setAuth(auth); // // target.setAuth(auth);
// return target; // // return target;
return null; // return null;
} // }
} // }

View File

@ -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.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Item; // import com.loafle.overflow.model.sensorconfig.Item;
import com.loafle.overflow.model.sensorconfig.Keys; // import com.loafle.overflow.model.sensorconfig.Keys;
import com.loafle.overflow.model.sensorconfig.MappingInfo; // import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; // import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; // import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.fasterxml.jackson.databind.ObjectMapper; // import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference; // import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.ArrayList; // import java.util.ArrayList;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by geek on 17. 9. 11. // * Created by geek on 17. 9. 11.
*/ // */
@Service("InfraServiceJMXGenerator") // @Service("InfraServiceJMXGenerator")
public class InfraServiceJMXGenerator { // public class InfraServiceJMXGenerator {
@Autowired // @Autowired
private GenerateUtil generateUtil; // private GenerateUtil generateUtil;
@Autowired // @Autowired
private ObjectMapper objectMapper; // private ObjectMapper objectMapper;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, // public void process(List<SensorItem> sensorItems, Map<Integer,
SensorConfig sensorConfig) throws Exception { // MetaSensorItemKey> keyMap, Sensor dbSensor,
Map<String, List<MetaSensorItemKey>> metricMap = null; // SensorConfig sensorConfig) throws Exception {
metricMap = this.generateUtil.sortItems(sensorItems, keyMap); // Map<String, List<MetaSensorItemKey>> metricMap = null;
// metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
List<Item> itemList = new ArrayList<>(); // List<Item> itemList = new ArrayList<>();
Item item = null; // Item item = null;
QueryInfo queryInfo = null; // QueryInfo queryInfo = null;
MappingInfo mappingInfo = 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; // List<Keys> keysList = null;
MetaSensorItemKey tempItemKey = null; // MetaSensorItemKey tempItemKey = null;
Keys keys = null; // Keys keys = null;
for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet()) { // for (Map.Entry<String, List<MetaSensorItemKey>> elms : metricMap.entrySet())
keysList = new ArrayList<>(); // {
item = new Item(); // keysList = new ArrayList<>();
buffer.setLength(0); // item = new Item();
// buffer.setLength(0);
buffer.append(elms.getKey()); // buffer.append(elms.getKey());
for (int idx = 0; idx < elms.getValue().size(); idx++) { // for (int idx = 0; idx < elms.getValue().size(); idx++) {
tempItemKey = elms.getValue().get(idx); // tempItemKey = elms.getValue().get(idx);
buffer.append(tempItemKey.getKey()); // buffer.append(tempItemKey.getKey());
keys = new Keys(); // keys = new Keys();
keys.setKey(tempItemKey.getKey()); // keys.setKey(tempItemKey.getKey());
keys.setMetric(tempItemKey.getMetaSensorItem().getKey()); // keys.setMetric(tempItemKey.getMetaSensorItem().getKey());
keysList.add(this.generateUtil.createKeys(tempItemKey)); // keysList.add(this.generateUtil.createKeys(tempItemKey));
} // }
String json = tempItemKey.getOption(); // String json = tempItemKey.getOption();
List<String> aliases = null; // List<String> aliases = null;
List<String> arrayCol = null; // List<String> arrayCol = null;
if (json != null && json.length() > 0) { // if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() { // HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
}); // TypeReference<Map<String, String>>() {
// });
Object obj = null; // Object obj = null;
obj = optionMap.get("aliases"); // obj = optionMap.get("aliases");
if (obj != null) { // if (obj != null) {
aliases = (List<String>) obj; // aliases = (List<String>) obj;
} // }
obj = optionMap.get("arrayColumns"); // obj = optionMap.get("arrayColumns");
if (obj != null) { // if (obj != null) {
arrayCol = (List<String>) obj; // arrayCol = (List<String>) obj;
} // }
} // }
queryInfo = new QueryInfo(); // queryInfo = new QueryInfo();
queryInfo.setQuery(tempItemKey.getFroms()); // queryInfo.setQuery(tempItemKey.getFroms());
queryInfo.setExtend(extendMap); // queryInfo.setExtend(extendMap);
extendMap.put("aliases", aliases); // extendMap.put("aliases", aliases);
mappingInfo = new MappingInfo(); // mappingInfo = new MappingInfo();
mappingInfo.setArrayColumns(arrayCol); // mappingInfo.setArrayColumns(arrayCol);
item.setMappingInfo(mappingInfo); // item.setMappingInfo(mappingInfo);
item.setQueryInfo(queryInfo); // item.setQueryInfo(queryInfo);
item.setKeys(keysList); // item.setKeys(keysList);
itemList.add(item); // itemList.add(item);
} // }
sensorConfig.setItems(itemList); // sensorConfig.setItems(itemList);
} // }
} // }

View File

@ -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.meta.MetaSensorItemKey;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.model.sensorconfig.Item; // import com.loafle.overflow.model.sensorconfig.Item;
import com.loafle.overflow.model.sensorconfig.Keys; // import com.loafle.overflow.model.sensorconfig.Keys;
import com.loafle.overflow.model.sensorconfig.MappingInfo; // import com.loafle.overflow.model.sensorconfig.MappingInfo;
import com.loafle.overflow.model.sensorconfig.QueryInfo; // import com.loafle.overflow.model.sensorconfig.QueryInfo;
import com.loafle.overflow.model.sensorconfig.SensorConfig; // import com.loafle.overflow.model.sensorconfig.SensorConfig;
import com.fasterxml.jackson.databind.ObjectMapper; // import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference; // import com.fasterxml.jackson.core.type.TypeReference;
import org.springframework.beans.factory.annotation.Autowired; // import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.ArrayList; // import java.util.ArrayList;
import java.util.HashMap; // import java.util.HashMap;
import java.util.List; // import java.util.List;
import java.util.Map; // import java.util.Map;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("InfraServiceMysqlGenerator") // @Service("InfraServiceMysqlGenerator")
public class InfraServiceMysqlGenerator { // public class InfraServiceMysqlGenerator {
@Autowired // @Autowired
private GenerateUtil generateUtil; // private GenerateUtil generateUtil;
@Autowired // @Autowired
private ObjectMapper objectMapper; // private ObjectMapper objectMapper;
public void process(List<SensorItem> sensorItems, Map<Integer, MetaSensorItemKey> keyMap, Sensor dbSensor, // public void process(List<SensorItem> sensorItems, Map<Integer,
SensorConfig sensorConfig) throws Exception { // MetaSensorItemKey> keyMap, Sensor dbSensor,
// SensorConfig sensorConfig) throws Exception {
// List<Keys> keysList = new ArrayList<>(); // // List<Keys> keysList = new ArrayList<>();
// for(SensorItem sItem : sensorItems) { // // for(SensorItem sItem : sensorItems) {
// keys = new Keys(); // // keys = new Keys();
// keys.setMetric(sItem.getItem().getKey()); // // keys.setMetric(sItem.getItem().getKey());
// keys.setKey(KeyMap.get(sItem.getItem().getId()).getKey()); // // keys.setKey(KeyMap.get(sItem.getItem().getId()).getKey());
// keysList.add(keys); // // keysList.add(keys);
// } // // }
// item.setKeys(keysList); // // item.setKeys(keysList);
Map<String, List<MetaSensorItemKey>> metricMap = null; // Map<String, List<MetaSensorItemKey>> metricMap = null;
metricMap = this.generateUtil.sortItems(sensorItems, keyMap); // metricMap = this.generateUtil.sortItems(sensorItems, keyMap);
List<Item> itemList = new ArrayList<>(); // List<Item> itemList = new ArrayList<>();
QueryInfo queryInfo = null; // QueryInfo queryInfo = null;
MappingInfo mappingInfo = null; // MappingInfo mappingInfo = null;
List<Keys> keysList = null; // List<Keys> keysList = null;
MetaSensorItemKey tempItemKey = null; // MetaSensorItemKey tempItemKey = null;
Keys keys = null; // Keys keys = null;
Item item = null; // Item item = null;
StringBuffer stringBuffer = new StringBuffer(); // StringBuffer stringBuffer = new StringBuffer();
for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet()) { // for (Map.Entry<String, List<MetaSensorItemKey>> elems : metricMap.entrySet())
// {
keysList = new ArrayList<>(); // keysList = new ArrayList<>();
item = new Item(); // item = new Item();
stringBuffer.setLength(0); // stringBuffer.setLength(0);
stringBuffer.append(elems.getKey()); // stringBuffer.append(elems.getKey());
stringBuffer.append(" where "); // stringBuffer.append(" where ");
for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) { // for (int indexI = 0; indexI < elems.getValue().size(); ++indexI) {
tempItemKey = elems.getValue().get(indexI); // tempItemKey = elems.getValue().get(indexI);
stringBuffer.append("variable_name = '"); // stringBuffer.append("variable_name = '");
stringBuffer.append(tempItemKey.getKey()); // stringBuffer.append(tempItemKey.getKey());
stringBuffer.append("'"); // stringBuffer.append("'");
if (indexI + 1 < elems.getValue().size()) { // if (indexI + 1 < elems.getValue().size()) {
stringBuffer.append(" or "); // stringBuffer.append(" or ");
} // }
keysList.add(this.generateUtil.createKeys(tempItemKey)); // keysList.add(this.generateUtil.createKeys(tempItemKey));
} // }
List<String> keyColumns = null; // List<String> keyColumns = null;
String valueColumn = null; // String valueColumn = null;
String json = tempItemKey.getOption(); // String json = tempItemKey.getOption();
if (json != null && json.length() > 0) { // if (json != null && json.length() > 0) {
HashMap<String, String> optionMap = this.objectMapper.readValue(json, new TypeReference<Map<String, String>>() { // HashMap<String, String> optionMap = this.objectMapper.readValue(json, new
}); // TypeReference<Map<String, String>>() {
// });
Object obj = null; // Object obj = null;
obj = optionMap.get("valueColumn"); // obj = optionMap.get("valueColumn");
if (obj != null) { // if (obj != null) {
valueColumn = (String) obj; // valueColumn = (String) obj;
} // }
obj = optionMap.get("keyColumns"); // obj = optionMap.get("keyColumns");
if (obj != null) { // if (obj != null) {
keyColumns = (List<String>) obj; // keyColumns = (List<String>) obj;
} // }
} // }
queryInfo = new QueryInfo(); // queryInfo = new QueryInfo();
queryInfo.setQuery(stringBuffer.toString()); // queryInfo.setQuery(stringBuffer.toString());
mappingInfo = new MappingInfo(); // mappingInfo = new MappingInfo();
mappingInfo.setParseDirection("row"); // mappingInfo.setParseDirection("row");
mappingInfo.setValueColumn(valueColumn); // mappingInfo.setValueColumn(valueColumn);
mappingInfo.setKeyColumns(keyColumns); // mappingInfo.setKeyColumns(keyColumns);
item.setMappingInfo(mappingInfo); // item.setMappingInfo(mappingInfo);
item.setQueryInfo(queryInfo); // item.setQueryInfo(queryInfo);
item.setKeys(keysList); // item.setKeys(keysList);
itemList.add(item); // itemList.add(item);
} // }
sensorConfig.setItems(itemList); // sensorConfig.setItems(itemList);
// ObjectMapper objectMapper = new ObjectMapper(); // // ObjectMapper objectMapper = new ObjectMapper();
// // //
// return objectMapper.writeValueAsString(config); // // return objectMapper.writeValueAsString(config);
} // }
// public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys> keysList, // // public void setQueryAndMapping(MetaCrawler metaCrawler, List<Keys>
// QueryInfo queryInfo, MappingInfo mappingInfo) { // keysList,
// // // QueryInfo queryInfo, MappingInfo mappingInfo) {
// switch (metaCrawler.getId()) { // //
// case 11: // mysql // // switch (metaCrawler.getId()) {
// { // // case 11: // mysql
// String query = "show status where "; // // {
//// queryInfo.setQuery("show status where "); // // String query = "show status where ";
// // //// queryInfo.setQuery("show status where ");
// Keys keys = null; // //
// for(int indexI = 0 ; indexI < keysList.size(); ++indexI) { // // Keys keys = null;
// keys = keysList.get(indexI); // // for(int indexI = 0 ; indexI < keysList.size(); ++indexI) {
// query += "variable_name = '"; // // keys = keysList.get(indexI);
// query += keys.getKey(); // // query += "variable_name = '";
// query += "'"; // // query += keys.getKey();
// if(indexI + 1 < keysList.size()) { // // query += "'";
// query += " or "; // // if(indexI + 1 < keysList.size()) {
// } // // query += " or ";
// } // // }
// // // }
// queryInfo.setQuery(query); // //
// // // queryInfo.setQuery(query);
// mappingInfo.setParseDirection("row"); // //
// mappingInfo.setValueColumn("Value"); // // mappingInfo.setParseDirection("row");
// // // mappingInfo.setValueColumn("Value");
// List<String> keyColumns = new ArrayList<>(); // //
// keyColumns.add("Variable_name"); // // List<String> keyColumns = new ArrayList<>();
// // // keyColumns.add("Variable_name");
// mappingInfo.setKeyColumns(keyColumns); // //
// } // // mappingInfo.setKeyColumns(keyColumns);
// break; // // }
// } // // break;
// // // }
// } // //
} // // }
// }

View File

@ -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.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; // import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service; // import org.springframework.stereotype.Service;
import java.util.List; // import java.util.List;
import com.loafle.overflow.core.model.PageParams; // import com.loafle.overflow.core.model.PageParams;
import com.loafle.overflow.model.infra.Infra; // import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.sensor.Sensor; // import com.loafle.overflow.model.sensor.Sensor;
import com.loafle.overflow.model.sensor.SensorItem; // import com.loafle.overflow.model.sensor.SensorItem;
import com.loafle.overflow.service.central.infra.InfraService; // import com.loafle.overflow.service.central.infra.InfraService;
import com.loafle.overflow.service.central.sensor.SensorItemService; // import com.loafle.overflow.service.central.sensor.SensorItemService;
/** // /**
* Created by snoop on 17. 9. 6. // * Created by snoop on 17. 9. 6.
*/ // */
@Service("SensorConfigGenerator") // @Service("SensorConfigGenerator")
public class SensorConfigGenerator { // public class SensorConfigGenerator {
public String generate(Sensor sensor) throws Exception { // public String generate(Sensor sensor) throws Exception {
return null; // return null;
} // }
} // }

View File

@ -1,8 +1,6 @@
package com.loafle.overflow.central.module.infra.dao; package com.loafle.overflow.central.module.infra.dao;
import com.loafle.overflow.model.infra.Infra; 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.central.module.meta.dao; 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -8,5 +9,5 @@ import org.springframework.stereotype.Repository;
* Created by insanity on 17. 6. 23. * Created by insanity on 17. 6. 23.
*/ */
@Repository @Repository
public interface MetaSensorItemTypeDAO extends JpaRepository<MetaSensorItemType, Short> { public interface MetaCollectionItemDAO extends JpaRepository<MetaCollectionItem, Integer> {
} }

View File

@ -1,6 +1,7 @@
package com.loafle.overflow.central.module.meta.dao; 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -8,5 +9,5 @@ import org.springframework.stereotype.Repository;
* Created by insanity on 17. 6. 23. * Created by insanity on 17. 6. 23.
*/ */
@Repository @Repository
public interface MetaSensorItemDAO extends JpaRepository<MetaSensorItem, Integer> { public interface MetaDisplayItemCategoryDAO extends JpaRepository<MetaDisplayItemCategory, Short> {
} }

View File

@ -1,13 +1,13 @@
package com.loafle.overflow.central.module.meta.dao; 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.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.loafle.overflow.model.meta.MetaDisplayItem;
/** /**
* Created by insanity on 17. 9. 20. * Created by insanity on 17. 9. 20.
*/ */
@Repository @Repository
public interface MetaSensorItemUnitDAO extends JpaRepository<MetaSensorItemUnit, Short> { public interface MetaDisplayItemDAO extends JpaRepository<MetaDisplayItem, Long> {
} }

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -1,7 +1,6 @@
package com.loafle.overflow.central.module.sensor.service; package com.loafle.overflow.central.module.sensor.service;
import com.loafle.overflow.central.commons.utils.PageUtil; 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.central.module.sensor.dao.SensorDAO;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.core.model.PageParams; import com.loafle.overflow.core.model.PageParams;
@ -30,9 +29,6 @@ public class CentralSensorService implements SensorService {
@Autowired @Autowired
private SensorItemService sensorItemService; private SensorItemService sensorItemService;
@Autowired
private SensorConfigGenerator sensorConfigGenerator;
@Autowired @Autowired
private TargetService targetService; private TargetService targetService;
@ -103,11 +99,9 @@ public class CentralSensorService implements SensorService {
return sensor; return sensor;
} }
@Override
public String generateSensorConfig(Sensor sensor) throws OverflowException { public String generateSensorConfig(Sensor sensor) throws OverflowException {
try { return null;
return this.sensorConfigGenerator.generate(sensor);
} catch (Exception e) {
throw new OverflowException("", new Throwable());
}
} }
} }

View File

@ -8,13 +8,11 @@ import com.loafle.overflow.central.module.target.dao.TargetDAO;
import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.core.exception.OverflowException;
import com.loafle.overflow.model.infra.Infra; import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.infra.InfraHost; 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.MetaTargetHostType;
import com.loafle.overflow.model.meta.MetaTargetStatus; import com.loafle.overflow.model.meta.MetaTargetStatus;
import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.probe.Probe;
import com.loafle.overflow.model.target.Target; import com.loafle.overflow.model.target.Target;
import com.loafle.overflow.service.central.infra.InfraService; 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 com.loafle.overflow.service.central.target.TargetService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -1,78 +1,14 @@
package com.loafle.overflow.central.module.target.service; package com.loafle.overflow.central.module.target.service;
import com.loafle.overflow.central.spring.AppConfigTest; 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.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ActiveProfiles("test") @ActiveProfiles("test")
@ContextConfiguration(classes = { AppConfigTest.class }) @ContextConfiguration(classes = { AppConfigTest.class })
public class CentralTargetServiceTest { 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());
}
} }