update query with version
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
index 97537a4..84f97e3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CQLTree.java
@@ -17,6 +17,10 @@
import de.ids_mannheim.korap.util.QueryException;
+/**
+ * @author margaretha
+ *
+ * */
public class CQLTree extends AbstractSyntaxTree {
private static final String VERSION_1_1 = "1.1";
@@ -32,12 +36,16 @@
private LinkedHashMap<String,Object> requestMap;
private String version;
- private boolean isCaseSensitive;
+ private boolean isCaseSensitive; // default true
private StringBuilder sb;
- public CQLTree(String query) throws QueryException {
+ /*public CQLTree(String query) throws QueryException {
this(query, VERSION_1_2, true);
- }
+ }*/
+
+ public CQLTree(String query, String version) throws QueryException {
+ this(query, version, true);
+ }
public CQLTree(String query, String version, boolean isCaseSensitive) throws QueryException {
this.sb = new StringBuilder();
@@ -189,12 +197,5 @@
modifier.getValue() + "\" is not supported.");
}
}
-
- public String getVersion() {
- return version;
- }
- public void setVersion(String version) {
- this.version = version;
- }
}
diff --git a/src/test/java/CQLTest.java b/src/test/java/CQLTest.java
index ef778b3..d9dba01 100644
--- a/src/test/java/CQLTest.java
+++ b/src/test/java/CQLTest.java
@@ -12,7 +12,7 @@
public class CQLTest {
String query;
-
+ String version ="1.2";
@Test
public void testBooleanQuery() throws CQLParseException, IOException, QueryException{
query="((Sonne) or (Mond)) and (scheint)";
@@ -26,7 +26,7 @@
"]}," +
"{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
"]}";
- CQLTree cqlTree = new CQLTree(query);
+ CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
@@ -42,7 +42,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
"]}" +
"]}";
- cqlTree = new CQLTree(query);
+ cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
@@ -57,7 +57,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
"]}";
- CQLTree cqlTree = new CQLTree(query);
+ CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
@@ -71,7 +71,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=Mond, layer=orth, match=match:eq}}" +
"]}";
- cqlTree = new CQLTree(query);
+ cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
@@ -87,7 +87,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=scheint, layer=orth, match=match:eq}}" +
"]}" +
"]}";
- cqlTree = new CQLTree(query);
+ cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
}
@@ -96,7 +96,7 @@
public void testTermQuery() throws CQLParseException, IOException, QueryException{
query = "Sonne";
String jsonLd = "{@type=korap:token, wrap={@type=korap:term, key=Sonne, layer=orth, match=match:eq}}";
- CQLTree cqlTree = new CQLTree(query);
+ CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
}
@@ -110,7 +110,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=Mann, layer=orth, match=match:eq}}" +
"]}";
- CQLTree cqlTree = new CQLTree(query);
+ CQLTree cqlTree = new CQLTree(query, version);
String serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
@@ -123,7 +123,7 @@
"{@type=korap:token, wrap={@type=korap:term, key=schläft, layer=orth, match=match:eq}}" +
"]}";
- cqlTree = new CQLTree(query);
+ cqlTree = new CQLTree(query, version);
serializedQuery = cqlTree.getRequestMap().get("query").toString();
assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace(" ", ""));
}