meta query builder update for span context foundry spec
Change-Id: Ia8a2d6c76442b5aed3d4f6fca02d41cc9ad80f44
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
index 534253b..22963a5 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQueryBuilder.java
@@ -44,26 +44,30 @@
/**
* context if of type paragraph or sentence where left and right
* size delimiters are irrelevant; or 2-token, 2-char p/paragraph,
- * s/sentence or token, char
+ * s/sentence or token, char.
+ * Distinguish
*
* @param context
* @return
*/
public MetaQueryBuilder setSpanContext(String context) {
- if (context.startsWith("s") | context.startsWith("p"))
- this.spanContext = new SpanContext(context);
- else {
- String[] ct = context.replaceAll("\\s+", "").split(",");
- String[] lc = ct[0].split("-");
- String[] rc = ct[1].split("-");
- this.spanContext = new SpanContext(Integer.valueOf(lc[0]), lc[1],
- Integer.valueOf(rc[0]), rc[1]);
+ if (context != null) {
+ if (!context.contains("-") || context.contains(":"))
+ this.spanContext = new SpanContext(context);
+ else {
+ String[] ct = context.replaceAll("\\s+", "").split(",");
+ String[] lc = ct[0].split("-");
+ String[] rc = ct[1].split("-");
+ this.spanContext = new SpanContext(Integer.valueOf(lc[0]),
+ lc[1], Integer.valueOf(rc[0]), rc[1]);
+ }
}
return this;
}
public MetaQueryBuilder addEntry(String name, Object value) {
- meta.put(name, value);
+ if (value != null)
+ meta.put(name, value);
return this;
}
@@ -73,6 +77,8 @@
return meta;
}
+
+
@Data
public class SpanContext {
private String left_type;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index ff11926..92ac1f3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -231,7 +231,7 @@
return this;
}
- public QuerySerializer addMeta(MetaQueryBuilder meta) {
+ public QuerySerializer setMeta(MetaQueryBuilder meta) {
this.meta = meta.raw();
return this;
}