Handle Warnings correctly
diff --git a/src/main/java/de/ids_mannheim/korap/KorapResult.java b/src/main/java/de/ids_mannheim/korap/KorapResult.java
index 4cf2ff8..cedf75c 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapResult.java
@@ -36,6 +36,7 @@
private String benchmarkSearchResults,
benchmarkHitCounter;
private String error = null;
+ private String warning = null;
private String version;
private JsonNode request;
@@ -144,11 +145,21 @@
return this.error;
}
-
public void setError(String msg) {
this.error = msg;
}
+ public String getWarning() {
+ return this.warning;
+ }
+
+ public void addWarning (String warning) {
+ if (this.warning == null)
+ this.warning = warning;
+ else
+ this.warning += "; " + warning;
+ };
+
public void setRequest(JsonNode request) {
this.request = request;
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 56b06a6..f1b637f 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -35,6 +35,7 @@
private KorapCollection collection;
private KorapIndex index;
private String error;
+ private String warning;
private JsonNode request;
@@ -63,6 +64,9 @@
this.error = "No query defined";
};
+ if (this.request.has("warning"))
+ this.warning = this.request.get("warning").asText();
+
// "meta" virtual collections
if (this.request.has("collections"))
this.setCollection(new KorapCollection(jsonString));
@@ -121,6 +125,17 @@
return this.error;
};
+ public String getWarning () {
+ return this.warning;
+ };
+
+ public void addWarning (String warning) {
+ if (this.warning == null)
+ this.warning = warning;
+ else
+ this.warning += "; " + warning;
+ };
+
public SpanQuery getQuery () {
return this.query;
};
@@ -261,12 +276,16 @@
KorapResult kr = new KorapResult();
kr.setRequest(this.request);
kr.setError(this.error);
+ if (this.warning != null)
+ kr.addWarning(this.warning);
return kr;
};
this.getCollection().setIndex(ki);
KorapResult kr = ki.search(this.getCollection(), this);
kr.setRequest(this.request);
+ if (this.warning != null)
+ kr.addWarning(this.warning);
return kr;
};
};