From acc76cb20c186e9754c285eaf2a1aac0c8d8c8ed Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Sun, 21 Apr 2013 09:19:23 -0400 Subject: [PATCH] Adds some debug log statements for target filter --- .../com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java | 11 +++++++---- .../mkjsf/pazpar2/commands/SingleTargetFilter.java | 8 ++++++-- 2 files changed, 13 insertions(+), 6 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 749742e..5e4e07b 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -150,13 +150,14 @@ public class SearchCommand extends Pazpar2Command { if (hasSingleTargetFilter(new SingleTargetFilter(targetId,targetName))) { logger.debug("Already using target filter " + this.singleTargetFilter.getFilterExpression()); } else { + logger.debug("Setting new single target filter for [" + targetName + "]"); this.singleTargetFilter = new SingleTargetFilter(targetId,targetName); setParameter(new CommandParameter("filter","=",this.singleTargetFilter.getFilterExpression())); } } public SingleTargetFilter getSingleTargetFilter () { - logger.debug("request to get the current single target filter"); + logger.debug("request to get the current single target filter " + singleTargetFilter); return singleTargetFilter; } @@ -164,10 +165,11 @@ public class SearchCommand extends Pazpar2Command { * Removes the current target filter from the search * */ - public void removeSingleTargetFilter () { + public String removeSingleTargetFilter () { logger.debug("Removing target filter " + singleTargetFilter.getFilterExpression()); this.singleTargetFilter = null; - removeParameter("filter"); + removeParameter("filter"); + return null; } /** @@ -178,7 +180,7 @@ public class SearchCommand extends Pazpar2Command { logger.debug("Checking if a single target filter is set: " + (singleTargetFilter != null)); return singleTargetFilter != null; } - + /** * Resolves if the current search command has a target filter - to * be used by the UI for conditional rendering of target filter info. @@ -187,6 +189,7 @@ public class SearchCommand extends Pazpar2Command { * filter */ protected boolean hasSingleTargetFilter(SingleTargetFilter targetFilter) { + logger.debug("Checking if target filter for [" + targetFilter.getTargetName() + "] is set."); return hasSingleTargetFilter() && targetFilter.equals(this.singleTargetFilter); } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java index 4aea8a2..ef6303e 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java @@ -8,8 +8,8 @@ public class SingleTargetFilter implements Serializable { private static final long serialVersionUID = 2389085467202526537L; - private String targetName; - private String targetId; + private String targetName = ""; + private String targetId = ""; public SingleTargetFilter (String targetId, String targetName) { this.targetId = targetId; @@ -43,5 +43,9 @@ public class SingleTargetFilter implements Serializable { return (targetId+targetName).hashCode(); } + @Override + public String toString () { + return targetName + " (" + targetId + ")"; + } } -- 1.7.10.4