- Collection query response is whole requestMap, gets integrated into QuerySerializer field by field
- logging
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
index 82f3a80..e1bb0dd 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryTree.java
@@ -6,9 +6,12 @@
 
 import org.antlr.v4.runtime.*;
 import org.antlr.v4.runtime.tree.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.lang.reflect.Method;
 import java.util.*;
+import java.util.regex.Pattern;
 
 /**
  * @author hanl, bingel
@@ -16,6 +19,7 @@
  */
 public class CollectionQueryTree extends Antlr4AbstractSyntaxTree {
 
+	private static Logger log = LoggerFactory.getLogger(CollectionQueryTree.class);
     private Parser parser;
     private static boolean verbose;
     private List<ParseTree> visited = new ArrayList<ParseTree>();
@@ -53,7 +57,7 @@
         } else {
             throw new NullPointerException("Parser has not been instantiated!");
         }
-        System.out.println("Processing collection query");
+        log.info("Processing collection query");
         if (verbose) System.out.println(tree.toStringTree(parser));
         processNode(tree);
     }
@@ -99,6 +103,11 @@
             	requestMap = new LinkedHashMap<String,Object>();
             	return;
             }
+            if (checkDateValidity(valueNode)) {
+        		addWarning("The collection query contains a value that looks like a date ('"+valueNode.getText()+"')"
+        				+ " and an operator that is only defined for strings ('"+match+"'). The value is interpreted as "
+        						+ "a string, use a date operator to ensure the value is treated as a date");            	
+            }
             putIntoSuperObject(term);
         }
         
@@ -201,7 +210,7 @@
 		String match = (String) term.get("match");
 		String type = (String) term.get("type");
 		if (type == null || type.equals("type:regex")) {
-			if (!(match.equals("match:eq") || match.equals("match:ne") || match.equals("match:contains"))) {
+			if (!(match.equals("match:eq") || match.equals("match:ne") || match.equals("match:contains") || match.equals("match:containsnot"))) {
 				addError(302, "You used an inequation operator with a string value.");
 				return false;
 			}
@@ -231,8 +240,10 @@
 		return map;
 	}
 
-	private void checkDateValidity(ParseTree valueNode) {
+	private boolean checkDateValidity(ParseTree valueNode) {
 		// TODO ensure month is <= 12, day is <= 31 etc.
+//		Pattern p = 
+		return true;
 	}
 
 	private String interpretMatchOperator(String match) {
@@ -260,7 +271,7 @@
                 out = "contains";
                 break;    
             case "!~":
-                out = "notcontains";
+                out = "containsnot";
                 break;    
             case "in":
                 out = "eq";
@@ -312,8 +323,8 @@
             ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack.get(objStackPosition).get("operands");
             topObjectOperands.add(object);
         } else {
-        	requestMap = object;
-//        	requestMap.put("collection", object);
+//        	requestMap = object;
+        	requestMap.put("collection", object);
         }
     }
 
@@ -428,12 +439,10 @@
             // Get starting rule from parser
             Method startRule = CollectionQueryParser.class.getMethod("start");
             tree = (ParserRuleContext) startRule.invoke(parser, (Object[]) null);
-            System.out.println(tree.toStringTree(parser));
-
         }
         // Some things went wrong ...
         catch (Exception e) {
-            System.err.println("Parsing exception message: " + e.getMessage());
+            System.err.println("Parsing exception message: " + e);
         }
         if (tree == null) {
             throw new QueryException("Could not parse query. Make sure it is correct syntax.");
@@ -446,10 +455,9 @@
         String query = "foo=bar&c=d";
         query = "(1990<year<2010&genre=Sport)|textClass=politk";
         query = "(textClass=wissenschaft & textClass=politik) | textClass=ausland";
-        query = "1990<year<2010 & genre=Sport";
-        query = "1990<year<2010";
         query = "textClass=Sport & year=2014";
-        query = "textClass=0154";
+        query = "title!~mannheim";
+        query = "title=1984";
         CollectionQueryTree.verbose = true;
         CollectionQueryTree filter = null;
         try {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index 42b5775..1dfb430 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -113,7 +113,6 @@
 			throw new QueryException("Your query could not be processed. Please make sure it is well-formed.");
 		}
 		log.info("Processing CosmasII query");
-		System.out.println("Processing Cosmas");
 		processNode(tree);
 		log.info(requestMap.toString());
 	}
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 6458578..ef47d2f 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
@@ -2,14 +2,17 @@
 
 import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.databind.JsonMappingException;
+
 import de.ids_mannheim.korap.util.QueryException;
 import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.utils.KorAPLogger;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -23,6 +26,9 @@
     private AbstractSyntaxTree ast;
     private Object collection;
     private Map meta;
+    private List errors;
+    private List warnings;
+    private List messages;
     private org.slf4j.Logger log = LoggerFactory
             .getLogger(QuerySerializer.class);
 
@@ -40,16 +46,17 @@
         String[] queries;
         if (args.length == 0) {
             queries = new String[]{
-
+            		"foo"
             };
         } else
             queries = new String[]{args[0]};
-
+        
         for (String q : queries) {
             i++;
             try {
                 System.out.println(q);
                 String ql = "cosmas2";
+                jg.setCollection("pubDate=2014");
                 jg.run(q, ql, System.getProperty("user.home") + "/" + ql + "_" + i + ".jsonld");
                 System.out.println();
             } catch (NullPointerException npe) {
@@ -92,7 +99,9 @@
         } else {
             throw new QueryException(queryLanguage + " is not a supported query language!");
         }
+        toJSON();
         Map<String, Object> requestMap = ast.getRequestMap();
+        System.out.println(requestMap);
 //        mapper.writeValue(new File(outFile), requestMap);
     }
 
@@ -146,12 +155,28 @@
         if (ast != null) {
             Map<String, Object> requestMap = ast.getRequestMap();
             Map meta = (Map) requestMap.get("meta");
+            List errors = (List) requestMap.get("errors");
+            List warnings = (List) requestMap.get("warnings");
+            List messages = (List) requestMap.get("messages");
             if (collection != null)
                 requestMap.put("collection", collection);
             if (this.meta != null) {
                 meta.putAll(this.meta);
                 requestMap.put("meta", meta);
             }
+            if (this.errors != null) {
+                errors.addAll(this.errors);
+                requestMap.put("errors", errors);
+            }
+            if (this.warnings != null) {
+                warnings.addAll(this.warnings);
+                requestMap.put("warnings", warnings);
+            }
+            if (this.messages != null) {
+            	messages.addAll(this.messages);
+                requestMap.put("messages", messages);
+            }
+            
 
             return requestMap;
         }
@@ -194,8 +219,12 @@
 
     public QuerySerializer setCollection(String collection) throws QueryException {
         CollectionQueryTree tree = new CollectionQueryTree();
+        Map collectionRequest = tree.getRequestMap();
         tree.process(collection);
-        this.collection = tree.getRequestMap();
+        this.collection = collectionRequest.get("collection");
+        this.errors = (List) collectionRequest.get("errors");
+        this.warnings = (List) collectionRequest.get("warnings");
+        this.messages = (List) collectionRequest.get("messages");
         return this;
     }