REST query function with json-ld body;
policyrewrite bug fixes;
query serializer builder class;
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index 1995510..f8dc4e6 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -29,11 +29,10 @@
b.append("pubPlace:Erfurt");
b.append(" AND ");
b.append("textClass:wissenschaft");
-// CollectionQuery qu = new CollectionQuery().addMetaFilter(b.toString());
- CollectionQuery query = new CollectionQuery().addMetaFilter(b.toString(),
- Relation.AND);
- System.out.println(query.buildString(Relation.AND, Relation.AND));
- System.out.println(query.toCollections(Relation.AND, Relation.AND));
+// CollectionQuery qu = new CollectionQuery().addMetaFilterQuery(b.toString());
+ CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ System.out.println(query.buildString());
+ System.out.println(query.toCollections());
// System.out.println("value reference " + qu.stringify());
// System.out.println();
}
@@ -42,7 +41,7 @@
public void testSingle() throws IOException {
CollectionQuery query = new CollectionQuery().addMetaFilter("textClass", "wissenschaft");
// System.out.println("------ TEXT SINGLE " + query.stringify());
- System.out.println(query.buildString(Relation.AND, Relation.AND));
+ System.out.println(query.buildString());
}
@Test
@@ -53,10 +52,10 @@
b.append("pubDate:<2012-04-01");
b.append(" AND ");
b.append("author:Goethe");
- CollectionQuery query = new CollectionQuery().addMetaFilter(b.toString(), Relation.AND);
- System.out.println("value until/since : " + query.buildString(Relation.AND, Relation.AND));
- System.out.println("meta value until/since " + query.toCollections(Relation.AND, Relation.AND));
- 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(Relation.AND, Relation.AND));
+ CollectionQuery query = new CollectionQuery().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());
// System.out.println();
}
@@ -66,9 +65,9 @@
b.append("pubDate:>2013-12-10");
b.append(" AND ");
b.append("author:Hesse");
- CollectionQuery query = new CollectionQuery().addMetaFilter(b.toString(), Relation.AND);
+ CollectionQuery query = new CollectionQuery().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(Relation.AND, Relation.AND));
+ 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());
// System.out.println();
}
@@ -79,13 +78,12 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery query = new CollectionQuery().addMetaFilter(b.toString(), Relation.AND);
- System.out.println("value since : " + query.buildString(Relation.AND,
- Relation.AND));
- System.out.println("meta value since " + query.toCollections(Relation.AND, Relation.AND));
+ CollectionQuery query = new CollectionQuery().addMetaFilterQuery(b.toString());
+ System.out.println("value since : " + query.buildString());
+ System.out.println("meta value since " + query.toCollections());
// System.out.println();
System.out.println("Running date check (since) 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\":\"Kafka\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"since\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.buildString(Relation.AND, Relation.AND));
+ Assert.assertEquals("[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:group\",\"relation\":\"and\",\"operands\":[{\"@type\":\"korap:term\",\"@field\":\"korap:field#author\",\"@value\":\"Kafka\"},{\"@type\":\"korap:group\",\"@field\":\"korap:field#pubDate\",\"relation\":\"since\",\"operands\":[{\"@type\":\"korap:date\",\"@value\":\"2013-12-10\"}]}]}}]", query.buildString());
}
@Test
@@ -128,10 +126,10 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery q = new CollectionQuery().addMetaFilter(b.toString(), Relation.AND);
+ CollectionQuery q = new CollectionQuery().addMetaFilterQuery(b.toString());
q.addMetaExtend("author", "Hesse");
- System.out.println("--- ALL " + q.buildString(Relation.AND, Relation.AND));
+ System.out.println("--- ALL " + q.buildString());
System.out.println();
}
@@ -142,8 +140,8 @@
b.append("pubDate:<2013-12-10");
b.append(" AND ");
b.append("author:Kafka");
- CollectionQuery q = new CollectionQuery().addMetaExtend(b.toString(), Relation.AND);
- System.out.println("array repres " + q.buildString(Relation.AND, Relation.AND));
+ CollectionQuery q = new CollectionQuery().addMetaExtendQuery(b.toString());
+ System.out.println("array repres " + q.buildString());
System.out.println();
}
@@ -152,8 +150,8 @@
CollectionQuery q = new CollectionQuery().addMetaFilter("corpusID", "A00");
q.addMetaExtend("corpusID", "A01");
- System.out.println("results stringified " + q.buildString(Relation.AND, Relation.AND));
- System.out.println("results to meta" + q.toCollections(Relation.AND, Relation.AND));
+ System.out.println("results stringified " + q.buildString());
+ System.out.println("results to meta" + q.toCollections());
System.out.println();
}
@@ -168,13 +166,13 @@
String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
CollectionQuery q = new CollectionQuery().addResource(meta);
System.out.println("Testing Resource Meta data");
- org.junit.Assert.assertEquals("{\"collections\":" + meta + "}", q.toCollections(Relation.AND, Relation.AND));
+ org.junit.Assert.assertEquals("{\"collections\":" + meta + "}", q.toCollections());
}
@Test
public void testA00() throws IOException {
CollectionQuery q = new CollectionQuery().addMetaExtend("corpusID", "A00").addMetaExtend("corpusID", "A01");
- System.out.println("A meta: " + q.buildString(Relation.AND, Relation.AND));
+ System.out.println("A meta: " + q.buildString());
System.out.println();
}
@@ -183,8 +181,8 @@
String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
CollectionQuery q = new CollectionQuery().addResource(meta);
q.addMetaFilter("textClass", "wissenschaft");
- System.out.println("stringified meta " + q.buildString(Relation.AND, Relation.AND));
- System.out.println("meta string " + q.toCollections(Relation.AND, Relation.AND));
+ System.out.println("stringified meta " + q.buildString());
+ System.out.println("meta string " + q.toCollections());
}
}