Deprecated 'isAround' as a frame and favor 'contains'

Change-Id: Icf1ca7a52d9cf130151263220c4fb8bca9cd541e
diff --git a/Changes b/Changes
index 67ca7b1..c02f7ff 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,9 @@
       (margaretha, diewald)
     - [bugfix] Fixed setting candidates in element distance spans.
       (margaretha, diewald)
+    - [cleanup] Change contains' frame to be only "contains", for
+      compatibility with future changes; isAround is deprecated
+      for now (diewald)
 
 0.59.4 2021-07-27
     - [cleanup] Upgrade dependencies (diewald)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index a913460..c10d93c 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -663,7 +663,7 @@
             throw new QueryException(705,
                     "Number of operands is not acceptable");
 
-        String frame = "isAround";
+        String frame = "contains";
         // Temporary workaround for wrongly set overlaps
         if (json.has("frames")) {
             JsonNode frameN = json.get("frames");
@@ -688,14 +688,27 @@
 
         // Byte flag - should cover all 13 cases, i.e. two bytes long
         byte flag = WITHIN;
+        JsonNode operand;
         switch (frame) {
-            case "isAround":
-                JsonNode operand = operands.get(0);
+            case "contains":
+                operand = operands.get(0);
                 if (operand.get("@type").asText().equals("koral:token")){
                     throw new QueryException(StatusCodes.INVALID_QUERY, 
                             "Token cannot contain another token or element.");
                 }
                 break;
+            case "isAround":
+                operand = operands.get(0);
+                if (operand.get("@type").asText().equals("koral:token")){
+                    throw new QueryException(StatusCodes.INVALID_QUERY, 
+                            "Token cannot contain another token or element.");
+                }
+                this.addMessage(
+                    0,
+                    "'isAround' will have a different meaning in the future and is therefore temporarily deprecated in favor of 'contains'"
+                    );
+
+                break;
             case "strictlyContains":
                 flag = REAL_WITHIN;
                 break;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
index 5e06cfa..b7c2416 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -1,6 +1,7 @@
 package de.ids_mannheim.korap.index;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.io.*;
@@ -1105,8 +1106,9 @@
     public void queryJSONpoly2 () throws QueryException, IOException {
         String jsonPath = getClass().getResource("/queries/poly2.json").getFile();
         String jsonPQuery = getJsonString(jsonPath);
-        SpanQueryWrapper sqwi = new KrillQuery("tokens").fromKoral(jsonPQuery);
-
+        KrillQuery kq = new KrillQuery("tokens");
+        SpanQueryWrapper sqwi = kq.fromKoral(jsonPQuery);
+        
         SpanWithinQuery sq = (SpanWithinQuery) sqwi.toQuery();
 
         KrillIndex ki = new KrillIndex();
@@ -1118,6 +1120,12 @@
 
         ki.commit();
         Result kr = ki.search(sq, (short) 10);
+        assertTrue(!kq.hasErrors());
+        assertTrue(!kq.hasWarnings());
+        assertTrue(kq.hasMessages());
+        assertEquals("'isAround' will have a different meaning in the future and is therefore temporarily deprecated in favor of 'contains'",
+                     kq.getMessage(0).getMessage());
+
         assertEquals(2, kr.getTotalResults());
         assertEquals(0, kr.getMatch(0).getLocalDocID());
         assertEquals(76, kr.getMatch(0).getStartPos());
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
index 1738125..010df59 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
@@ -2,10 +2,12 @@
 
 import static de.ids_mannheim.korap.TestSimple.*;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.lucene.search.spans.SpanQuery;
 import org.junit.Test;
 
+import de.ids_mannheim.korap.KrillQuery;
 import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.util.QueryException;
 
@@ -54,7 +56,16 @@
         String filepath = getClass()
                 .getResource("/queries/submatch/simpleElement.jsonld")
                 .getFile();
-        SpanQueryWrapper sqwi = getJsonQuery(filepath);
+        // SpanQueryWrapper sqwi = getJsonQuery(filepath);
+
+        String jsonPQuery = getJsonString(filepath);
+        KrillQuery kq = new KrillQuery("tokens");
+        SpanQueryWrapper sqwi = kq.fromKoral(jsonPQuery);
+
+        assertTrue(!kq.hasErrors());
+        assertTrue(!kq.hasWarnings());
+        assertTrue(!kq.hasMessages());
+        
         SpanQuery sq = sqwi.toQuery();
         assertEquals(
                 "subspan(spanContain(<tokens:s />, tokens:tt/l:Haus), 1, 4)",
diff --git a/src/test/resources/queries/submatch/simpleElement.jsonld b/src/test/resources/queries/submatch/simpleElement.jsonld
index a48b56e..043df8f 100644
--- a/src/test/resources/queries/submatch/simpleElement.jsonld
+++ b/src/test/resources/queries/submatch/simpleElement.jsonld
@@ -16,7 +16,7 @@
          {
             "@type" : "koral:group",
             "frames" : [
-               "frames:isAround"
+               "frames:contains"
             ],
             "operands" : [
                {