From dd4fff017b784b22f3440b395fddb2418875772c Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Tue, 17 Dec 2013 11:35:11 -0500 Subject: [PATCH] Bugfixes to compound filter and limit settings --- .../mkjsf/pazpar2/commands/Pazpar2Command.java | 8 ++++ .../mkjsf/pazpar2/commands/SearchCommand.java | 44 +++++++------------- 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java index f61642c..4a802df 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Command.java @@ -219,6 +219,10 @@ public abstract class Pazpar2Command implements Serializable { checkInState(copy); } + public void removeParameterInState (String name) { + parameters.remove(name); + } + /** * Removes multiple parameters completely and notifies the state manager * -- once -- about the change @@ -254,6 +258,10 @@ public abstract class Pazpar2Command implements Serializable { checkInState(copy); } + public void addExpressionInState (String parameterName, Expression expression) { + getParameter(parameterName).addExpression(expression); + } + public void removeExpression(String parameterName, Expression expression) { Pazpar2Command copy = this.copy(); copy.getParameter(parameterName).removeExpression(expression); 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 f9f76a2..0c8d745 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -71,26 +71,19 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand * Sets the filter parameter. See Pazpar2 documentation for details. */ public void setFilter(String compoundExpression) { - if (compoundExpression != null && compoundExpression.length()>0) { - // Split expression by commas that are not escaped (with backslash) + if (getParameter("filter") != null) removeParameterInState("filter"); + if (compoundExpression != null && compoundExpression.length()>0) { + // Split expression by commas that are not escaped with backslash String[] subExpressions = compoundExpression.split("(?limit parameter. See Pazpar2 documentation for details. */ - public void setLimit (String compoundExpression) { - if (compoundExpression != null && compoundExpression.length()>0) { - // Split expression by commas that are not escaped (with backslash) + public void setLimit (String compoundExpression) { + if (getParameter("limit") != null) removeParameterInState("limit"); + if (compoundExpression != null && compoundExpression.length()>0) { + // Split expression by commas that are not escaped with backslash String[] subExpressions = compoundExpression.split("(?