some code cleanup
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
index 4a2ae95..7b1b01e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractSyntaxTree.java
@@ -11,17 +11,21 @@
import org.antlr.runtime.tree.Tree;
import org.antlr.v4.runtime.tree.ParseTree;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
import de.ids_mannheim.korap.util.QueryException;
public abstract class AbstractSyntaxTree {
- public abstract Map<String, Object> getRequestMap();
-
public abstract void process(String query) throws QueryException;
public static final Integer MAXIMUM_DISTANCE = 100;
-
+
+ Logger log;
+ /**
+ * The query
+ */
+ String query;
/**
* Top-level map representing the whole request.
*/
@@ -49,9 +53,20 @@
ParseTree currentNode = null;
Integer stackedObjects = 0;
ArrayList<String> errorMsgs = new ArrayList<String>();
- ArrayList<String> userWarnings = new ArrayList<String>();
- ArrayList<String> backendWarnings = new ArrayList<String>();
-
+ ArrayList<String> warnings = new ArrayList<String>();
+ ArrayList<String> announcements = new ArrayList<String>();
+
+ AbstractSyntaxTree() {
+ requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
+ requestMap.put("errors", errorMsgs);
+ requestMap.put("warnings", warnings);
+ requestMap.put("announcements", announcements);
+ }
+
+ public Map<String, Object> getRequestMap() {
+ return requestMap;
+ }
+
protected LinkedHashMap<String, Object> makeSpan() {
LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
span.put("@type", "korap:span");
@@ -112,7 +127,7 @@
group.put("boundary", makeBoundary(min, max));
group.put("min", min);
group.put("max", max);
- backendWarnings.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
+ announcements.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
return group;
}
@@ -163,7 +178,7 @@
group.put("boundary", makeBoundary(min, max));
group.put("min", min);
group.put("max", max);
- backendWarnings.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
+ announcements.add("Deprecated 2014-07-24: 'min' and 'max' to be supported until 6 months from deprecation date.");
return group;
}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
index 25d0fb9..8b726c0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Antlr4AbstractSyntaxTree.java
@@ -11,7 +11,6 @@
public abstract class Antlr4AbstractSyntaxTree extends AbstractSyntaxTree {
-
/**
* Parser object deriving the ANTLR parse tree.
*/
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
index 8cbaf19..51e5d6e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AqlTree.java
@@ -15,10 +15,10 @@
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.Lexer;
-import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.tree.ParseTree;
import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
import de.ids_mannheim.korap.query.annis.AqlLexer;
import de.ids_mannheim.korap.query.annis.AqlParser;
@@ -30,8 +30,7 @@
*
*/
public class AqlTree extends Antlr4AbstractSyntaxTree {
- private org.slf4j.Logger log = LoggerFactory
- .getLogger(AqlTree.class);
+ private static Logger log = LoggerFactory.getLogger(AqlTree.class);
/**
* Flag that indicates whether token fields or meta fields are currently being processed
*/
@@ -87,7 +86,6 @@
* @param parser The ANTLR parser instance that generated the parse tree
*/
public AqlTree(String query) {
- requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
try {
process(query);
} catch (QueryException e) {
@@ -96,12 +94,6 @@
System.out.println(">>> "+requestMap.get("query")+" <<<");
}
-
- @Override
- public Map<String, Object> getRequestMap() {
- return requestMap;
- }
-
@Override
public void process(String query) throws QueryException {
ParseTree tree = parseAnnisQuery(query);
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 4da63da..9d0adb8 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
@@ -25,7 +25,6 @@
private static Logger log = LoggerFactory.getLogger(CosmasTree.class);
- String query;
LinkedList<LinkedHashMap[]> toWrapStack = new LinkedList<LinkedHashMap[]>();
/**
* Field for repetition query (Kleene + or * operations, or min/max queries: {2,4}
@@ -51,9 +50,6 @@
int wrapFirstOpInClass = -1;
int wrapSecondOpInClass = -1;
- Tree cosmasTree;
-
- LinkedHashMap<String, Object> treeMap = new LinkedHashMap<String, Object>();
/**
* Keeps track of all visited nodes in a tree
*/
@@ -91,12 +87,6 @@
}
@Override
- public Map<String, Object> getRequestMap() {
- return this.requestMap;
- }
-
-
- @Override
public void process(String query) throws QueryException {
Tree tree = null;
try {
@@ -108,8 +98,6 @@
}
log.info("Processing CosmasII query");
System.out.println("Processing Cosmas");
- requestMap.put("@context", "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld");
-// prepareContext(requestMap);
processNode(tree);
log.info(requestMap.toString());
}