excaped string 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 243a4d7..86f86f5 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
@@ -125,9 +125,11 @@
throw new IllegalArgumentException(ql + " is not a supported query language!");
}
Map<String, Object> requestMap = ast.getRequestMap();
+ MetaQuery metaQuery = new MetaQuery();
+ metaQuery.addResources(parents);
+
try {
- List<Map> meta_re = serializer.serializeResources(parents);
- requestMap.put("meta", meta_re);
+ requestMap.put("meta", metaQuery.raw());
requestMap = serializer.addParameters(requestMap, page, num,
cli, cri, cls, crs);
String res = mapper.writeValueAsString(requestMap);
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
index 3547d82..452d3c2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
@@ -35,24 +35,25 @@
this.track = ArrayListMultimap.create();
}
- public MetaQuery addResource(String query) throws IOException {
- JsonParser jp = factory.createParser(query);
- JsonNode m = jp.readValueAsTree();
- for (JsonNode n : m)
- this.rq.add(serialzer.treeToValue(n, Map.class));
- return this;
- }
-
- public MetaQuery addResources(List<String> queries) throws IOException {
- for (String query : queries) {
+ public MetaQuery addResource(String query) {
+ try {
JsonParser jp = factory.createParser(query);
JsonNode m = jp.readValueAsTree();
for (JsonNode n : m)
this.rq.add(serialzer.treeToValue(n, Map.class));
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Conversion went wrong!");
}
return this;
}
+ public MetaQuery addResources(List<String> queries) {
+ for (String query : queries)
+ addResource(query);
+ return this;
+ }
+
public MetaQuery addMetaFilter(Map<String, String> queries) {
//single is redundant!
boolean single = true;
@@ -228,11 +229,12 @@
public void clear() {
this.rq.clear();
this.mfil.clear();
+ this.track.clear();
}
@Deprecated
//todo: ordering irrelevant
- private List<Map> join() {
+ private List<Map> joinO() {
List<Map> cursor = new ArrayList<>(this.rq);
List<Map> copy = new ArrayList<>();
if (!this.mext.isEmpty()) {
@@ -250,16 +252,26 @@
return cursor;
}
- private List<Map> join2() {
+ private List<Map> join() {
List<Map> cursor = new ArrayList<>(this.rq);
cursor.addAll(this.mfil);
cursor.addAll(this.mext);
return cursor;
}
+ private List<Map> getMetaOnly() {
+ List<Map> cursor = new ArrayList<>(this.mfil);
+ cursor.addAll(this.mext);
+ return cursor;
+ }
+
+ /**
+ * returns the meta query only and does not contain parent dependencies
+ * @return
+ */
public String stringify() {
try {
- return serialzer.writeValueAsString(join2());
+ return serialzer.writeValueAsString(getMetaOnly());
} catch (JsonProcessingException e) {
e.printStackTrace();
return "";
@@ -267,12 +279,27 @@
}
public JsonNode jsonify() {
- return serialzer.valueToTree(join2());
+ return serialzer.valueToTree(join());
}
+ /**
+ * returns the List<Map> that contains all the meta queries and resource queries
+ * added to the meta query container
+ * @return
+ */
+ public List<Map> raw() {
+ return join();
+ }
+
+ /**
+ * returns a JSON String representation that contains all information
+ * (meta query and resource meta queries alike) in a root meta JSON node
+ *
+ * @return
+ */
public String toMeta() {
Map meta = new LinkedHashMap();
- meta.put("meta", join2());
+ meta.put("meta", join());
try {
return serialzer.writeValueAsString(meta);