From 499264a3ac955aafd1a9c3a0f280ec9a9bcdcfd0 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Tue, 5 Nov 2013 19:57:14 -0500 Subject: [PATCH] Adds some support for compound expressions (filter,limit) --- .../mkjsf/pazpar2/commands/SearchCommand.java | 56 ++++++++++++++------ 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java index b8003cc..dcbb323 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -1,7 +1,9 @@ package com.indexdata.mkjsf.pazpar2.commands; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.StringTokenizer; import javax.enterprise.context.SessionScoped; import javax.inject.Named; @@ -70,14 +72,24 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand /** * Sets the filter parameter. See Pazpar2 documentation for details. */ - public void setFilter(String filterExpression) { - if (filterExpression != null && filterExpression.length()>0) { - if (filterExpression.split("[=~]").length==1) { - removeFilters(filterExpression.split("[=~]")[0]); - } else if (filterExpression.split("[=~]").length==2) { - setParameter(new FilterParameter(new Expression(filterExpression))); - } else { - logger.error("Could not parse filter expression [" + filterExpression + "]"); + public void setFilter(String compoundExpression) { + if (compoundExpression != null && compoundExpression.length()>0) { + String[] subExpressions = compoundExpression.split(","); + for (int i=0; ilimit parameter. See Pazpar2 documentation for details. */ - public void setLimit (String limitExpression) { - if (limitExpression != null && limitExpression.length()>0) { - if (limitExpression.split("[=~]").length==1) { - removeLimits(limitExpression.split("[=~]")[0]); - } else if (limitExpression.split("[=~]").length==2) { - setParameter(new LimitParameter(new Expression(limitExpression))); - } else { - logger.error("Could not parse limit expression [" + limitExpression + "]"); + public void setLimit (String compoundExpression) { + if (compoundExpression != null && compoundExpression.length()>0) { + String[] subExpressions = compoundExpression.split(","); + for (int i=0; iexpressionFields + * Returns a list of limit expressions with fields that matches one of expressionFields * * @param expressionFields limit expressions to look for */ -- 1.7.10.4