Removed version from FCSQL query processor.

Change-Id: I906d7c1d66feb90d7ca0ca8e4ad1eb51f2f54806
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
index ef7e375..671f505 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
@@ -12,8 +12,9 @@
 import eu.clarin.sru.server.fcs.parser.QueryParser;
 import eu.clarin.sru.server.fcs.parser.QueryParserException;
 
-/** FCSQLQueryProcessor is accountable for the serialization of FCSQL to KoralQuery.
- * The KoralQuery is structured as a map containing parts of JSON-LD serializations of KoralObjects.  
+/** FCSQLQueryProcessor is accountable for the serialization of FCSQL 
+ *  to KoralQuery. The KoralQuery is structured as a map containing 
+ *  parts of JSON-LD serializations of KoralObjects.  
  * 
  * @author margaretha
  * 
@@ -32,22 +33,13 @@
         }
     }
 
-    private static final String VERSION_2_0 = "2.0";
-
     private final QueryParser fcsParser = new QueryParser();
-    private String version;
     
-    public FCSQLQueryProcessor (String query) {
-        this(query, VERSION_2_0);
-    }
-
     /** Constructs FCSQLQueryProcessor for the given query and version.
      * @param query an FCS query string
-     * @param version the FCSQL version of the query
      */
-    public FCSQLQueryProcessor (String query, String version) {
+    public FCSQLQueryProcessor (String query) {
         super();
-        this.version = version;
         process(query);
     }
 
@@ -58,33 +50,17 @@
 
     @Override
     public void process(String query) {
-        if (isVersionValid()) {
-            FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
-            if (fcsSruQuery != null) {
-                QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
-                try {
-					parseFCSQueryToKoralQuery(fcsQueryNode);
-				} catch (KoralException e) {
-					addError(e.getStatusCode(), e.getMessage());
-				}
-            }
+        FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
+        if (fcsSruQuery != null) {
+            QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
+            try {
+				parseFCSQueryToKoralQuery(fcsQueryNode);
+			} catch (KoralException e) {
+				addError(e.getStatusCode(), e.getMessage());
+			}
         }
     }
 
-    private boolean isVersionValid() {
-        if (version == null || version.isEmpty()) {
-            addError(StatusCodes.MISSING_VERSION,
-                    "Version number is missing.");
-            return false;
-        }
-        else if (!version.equals(VERSION_2_0)) {
-            addError(StatusCodes.UNSUPPORTED_VERSION,
-                    "Only supports SRU version 2.0.");
-            return false;
-        }
-        return true;
-    }
-
     /** Translates the given FCS query string into an FCSSSRUQuery object.
      * @param query an FCS query string
      * @return an FCSSRUQuery
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index 4b192b0..699581b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -1,15 +1,21 @@
 package de.ids_mannheim.korap.query.serialize;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
-import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.log4j.BasicConfigurator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.*;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import de.ids_mannheim.korap.query.serialize.util.KoralObjectGenerator;
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
 
 /**
  * Main class for Koral, serializes queries from concrete QLs to KoralQuery
@@ -118,7 +124,7 @@
             ast = new CqlQueryProcessor(query);
         }
         else if (queryLanguage.equalsIgnoreCase("fcsql")) {
-            ast = new FCSQLQueryProcessor(query, "2.0");
+            ast = new FCSQLQueryProcessor(query);
         }
         else if (queryLanguage.equalsIgnoreCase("annis")) {
             ast = new AnnisQueryProcessor(query);
@@ -157,14 +163,7 @@
             }
         }
         else if (ql.equalsIgnoreCase("fcsql")) {
-            if (version == null) {
-                ast = new FCSQLQueryProcessor(query);
-//                ast.addError(StatusCodes.MISSING_VERSION,
-//                        "SRU Version is missing!");
-            }
-            else {
-                ast = new FCSQLQueryProcessor(query, version);
-            }
+            ast = new FCSQLQueryProcessor(query);
         }
         else if (ql.equalsIgnoreCase("annis")) {
             ast = new AnnisQueryProcessor(query);
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
index 60199bb..7417644 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLComplexTest.java
@@ -382,8 +382,7 @@
                 .validateNode(query, "/query/operands/0", jsonLd);
 
         query = "[cnx:pos=\"VVFIN\"] within u";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(311, error.get(0));
         assertEquals(
                 "Within scope UTTERANCE is currently unsupported.",
@@ -435,24 +434,20 @@
         
         // expression should always be within a segment
         query = "!(mate:lemma=\"sein\" | mate:pos=\"PPOSS\")";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(399, error.get(0));
         assertEquals(errorMessage, error.get(1).toString());
 
         query = "![mate:lemma=\"sein\" | mate:pos=\"PPOSS\"]";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(errorMessage, error.get(1).toString());
 
         query = "(\"blaue\"&\"grüne\")";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(errorMessage, error.get(1).toString());
 
         query = "[pos=\"NN\"]&[text=\"Mann\"]";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(399, error.get(0));
         assertEquals(errorMessage, error.get(1).toString());
     }
diff --git a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
index 4876943..3d8bfaa 100644
--- a/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/test/fcsql/FCSQLQueryProcessorTest.java
@@ -29,7 +29,7 @@
 
     public static void runAndValidate(String query, String jsonLd)
             throws JsonProcessingException {
-        FCSQLQueryProcessor processor = new FCSQLQueryProcessor(query, "2.0");
+        FCSQLQueryProcessor processor = new FCSQLQueryProcessor(query);
         String serializedQuery = mapper.writeValueAsString(processor
                 .getRequestMap().get("query"));
         assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
@@ -37,7 +37,7 @@
 
     public static void validateNode(String query, String path, String jsonLd)
             throws JsonProcessingException, IOException {
-        qs.setQuery(query, "fcsql", "2.0");
+        qs.setQuery(query, "fcsql");
         node = mapper.readTree(qs.toJSON());
         String serializedQuery = mapper.writeValueAsString(node.at(path));
         assertEquals(jsonLd.replace(" ", ""), serializedQuery.replace("\"", ""));
@@ -48,19 +48,6 @@
         return (List<Object>) errors.get(0);
     }
 
-    @Test
-    public void testVersion() throws JsonProcessingException {
-        error = getError(new FCSQLQueryProcessor("\"Sonne\"", "1.0"));
-        assertEquals(310, error.get(0));
-        assertEquals("Only supports SRU version 2.0.",
-                error.get(1));
-
-        error = getError(new FCSQLQueryProcessor("\"Sonne\"", null));
-        assertEquals(309, error.get(0));
-        assertEquals("Version number is missing.",
-                error.get(1));
-    }
-
     // regexp ::= quoted-string
     @Test
     public void testTermQuery() throws JsonProcessingException {
@@ -116,15 +103,13 @@
         FCSQLQueryProcessorTest.validateNode(query, "/query/wrap", jsonLd);
 
         query = "\"Fliegen\" /l";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         String msg = (String) error.get(1);
         assertEquals(true, msg.startsWith("Regexflags"));
 
         query = "\"Fliegen\" /d";
-        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query,
-                "2.0"));
+        error = FCSQLQueryProcessorTest.getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals(
                 "Regexflag: IGNORE_DIACRITICS is unsupported.",
@@ -300,7 +285,7 @@
                 + "{@type: koral:term, key: PPOSS, foundry: mate, layer: p, type:type:regex, match: match:ne}]}}";
         //FCSQLQueryProcessorTest.runAndValidate(query, jsonLd);
         
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(399, error.get(0));
         assertEquals(
                 "Query cannot be parsed, an unexpcected occured exception while parsing",
@@ -311,35 +296,35 @@
     public void testExceptions() throws JsonProcessingException {
         // unsupported lemma und qualifier
         query = "[opennlp:lemma = \"sein\"]";
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals(
                 "Layer lemma with qualifier opennlp is unsupported.",
                 error.get(1));
 
         query = "[tt:morph = \"sein\"]";
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals("Layer morph is unsupported.",
                 error.get(1));
 
         // unsupported qualifier
         query = "[malt:lemma = \"sein\"]";
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals("Qualifier malt is unsupported.",
                 error.get(1));
 
         // unsupported layer
         query = "[cnx:morph = \"heit\"]";
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals("Layer morph is unsupported.",
                 error.get(1));
 
         // missing layer
         query = "[cnx=\"V\"]";
-        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        error = getError(new FCSQLQueryProcessor(query));
         assertEquals(306, error.get(0));
         assertEquals("Layer cnx is unsupported.",
                 error.get(1));