Added statistics back to the VC info web-service.
Change-Id: I6d9d3963116d1b2caeeee429336095f3e2c0e7a9
diff --git a/src/main/java/de/ids_mannheim/korap/service/QueryService.java b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
index 60c4bef..1962167 100644
--- a/src/main/java/de/ids_mannheim/korap/service/QueryService.java
+++ b/src/main/java/de/ids_mannheim/korap/service/QueryService.java
@@ -679,14 +679,14 @@
String createdBy, QueryType queryType) throws KustvaktException {
QueryDO query = searchQueryByName(username, queryName, createdBy,
queryType);
- // String json = query.getKoralQuery();
+
String statistics = null;
// long start,end;
// start = System.currentTimeMillis();
- // if (query.getQueryType().equals(QueryType.VIRTUAL_CORPUS))
- // {
- // statistics = krill.getStatistics(json);
- // }
+ if (query.getQueryType().equals(QueryType.VIRTUAL_CORPUS)) {
+ String json = query.getKoralQuery();
+ statistics = krill.getStatistics(json);
+ }
// end = System.currentTimeMillis();
// jlog.debug("{} statistics duration: {}", queryName, (end -
// start));
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusInfoTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusInfoTest.java
index 9495660..552026f 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusInfoTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusInfoTest.java
@@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
+import org.mozilla.javascript.Node;
import com.fasterxml.jackson.databind.JsonNode;
@@ -31,8 +32,17 @@
// assertEquals("koral:doc", node.at("/koralQuery/collection/@type").asText());
assertTrue(node.at("/query").isMissingNode());
assertTrue(node.at("/queryLanguage").isMissingNode());
+
+ testStatistics(node);
}
+ private void testStatistics (JsonNode node) {
+ assertTrue(node.at("/numberOfDoc").asInt()>0);
+ assertTrue(node.at("/numberOfParagraphs").asInt()>0);
+ assertTrue(node.at("/numberOfSentences").asInt()>0);
+ assertTrue(node.at("/numberOfTokens").asInt()>0);
+ }
+
@Test
public void testRetrieveSystemVC_guest ()
throws KustvaktException {
@@ -51,6 +61,8 @@
assertEquals(node.at("/name").asText(), "dory-vc");
assertEquals(ResourceType.PRIVATE.displayName(),
node.at("/type").asText());
+
+ testStatistics(node);
}
@Test
diff --git a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
index 8db247d..e33da75 100644
--- a/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/controller/vc/VirtualCorpusListTest.java
@@ -64,40 +64,4 @@
.get();
testResponseUnauthorized(response, "guest");
}
-
- @Disabled
- @Deprecated
- @Test
- public void testListAvailableVCByOtherUser ()
- throws ProcessingException, KustvaktException {
- Response response = target().path(API_VERSION).path("vc").path("~dory")
- .request().header(HttpHeaders.X_FORWARDED_FOR, "149.27.0.32")
- .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
- .createBasicAuthorizationHeaderValue("pearl", "pass"))
- .get();
- String entity = response.readEntity(String.class);
- JsonNode node = JsonUtils.readTree(entity);
- assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
- assertEquals(StatusCodes.AUTHORIZATION_FAILED,
- node.at("/errors/0/0").asInt());
- assertEquals(node.at("/errors/0/1").asText(),
- "Unauthorized operation for user: pearl");
- checkWWWAuthenticateHeader(response);
- }
-
- @Disabled
- @Deprecated
- @Test
- public void testListUserVC ()
- throws ProcessingException, KustvaktException {
- Response response = target().path(API_VERSION).path("vc")
- .queryParam("username", "dory").request()
- .header(Attributes.AUTHORIZATION, HttpAuthorizationHandler
- .createBasicAuthorizationHeaderValue("admin", "pass"))
- .get();
- assertEquals(Status.OK.getStatusCode(), response.getStatus());
- String entity = response.readEntity(String.class);
- JsonNode node = JsonUtils.readTree(entity);
- assertEquals(4, node.size());
- }
}