From 5dcafe1f0187979293b507278c7139ae7e5dc7ac Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Fri, 29 Mar 2013 18:27:24 -0700 Subject: [PATCH] Ammends record command logic --- .../indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java | 12 ++++++++++- .../pz2utils4jsf/pazpar2/Pz2Interface.java | 4 ++++ .../indexdata/pz2utils4jsf/pazpar2/Pz2Session.java | 22 +++++++++++++------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java index 7f3ae52..277876b 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -181,7 +181,7 @@ public class Pz2Bean implements Pz2Interface, Serializable { public int getStart() { return pz2.getStart(); } - + /* (non-Javadoc) * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#toggleRecord(java.lang.String) */ @@ -302,4 +302,14 @@ public class Pz2Bean implements Pz2Interface, Serializable { 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 55a5a3a..ef820da 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Interface.java @@ -332,5 +332,9 @@ public interface Pz2Interface extends Serializable { * @return */ 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 3dec233..e0b7ea7 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Session.java @@ -62,8 +62,7 @@ public class Pz2Session implements Pz2Interface { // To avoid that, a context free client is cloned from the context // dependent one. // If propagation to threads gets supported, the cloning can go. - this.searchClient = searchClient.cloneMe(); - + this.searchClient = searchClient.cloneMe(); } catch (ConfigurationException e) { configurationErrors.add(new ConfigurationError("Search Client","Configuration",e.getMessage(),new ErrorHelper(configReader))); } @@ -228,22 +227,29 @@ public class Pz2Session implements Pz2Interface { public int getStart() { return getCommandParameterValue("show","start",0); } - + public String toggleRecord (String recId) { if (hasRecord(recId)) { removeCommand("record"); dataObjects.put("record", new RecordResponse()); return ""; } else { - return updateRecord(recId); + setRecordId(recId); + return doCommand("record"); } } - private String updateRecord(String recId) { - setCommandParameter("record",new CommandParameter("id","=",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 getCommand("record").hasParameters() && getRecord().getRecId().equals(recId); } @@ -375,7 +381,7 @@ public class Pz2Session implements Pz2Interface { logger.debug("Found pending record ID change. Doing record before updating " + commands); queryStates.hasPendingStateChange("record",false); if (getCommand("record").hasParameters()) { - updateRecord(getCommand("record").getParameter("id").getSimpleValue()); + update("record"); } else { removeCommand("record"); dataObjects.put("record", new RecordResponse()); -- 1.7.10.4