Fixed empty user availabilities.
Change-Id: I8efe10fa3adbf3452e026024cc970b91e9c6f174
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewrite.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewrite.java
index 54b5457..142b9f6 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewrite.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewrite.java
@@ -48,8 +48,7 @@
&& node.at("/key").asText().equals("availability")) {
String queryAvailability = node.at("/value").asText();
String matchOp = node.at("/match").asText();
- if (userAvailabilities.contains(queryAvailability) && matchOp.
- equals(KoralMatchOperator.EQUALS.toString())){
+ if (!userAvailabilities.contains(queryAvailability)){
userAvailabilities.remove(queryAvailability);
}
}
@@ -91,7 +90,9 @@
if (jsonNode.has("collection")) {
userAvailabilities = checkAvailability(jsonNode.at("/collection"), userAvailabilities);
- builder.with(buildAvailability(userAvailabilities));
+ if (!userAvailabilities.isEmpty()){
+ builder.with(buildAvailability(userAvailabilities));
+ }
builder.setBaseQuery(builder.toJSON());
rewrittesNode = builder.mergeWith(jsonNode).at("/collection");
node.set("collection", rewrittesNode, identifier);