From 0aef8f100ba550362bf63b33399eccc409ab6b19 Mon Sep 17 00:00:00 2001 From: "jackdaw@loafle.com" Date: Wed, 26 Apr 2017 10:58:56 +0900 Subject: [PATCH] result set --- .../loafle/overflow/crawler/config/Item.java | 21 ++++++++++---- .../loafle/overflow/crawler/config/Query.java | 29 ------------------- .../overflow/crawler/result/OFResultSet.java | 2 +- .../crawler/result/OFResultSetCol.java | 6 ++-- .../crawler/result/OFResultSetRow.java | 16 +++++----- 5 files changed, 26 insertions(+), 48 deletions(-) delete mode 100644 src/main/java/com/loafle/overflow/crawler/config/Query.java diff --git a/src/main/java/com/loafle/overflow/crawler/config/Item.java b/src/main/java/com/loafle/overflow/crawler/config/Item.java index b43282a..7fdef3d 100644 --- a/src/main/java/com/loafle/overflow/crawler/config/Item.java +++ b/src/main/java/com/loafle/overflow/crawler/config/Item.java @@ -1,6 +1,7 @@ package com.loafle.overflow.crawler.config; import java.util.List; +import java.util.Map; /** * Created by root on 17. 4. 13. @@ -8,21 +9,29 @@ import java.util.List; public class Item { List metrics; - Query query; + List keys; + Map queryInfo; public List getMetrics() { return metrics; } - public void setMetrics(List metrics) { this.metrics = metrics; } - public Query getQuery() { - return query; + public List getKeys() { + return keys; } - public void setQuery(Query query) { - this.query = query; + public void setKeys(List keys) { + this.keys = keys; + } + + public Map getQueryInfo() { + return queryInfo; + } + + public void setQueryInfo(Map queryInfo) { + this.queryInfo = queryInfo; } } diff --git a/src/main/java/com/loafle/overflow/crawler/config/Query.java b/src/main/java/com/loafle/overflow/crawler/config/Query.java deleted file mode 100644 index c381331..0000000 --- a/src/main/java/com/loafle/overflow/crawler/config/Query.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.loafle.overflow.crawler.config; - -import java.util.List; -import java.util.Map; - -/** - * Created by snoop on 2017-04-21. - */ -public class Query { - - Map queryInfo; - List keys; - - public Map getQueryInfo() { - return queryInfo; - } - - public void setQueryInfo(Map queryInfo) { - this.queryInfo = queryInfo; - } - - public List getKeys() { - return keys; - } - - public void setKeys(List keys) { - this.keys = keys; - } -} diff --git a/src/main/java/com/loafle/overflow/crawler/result/OFResultSet.java b/src/main/java/com/loafle/overflow/crawler/result/OFResultSet.java index f1ba219..e7acc0b 100644 --- a/src/main/java/com/loafle/overflow/crawler/result/OFResultSet.java +++ b/src/main/java/com/loafle/overflow/crawler/result/OFResultSet.java @@ -42,7 +42,7 @@ public abstract class OFResultSet { // methods static public OFResultSet newInstance(Item item) { - String type = (String) item.getQuery().getQueryInfo().get("parseDirection"); + String type = (String) item.getQueryInfo().get("parseDirection"); if (type != null && type.equals("row")) { return new OFResultSetRow(item); } else { diff --git a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java index 8aa0f5a..d30f856 100644 --- a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java +++ b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetCol.java @@ -16,8 +16,8 @@ public class OFResultSetCol extends OFResultSet{ public void setMeta() { - List meta = this.item.getQuery().getKeys(); - List arrayColumns = (List)this.item.getQuery().getQueryInfo().get("arrayColumns"); + List meta = this.item.getKeys(); + List arrayColumns = (List)this.item.getQueryInfo().get("arrayColumns"); if(this.meta == null) { this.meta = new HashMap<>(); @@ -40,7 +40,7 @@ public class OFResultSetCol extends OFResultSet{ public Map parse() { List metrics = this.item.getMetrics(); - List arrayColumns = (List)this.item.getQuery().getQueryInfo().get("arrayColumns"); + List arrayColumns = (List)this.item.getQueryInfo().get("arrayColumns"); // this.meta Map resultMap = new HashMap<>(); diff --git a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetRow.java b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetRow.java index ac9da46..994a09c 100644 --- a/src/main/java/com/loafle/overflow/crawler/result/OFResultSetRow.java +++ b/src/main/java/com/loafle/overflow/crawler/result/OFResultSetRow.java @@ -1,7 +1,6 @@ package com.loafle.overflow.crawler.result; import com.loafle.overflow.crawler.config.Item; -import com.loafle.overflow.crawler.config.Query; import java.util.ArrayList; import java.util.HashMap; @@ -22,9 +21,9 @@ public class OFResultSetRow extends OFResultSet{ List meta = new ArrayList<>(); - List arrayColumns = (List) this.item.getQuery().getQueryInfo().get("arrayColumns"); - List keyColumns = (List) this.item.getQuery().getQueryInfo().get("keyColumns"); - String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn"); + List arrayColumns = (List) this.item.getQueryInfo().get("arrayColumns"); + List keyColumns = (List) this.item.getQueryInfo().get("keyColumns"); + String valueColumn = (String) this.item.getQueryInfo().get("valueColumn"); if (arrayColumns != null) { for (String c : arrayColumns) { meta.add(c); @@ -54,7 +53,7 @@ public class OFResultSetRow extends OFResultSet{ Map returnMap = new HashMap<>(); - String valueColumn = (String) this.item.getQuery().getQueryInfo().get("valueColumn"); + String valueColumn = (String) this.item.getQueryInfo().get("valueColumn"); for (List row : this.rows) { String key = makeKey(row); @@ -66,12 +65,11 @@ public class OFResultSetRow extends OFResultSet{ private String makeKey(List data) { - Query query = this.item.getQuery(); List metrics = this.item.getMetrics(); - List arrayColumns = (List) this.item.getQuery().getQueryInfo().get("arrayColumns"); - List keyColumns = (List) this.item.getQuery().getQueryInfo().get("keyColumns"); - List keys = query.getKeys(); + List arrayColumns = (List) this.item.getQueryInfo().get("arrayColumns"); + List keyColumns = (List) this.item.getQueryInfo().get("keyColumns"); + List keys = this.item.getKeys(); boolean find = false; int findIndex = -1;