From: Niels Erik G. Nielsen Date: Sat, 13 Apr 2013 18:41:29 +0000 (-0400) Subject: Moves record parameter settings from pz2 bean to record cmd X-Git-Tag: v0.0.7~171 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=ef76a342d67b814bea4ca54de78000d540e879a8;p=mkjsf-moved-to-github.git Moves record parameter settings from pz2 bean to record cmd --- diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java index 00d587a..fe63d6e 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -234,15 +234,5 @@ public class Pz2Bean implements Pz2Interface, Serializable { public boolean hasConfigurationErrors() { return pz2.hasConfigurationErrors(); } - - @Override - public void setRecordId(String recId) { - pz2.setRecordId(recId); - } - - @Override - public String getRecordId() { - return pz2.getRecordId(); - } } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java index 8cba18a..d33b114 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java @@ -238,8 +238,5 @@ public interface Pz2Interface extends Serializable { */ public List getConfigurationErrors(); - void setRecordId(String recId); - - String getRecordId(); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java index 56aa95b..654f3c8 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java @@ -21,7 +21,6 @@ import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandParameter; import com.indexdata.pz2utils4jsf.pazpar2.commands.CommandReadOnly; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Command; import com.indexdata.pz2utils4jsf.pazpar2.commands.Pazpar2Commands; -import com.indexdata.pz2utils4jsf.pazpar2.commands.SearchCommand; import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget; import com.indexdata.pz2utils4jsf.pazpar2.data.CommandError; import com.indexdata.pz2utils4jsf.pazpar2.data.Pazpar2ResponseData; @@ -160,43 +159,7 @@ public class Pz2Session implements Pz2Interface, StateListener { } } - - /* - public void setQuery (String query) { - logger.debug("Creating new command parameter for " + query); - setCommandParameter("search",new CommandParameter("query","=",query)); - } - - public String getQuery () { - return getCommandParameterValueSimple("search","query",null); - } - */ - - public void setFacet (String facetKey, String term) { - if (term != null && term.length()>0) { - Pazpar2Command command = req.getCommand("search"); - command.getParameter("query").addExpression(new Expression(facetKey,"=",term)); - stateMgr.checkIn(command); - doSearch(); - } - } - - public void setFacetOnQuery (String facetKey, String term) { - String facetExpression = facetKey + "=" + term; - if (term != null && term.length()>0) { - String currentQuery= req.getCommandReadOnly("search").getParameterValue("query"); - setCommandParameter("search",new CommandParameter("query","=", currentQuery + " and " + facetExpression)); - doSearch(); - } - } - - public void removeFacet(String facetKey, String term) { - SearchCommand command = req.getSearch(); - command.getParameter("query").removeExpression(new Expression(facetKey,"=",term)); - stateMgr.checkIn(command); - doSearch(); - } - + public void setSingleTargetFilter (String targetId, String targetName) { if (hasSingleTargetFilter(new SingleTargetFilter(targetId,targetName))) { logger.debug("Already using target filter " + this.singleTargetFilter.getFilterExpression()); @@ -228,22 +191,12 @@ public class Pz2Session implements Pz2Interface, StateListener { dataObjects.put("record", new RecordResponse()); return ""; } else { - setRecordId(recId); + req.getRecord().setRecordId(recId); return doCommand("record"); } } @Override - public void setRecordId(String recId) { - setCommandParameter("record",new CommandParameter("id","=",recId)); - } - - @Override - public String getRecordId () { - return getCommandParameterValue("record","recid",""); - } - - @Override public boolean hasRecord (String recId) { return req.getCommandReadOnly("record").hasParameters() && getRecord().getRecId().equals(recId); } @@ -499,12 +452,12 @@ public class Pz2Session implements Pz2Interface, StateListener { } @Override - public void stateUpdate(String commandName) { + public void stateUpdated(String commandName) { logger.debug("State change reported for [" + commandName + "]"); if (commandName.equals("show")) { logger.debug("Updating show"); update(commandName); - } + } } } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/RecordCommand.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/RecordCommand.java index aa44fb9..086cfa8 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/RecordCommand.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/commands/RecordCommand.java @@ -9,5 +9,24 @@ public class RecordCommand extends Pazpar2Command { public RecordCommand(StateManager stateMgr) { super("record",stateMgr); } + + public void setRecordId(String recId) { + setParameter(new CommandParameter("id","=",recId)); + } + + public String getRecordId () { + return getParameterValue("id"); + } + + @Override + public RecordCommand copy () { + RecordCommand newCommand = new RecordCommand(stateMgr); + for (String parameterName : parameters.keySet()) { + newCommand.setParameterSilently(parameters.get(parameterName).copy()); + } + return newCommand; + } + + } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateListener.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateListener.java index 05fd5db..ac7fe8b 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateListener.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateListener.java @@ -2,6 +2,6 @@ package com.indexdata.pz2utils4jsf.pazpar2.state; public interface StateListener { - public void stateUpdate(String commandName); + public void stateUpdated(String commandName); } diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java index 4398efa..618d880 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/state/StateManager.java @@ -47,7 +47,7 @@ public class StateManager implements Serializable { private void updateListeners (String command) { for (StateListener lsnr : listeners) { - lsnr.stateUpdate(command); + lsnr.stateUpdated(command); } } @@ -69,7 +69,9 @@ public class StateManager implements Serializable { Pazpar2State state = new Pazpar2State(getCurrentState(),command); states.put(state.getKey(), state); currentKey = state.getKey(); - hasPendingStateChange(command.getName(),new Boolean(true)); + hasPendingStateChange(command.getName(),new Boolean(true)); + logger.debug("Updating listeners with state change from " + command); + updateListeners(command.getName()); } else { logger.debug("Command " + command.getName() + " not found to change the state [" + command.getEncodedQueryString() + "]"); } @@ -132,10 +134,6 @@ public class StateManager implements Serializable { */ public void hasPendingStateChange(String command, boolean bool) { pendingStateChanges.put(command, new Boolean(bool)); - if (bool) { - logger.debug("Updating listeners with state change from " + command); - updateListeners(command); - } } /**