diff --git a/pom.xml b/pom.xml index 339ed56..b60145e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.loafle.overflow commons-java jar - 1.0.118-SNAPSHOT + 1.0.119-SNAPSHOT com.loafle.overflow.commons-java diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfig.java b/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfig.java index a074c3b..babafef 100644 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfig.java +++ b/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfig.java @@ -1,5 +1,9 @@ package com.loafle.overflow.model.sensorconfig; +import java.util.List; + +import com.loafle.overflow.model.meta.MetaCollectionItem; + public class SensorConfig { private Long sensorID; @@ -7,7 +11,8 @@ public class SensorConfig { private SensorConfigSchedule schedule; private SensorConfigCrawler crawler; private SensorConfigConnection connection; - private SensorConfigItems items; + + private List metaCollectionItems; public Long getSensorID() { return sensorID; @@ -41,11 +46,12 @@ public class SensorConfig { this.connection = connection; } - public SensorConfigItems getItems() { - return items; + public List getMetaCollectionItems() { + return metaCollectionItems; } - public void setItems(SensorConfigItems items) { - this.items = items; + public void setMetaCollectionItems(List metaCollectionItems) { + this.metaCollectionItems = metaCollectionItems; } + } diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfigItems.java b/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfigItems.java deleted file mode 100644 index 215be58..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/SensorConfigItems.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.loafle.overflow.model.sensorconfig; - -import java.util.List; - -import com.loafle.overflow.model.meta.MetaCollectionItem; - -public class SensorConfigItems { - private List metaCollectionItems; - - public List getMetaCollectionItems() { - return metaCollectionItems; - } - - public void setMetaCollectionItems(List metaCollectionItems) { - this.metaCollectionItems = metaCollectionItems; - } -} diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Connection.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Connection.java deleted file mode 100644 index 8b30581..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Connection.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import com.loafle.overflow.model.meta.MetaCryptoType; -import com.loafle.overflow.model.meta.MetaIPType; -import com.loafle.overflow.model.meta.MetaPortType; - -/** - * Connection - */ -public class Connection { - private MetaIPType metaIPType; - private String ip; - private MetaPortType metaPortType; - private Integer port; - private MetaCryptoType metaCryptoType; - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - /** - * @return the metaPortType - */ - public MetaPortType getMetaPortType() { - return metaPortType; - } - - /** - * @param metaPortType the metaPortType to set - */ - public void setMetaPortType(MetaPortType metaPortType) { - this.metaPortType = metaPortType; - } - - /** - * @return the metaIPType - */ - public MetaIPType getMetaIPType() { - return metaIPType; - } - - /** - * @param metaIPType the metaIPType to set - */ - public void setMetaIPType(MetaIPType metaIPType) { - this.metaIPType = metaIPType; - } - - /** - * @return the metaCryptoType - */ - public MetaCryptoType getMetaCryptoType() { - return metaCryptoType; - } - - /** - * @param metaCryptoType the metaCryptoType to set - */ - public void setMetaCryptoType(MetaCryptoType metaCryptoType) { - this.metaCryptoType = metaCryptoType; - } -} diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Crawler.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Crawler.java deleted file mode 100644 index 2a635eb..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Crawler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -/** - * Crawler - */ -public class Crawler { - private String name; - private String container; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getContainer() { - return container; - } - - public void setContainer(String container) { - this.container = container; - } -} diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Item.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Item.java deleted file mode 100644 index 866ab3f..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Item.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.List; - -/** - * Item - */ -public class Item { - private List keys; - private QueryInfo queryInfo; - private MappingInfo mappingInfo; - - public List getKeys() { - return keys; - } - - public void setKeys(List keys) { - this.keys = keys; - } - - public QueryInfo getQueryInfo() { - return queryInfo; - } - - public void setQueryInfo(QueryInfo queryInfo) { - this.queryInfo = queryInfo; - } - - public MappingInfo getMappingInfo() { - return mappingInfo; - } - - public void setMappingInfo(MappingInfo mappingInfo) { - this.mappingInfo = mappingInfo; - } - -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Keys.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Keys.java deleted file mode 100644 index 402ebb1..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Keys.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.HashMap; -import java.util.Map; - -/** - * Keys - */ -public class Keys { - private String metric; - private String key; - - public String getMetric() { - return metric; - } - - public void setMetric(String metric) { - this.metric = metric; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public static Map keysToMap(Keys[] keys) { - Map map = new HashMap<>(); - for (Keys k : keys) { - map.put(k.key, k.metric); - } - return map; - } -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/MappingInfo.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/MappingInfo.java deleted file mode 100644 index 001db13..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/MappingInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.List; - -/** - * MappingInfo - */ -public class MappingInfo { - private String parseDirection; - private List arrayColumns; - private List keyColumns; - private String valueColumn; - - public String getParseDirection() { - return parseDirection; - } - - public void setParseDirection(String parseDirection) { - this.parseDirection = parseDirection; - } - - public List getArrayColumns() { - return arrayColumns; - } - - public void setArrayColumns(List arrayColumns) { - this.arrayColumns = arrayColumns; - } - - public List getKeyColumns() { - return keyColumns; - } - - public void setKeyColumns(List keyColumns) { - this.keyColumns = keyColumns; - } - - public String getValueColumn() { - return valueColumn; - } - - public void setValueColumn(String valueColumn) { - this.valueColumn = valueColumn; - } -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/QueryInfo.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/QueryInfo.java deleted file mode 100644 index 83dae00..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/QueryInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.Map; - -/** - * QueryInfo - */ -public class QueryInfo { - private String query; - private Map extend; - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } - - public Map getExtend() { - return extend; - } - - public void setExtend(Map extend) { - this.extend = extend; - } -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSet.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSet.java deleted file mode 100644 index 36e406c..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSet.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * ResultSet - */ -public abstract class ResultSet { - protected Item item; - protected List> rows; - protected Map meta; - - // methods - public static ResultSet newInstance(Item item) { - if (item.getMappingInfo() == null) { - item.setMappingInfo(new MappingInfo()); - } - String type = (String) item.getMappingInfo().getParseDirection(); - if (type != null && type.equals("row")) { - return new ResultSetRow(item); - } else { - return new ResultSetCol(item); - } - } - - public ResultSet(Item item) { - this.item = item; - this.rows = new ArrayList<>(); - this.setMeta(); - } - - public void addRow(List row) { - rows.add(row); - } - - public List> getRows() { - return rows; - } - - public void setRows(List> rows) { - this.rows = rows; - } - - public Map getMeta() { - return meta; - } - - public void setMeta(Map meta) { - this.meta = meta; - } - - public Item getItem() { - return item; - } - - public void setItem(Item item) { - this.item = item; - } - - public Map getData() { - return parse(); - } - - // abstracts - public abstract void setMeta(); - - public abstract Map parse(); - -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetCol.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetCol.java deleted file mode 100644 index 687d510..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetCol.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * ResultSetCol - */ -public class ResultSetCol extends ResultSet { - - public ResultSetCol(Item item) { - super(item); - } - - public void setMeta() { - List meta = this.item.getKeys(); - List arrayColumns = this.item.getMappingInfo().getArrayColumns(); - - if (this.meta == null) { - this.meta = new HashMap<>(); - } - - for (int indexI = 0; indexI < meta.size(); ++indexI) { - this.meta.put(meta.get(indexI).getKey(), indexI); - } - - if (arrayColumns != null) { - for (int indexI = 0; indexI < arrayColumns.size(); ++indexI) { - if (this.meta.containsKey(arrayColumns.get(indexI))) { - continue; - } - this.meta.put(arrayColumns.get(indexI), indexI + meta.size()); - } - } - - } - - public Map parse() { - - List metrics = this.item.getKeys(); - List arrayColumns = this.item.getMappingInfo().getArrayColumns(); - - Map resultMap = new HashMap<>(); - - List row = null; - - String metric = null; - List arrayValue = new ArrayList<>(); - - int columnIdx = 0; - - for (int indexI = 0; indexI < this.rows.size(); ++indexI) { - - row = this.rows.get(indexI); - for (int indexJ = 0; indexJ < row.size(); ++indexJ) { - - arrayValue.clear(); - - if (arrayColumns != null) { - for (int indexL = 0; indexL < arrayColumns.size(); ++indexL) { - columnIdx = this.meta.get(arrayColumns.get(indexL)); - - arrayValue.add(row.get(columnIdx)); - } - } - - for (int indexK = 0; indexK < metrics.size(); ++indexK) { - metric = metrics.get(indexK).getMetric(); - metric = convertMetric(metric, arrayValue); - resultMap.put(metric, row.get(indexK)); - } - - } - - } - - return resultMap; - - } - - private String convertMetric(String metric, List arrayValue) { - - if (arrayValue == null || arrayValue.size() <= 0) { - return metric; - } - - String convertChar = "$"; - String convertStr = null; - - for (int indexI = 0; indexI < arrayValue.size(); ++indexI) { - - convertStr = convertChar + String.valueOf(indexI); - - metric = metric.replace(convertStr, arrayValue.get(indexI)); - - } - - return metric; - } -} diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetRow.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetRow.java deleted file mode 100644 index 4449fee..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/ResultSetRow.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * ResultSetRow - */ -public class ResultSetRow extends ResultSet { - - public ResultSetRow(Item item) { - super(item); - } - - public void setMeta() { - - List meta = new ArrayList<>(); - - List arrayColumns = (List) this.item.getMappingInfo().getArrayColumns(); - List keyColumns = (List) this.item.getMappingInfo().getKeyColumns(); - String valueColumn = (String) this.item.getMappingInfo().getValueColumn(); - if (arrayColumns != null) { - for (String c : arrayColumns) { - meta.add(c); - } - } - - if (keyColumns != null) { - for (String c : keyColumns) { - meta.add(c); - } - } - - if (valueColumn != null && !valueColumn.equals("")) - meta.add(valueColumn); - - if (this.meta == null) { - this.meta = new HashMap<>(); - } - - for (int indexI = 0; indexI < meta.size(); ++indexI) { - this.meta.put(meta.get(indexI), indexI); - } - - } - - public Map parse() { - - Map returnMap = new HashMap<>(); - - String valueColumn = (String) this.item.getMappingInfo().getValueColumn(); - - for (List row : this.rows) { - String key = makeKey(row); - if (key == null) - continue; - returnMap.put(key, row.get(this.meta.get(valueColumn))); - } - - return returnMap; - } - - private String makeKey(List data) { - - List metrics = this.item.getKeys(); - - List arrayColumns = (List) this.item.getMappingInfo().getArrayColumns(); - List keyColumns = (List) this.item.getMappingInfo().getKeyColumns(); - List keys = this.item.getKeys(); - - boolean find = false; - int findIndex = -1; - for (String keyColumn : keyColumns) { - String row = data.get(this.meta.get(keyColumn)); - for (int i = 0; i < keys.size(); ++i) { - if (row.equals(keys.get(i).getKey())) { - findIndex = i; - find = true; - break; - } - } - if (find == true) { - break; - } - } - - if (findIndex < 0) { - return null; - } - - String metric = metrics.get(findIndex).getMetric(); - - if (arrayColumns != null) { - for (int i = 0; i < arrayColumns.size(); ++i) { - // replace - String k = "$" + i; - int dataIndex = this.meta.get(arrayColumns.get(i)); - String replaceString = data.get(dataIndex); - metric = metric.replace(k, "'" + replaceString + "'"); - } - } - return metric; - } - -} diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Schedule.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Schedule.java deleted file mode 100644 index d39bebd..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Schedule.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -/** - * Schedule - */ -public class Schedule { - private String interval; - - public String getInterval() { - return interval; - } - - public void setInterval(String interval) { - this.interval = interval; - } -} \ No newline at end of file diff --git a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Target.java b/src/main/java/com/loafle/overflow/model/sensorconfig/old/Target.java deleted file mode 100644 index 65d89e7..0000000 --- a/src/main/java/com/loafle/overflow/model/sensorconfig/old/Target.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.loafle.overflow.model.sensorconfig.old; - -public class Target { - // private Map auth; - // private Connection connection; - // private Map meta; - -} \ No newline at end of file