Resolved #69 - Fixed the distance serialization in CQL boolean queries.

Change-Id: I020ba0da1a3dc3238f140faec8d11e5ed4b8626e
diff --git a/Changes b/Changes
index 461b547..7b7d6b2 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,8 @@
     - [bugfix] Ignore min:max order in distance operators
       (#67; diewald)
     - [feature] Support #COND() operator alias in C2 (#70; diewald)
+    - [bugfix] Fixed the distance serialization in CQL boolean queries
+      (#69; margaretha)
 
 0.33 2019-02-20
     - Added debug flags (margaretha)
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
index 2dd8985..40e6755 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CqlQueryProcessor.java
@@ -1,15 +1,23 @@
 package de.ids_mannheim.korap.query.serialize;
 
-import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
-
-import org.z3950.zing.cql.*;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.z3950.zing.cql.CQLAndNode;
+import org.z3950.zing.cql.CQLBooleanNode;
+import org.z3950.zing.cql.CQLNode;
+import org.z3950.zing.cql.CQLOrNode;
+import org.z3950.zing.cql.CQLParseException;
+import org.z3950.zing.cql.CQLParser;
+import org.z3950.zing.cql.CQLRelation;
+import org.z3950.zing.cql.CQLTermNode;
+import org.z3950.zing.cql.Modifier;
+
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+
 /**
  * @author margaretha
  * @date 30.05.16
@@ -63,6 +71,7 @@
         // requestMap.put("query", sentenceWrapper(queryMap));
     }
 
+    @Deprecated
     private Map<String, Object> sentenceWrapper(Map<String, Object> m) {
         Map<String, Object> map = new LinkedHashMap<String, Object>();
         map.put("@type", "koral:group");
@@ -146,10 +155,15 @@
 
         List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
         Map<String, Object> distanceMap = new LinkedHashMap<String, Object>();
-        distanceMap.put("@type", "koral:distance");
+        distanceMap.put("@type", "cosmas:distance");
         distanceMap.put("key", "s");
-        distanceMap.put("min", "0");
-        distanceMap.put("max", "0");
+        
+        Map<String, Object> boundary = new LinkedHashMap<String, Object>();
+        boundary.put("type", "koral:boundary");
+        boundary.put("min", "0");
+        boundary.put("max", "0");
+        distanceMap.put("boundary", boundary);
+        
         list.add(distanceMap);
         map.put("distances", list);
 
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/CqlQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/CqlQueryProcessorTest.java
index 1448d54..56f435c 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/CqlQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/CqlQueryProcessorTest.java
@@ -18,6 +18,7 @@
     String VERSION = "1.2";
     ObjectMapper mapper = new ObjectMapper();
 
+    @SuppressWarnings("unchecked")
     private List<Object> getError(CqlQueryProcessor processor) {
         List<Object> errors = (List<Object>) processor.getRequestMap().get("errors");
         return (List<Object>) errors.get(0);
@@ -60,7 +61,7 @@
         query = "(Sonne) and (scheint)";
         String jsonLd = "{@type : koral:group, operation : operation:sequence, inOrder : false,"
                 + "distances:[ "
-                + "{@type : koral:distance, key : s, min : 0, max : 0 } ],"
+                + "{@type : cosmas:distance, key : s, boundary:{type:koral:boundary,min:0,max:0}} ],"
                 + "operands : ["
                 + "{@type : koral:token, wrap : {@type : koral:term,key : Sonne, layer : orth, match : match:eq}},"
                 + "{@type : koral:token,wrap : {@type : koral:term,key : scheint,layer : orth,match : match:eq}"
@@ -83,7 +84,7 @@
             Exception {
         query = "((Sonne) or (Mond)) and (scheint)";
         String jsonLd = "{@type:koral:group, operation:operation:sequence, inOrder : false, distances:["
-                + "{@type:koral:distance, key:s, min:0, max:0}"
+                + "{@type:cosmas:distance, key:s, boundary:{type:koral:boundary,min:0,max:0}}"
                 + "], operands:["
                 + "{@type:koral:group, operation:operation:or, operands:["
                 + "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, layer:orth, match:match:eq}},"
@@ -98,7 +99,7 @@
 
         query = "(scheint) and ((Sonne) or (Mond))";
         jsonLd = "{@type:koral:group, operation:operation:sequence, inOrder : false, distances:["
-                + "{@type:koral:distance, key:s, min:0, max:0}"
+                + "{@type:cosmas:distance, key:s, boundary:{type:koral:boundary,min:0,max:0}}"
                 + "], operands:["
                 + "{@type:koral:token, wrap:{@type:koral:term, key:scheint, layer:orth, match:match:eq}},"
                 + "{@type:koral:group, operation:operation:or, operands:["