minor bug fixes
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
index 61f388b..9c7677b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
@@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@@ -17,6 +18,8 @@
ObjectMapper mapper;
AbstractSyntaxTree ast;
private Serializer serializer;
+ private org.slf4j.Logger log = LoggerFactory
+ .getLogger(JsonGenerator.class);
public JsonGenerator() {
mapper = new ObjectMapper();
@@ -35,7 +38,7 @@
String[] queries;
if (args.length == 0) {
queries = new String[]{
- /*
+ /*
* negation
* elemente
* within
@@ -110,24 +113,27 @@
mapper.writeValue(new File(outFile), requestMap);
}
- public String run(String query, String ql, List<String> meta,
+ public String run(String query, String ql, List<String> parents,
String cli, String cri, int cls, int crs, int page, int num) {
- if (ql.equals("poliqarp")) {
+ if (ql.toLowerCase().equals("poliqarp")) {
ast = new PoliqarpPlusTree(query);
// } else if (queryLanguage.equals("cosmas")) {
// ast = new CosmasTree(query);
- } else if (ql.equals("poliqarpplus")) {
+ } else if (ql.toLowerCase().equals("poliqarpplus")) {
ast = new PoliqarpPlusTree(query);
} else {
throw new IllegalArgumentException(ql + " is not a supported query language!");
}
Map<String, Object> requestMap = ast.getRequestMap();
try {
- List<Map> meta_re = serializer.serializeResources(meta);
+ List<Map> meta_re = serializer.serializeResources(parents);
+
+
requestMap.put("meta", meta_re);
requestMap = serializer.addParameters(requestMap, page, num,
cli, cri, cls, crs);
- return mapper.writeValueAsString(requestMap);
+ String res = mapper.writeValueAsString(requestMap);
+ return res;
} catch (IOException e) {
e.printStackTrace();
return null;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
index 0482480..8655288 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
@@ -104,8 +104,6 @@
Map re = types.mapify(query);
parids.add(re);
}
-// metas.put("meta", parids);
-// return mapper.writeValueAsString(metas);
return parids;
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
index 4cb32b9..3e24e4c 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
@@ -25,9 +25,9 @@
}
public String serializeMeta(List m_queries) throws JsonProcessingException {
- Map metas = new HashMap();
- metas.put("meta", m_queries);
- return mapper.writeValueAsString(metas);
+// Map metas = new HashMap();
+// metas.put("meta", m_queries);
+ return mapper.writeValueAsString(m_queries);
}
public List<Map> serializeResources(List<String> r_queries) throws IOException {
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index ccd0011..b1062d8 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,8 +1,10 @@
import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import de.ids_mannheim.korap.query.serialize.JsonGenerator;
import de.ids_mannheim.korap.query.serialize.MetaCollectionSerializer;
import de.ids_mannheim.korap.query.serialize.MetaQuerySerializer;
+import de.ids_mannheim.korap.query.serialize.Serializer;
import org.joda.time.DateTime;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -11,6 +13,7 @@
import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
/**
@@ -23,10 +26,12 @@
private MetaQuerySerializer querySerializer;
private MetaCollectionSerializer collSerializer;
+ private Serializer ser;
public MetaQuerySerializationTest() {
querySerializer = new MetaQuerySerializer();
collSerializer = new MetaCollectionSerializer();
+ ser = new Serializer();
}
@Test
@@ -114,4 +119,28 @@
}
}
+ @Test
+ public void testLists() {
+ Map<String, String> queries = new LinkedHashMap<>();
+ queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
+ queries.put("author", "Kafka");
+ List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
+
+ queries.clear();
+ queries.put("author", "Hesse");
+
+ List f = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.EXTEND);
+ s.addAll(f);
+ System.out.println("--- ALL " + s);
+ }
+
+ @Test
+ public void testJSONArray() throws JsonProcessingException {
+ Map<String, String> queries = new LinkedHashMap<>();
+ queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
+ queries.put("author", "Kafka");
+ List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
+ System.out.println("array repres " + ser.serializeMeta(s));
+ }
+
}