From: Niels Erik G. Nielsen Date: Wed, 6 Nov 2013 00:57:14 +0000 (-0500) Subject: Adds some support for compound expressions (filter,limit) X-Git-Tag: v0.0.7~15 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=499264a3ac955aafd1a9c3a0f280ec9a9bcdcfd0;p=mkjsf-moved-to-github.git Adds some support for compound expressions (filter,limit) --- 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 */