collection query and meta serialization;
refactoring REST service;
piwik filter for REST;
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index f8dc4e6..7bf8784 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,9 +1,8 @@
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
-import de.ids_mannheim.korap.query.serialize.CollectionQuery;
+import de.ids_mannheim.korap.query.serialize.CollectionQueryBuilder;
import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.resource.Relation;
import de.ids_mannheim.korap.util.QueryException;
import org.junit.Assert;
import org.junit.Test;
@@ -30,7 +29,7 @@
b.append(" AND ");
b.append("textClass:wissenschaft");
// CollectionQuery qu = new CollectionQuery().addMetaFilterQuery(b.toString());
- CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQueryBuilder query = new CollectionQueryBuilder().addMetaFilterQuery(b.toString());
System.out.println(query.buildString());
System.out.println(query.toCollections());
// System.out.println("value reference " + qu.stringify());
@@ -39,7 +38,7 @@
@Test
public void testSingle() throws IOException {
- CollectionQuery query = new CollectionQuery().addMetaFilter("textClass", "wissenschaft");
+ CollectionQueryBuilder query = new CollectionQueryBuilder().addMetaFilter("textClass", "wissenschaft");
// System.out.println("------ TEXT SINGLE " + query.stringify());
System.out.println(query.buildString());
}
@@ -52,7 +51,7 @@
b.append("pubDate:<2012-04-01");
b.append(" AND ");
b.append("author:Goethe");
- CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQueryBuilder query = new CollectionQueryBuilder().addMetaFilterQuery(b.toString());
System.out.println("value until/since : " + query.buildString());
System.out.println("meta value until/since " + query.toCollections());
Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Goethe\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"between\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2012-04-01\"},{\"@type\":\"korap:date\",\"@value\":\"2013-04-01\"}]}]}}]", query.buildString());
@@ -65,7 +64,7 @@
b.append("pubDate:>2013-12-10");
b.append(" AND ");
b.append("author:Hesse");
- CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQueryBuilder query = new CollectionQueryBuilder().addMetaFilterQuery(b.toString());
System.out.println("Running date check (until) with additional attribute author");
Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Hesse\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"until\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.buildString());
// System.out.println("value until : " + query.stringify());
@@ -78,7 +77,7 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQueryBuilder query = new CollectionQueryBuilder().addMetaFilterQuery(b.toString());
System.out.println("value since : " + query.buildString());
System.out.println("meta value since " + query.toCollections());
// System.out.println();
@@ -126,7 +125,7 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery q = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addMetaFilterQuery(b.toString());
q.addMetaExtend("author", "Hesse");
System.out.println("--- ALL " + q.buildString());
@@ -140,14 +139,14 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery q = new CollectionQuery().addMetaExtendQuery(b.toString());
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addMetaExtendQuery(b.toString());
System.out.println("array repres " + q.buildString());
System.out.println();
}
@Test
public void testCollections() throws IOException {
- CollectionQuery q = new CollectionQuery().addMetaFilter("corpusID", "A00");
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addMetaFilter("corpusID", "A00");
q.addMetaExtend("corpusID", "A01");
System.out.println("results stringified " + q.buildString());
@@ -164,14 +163,14 @@
@Test
public void testResources() throws IOException {
String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
- CollectionQuery q = new CollectionQuery().addResource(meta);
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addResource(meta);
System.out.println("Testing Resource Meta data");
org.junit.Assert.assertEquals("{\"collections\":" + meta + "}", q.toCollections());
}
@Test
public void testA00() throws IOException {
- CollectionQuery q = new CollectionQuery().addMetaExtend("corpusID", "A00").addMetaExtend("corpusID", "A01");
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addMetaExtend("corpusID", "A00").addMetaExtend("corpusID", "A01");
System.out.println("A meta: " + q.buildString());
System.out.println();
}
@@ -179,7 +178,7 @@
@Test
public void testResources2() throws IOException {
String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
- CollectionQuery q = new CollectionQuery().addResource(meta);
+ CollectionQueryBuilder q = new CollectionQueryBuilder().addResource(meta);
q.addMetaFilter("textClass", "wissenschaft");
System.out.println("stringified meta " + q.buildString());
System.out.println("meta string " + q.toCollections());