From: Niels Erik G. Nielsen Date: Tue, 4 Jun 2013 10:11:05 +0000 (-0400) Subject: Clean-up X-Git-Tag: v0.0.7~64 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=f532c1d517d573a64accde31220e2ffbbb00354f;p=mkjsf-moved-to-github.git Clean-up Removes obsolete interface, obsolete class, obsolete methods --- diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Interface.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Interface.java deleted file mode 100644 index 2122743..0000000 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Interface.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.indexdata.mkjsf.pazpar2; - -import java.io.Serializable; - -import com.indexdata.mkjsf.controls.ResultsPager; - -public interface Pz2Interface extends Serializable { - - /** - * Executes a Pazpar2 search using the given query string - * - * @param query - */ - //public void doSearch(String query); - - /** - * Executes a Pazpar2 search using the current query - */ - // public void doSearch(); - - /** - * Executes a Pazpar2 record requests - * @return Active clients for the record request - */ - // public String doRecord(); - - /** - * Updates display data objects by issuing the following pazpar2 commands: - * 'show', 'stat', 'termlist' and 'bytarget'. - * - * Returns a count of the remaining active clients from the most recent search. - * - * After refreshing the data from pazpar2 the UI components displaying those - * data should be re-rendered. - * - * @return count of activeclients - */ - public String update(); - - /** - * Updates the data objects given by a comma separated list of one or more commands - - * i.e. "show,state,termlist,bytarget". - * - * May not be useful for the UI directly. - * - * @param commands Command separated list of pazpar2 commands. - * @return count of activeclients - * - */ - public String update (String commands); - - /** - * Will retrieve or remove the record with the given recid from memory. - * - * A pazpar2 'record' command will then be issued. The part of the UI - * showing record data should thus be re-rendered. - * - * @param recid - * @return - */ - public String toggleRecord(String recid); - - /** - * Resolves whether the backend has a record with the given recid in memory - * - * @return true if the bean currently holds the record with recid - */ - public boolean hasRecord (String recId); - - - /** - * Initiates a pager object, a component holding the data to draw a sequence - * of page numbers to navigate by and mechanisms to navigate with - * - * @param pageRange number of pages to display in the pager - * @return ResultsPager the initiated pager component - */ - public ResultsPager setPager(int pageRange); - - /** - * Gives a component for drawing a pager to navigate by. - * @return ResultsPager pager component - */ - public ResultsPager getPager(); - - /** - * Returns the current hash key used, as used for internal session state tracking - * and potentially for browser history entries as well - * - * A UI author would not normally be concerned with retrieving this. It's used by the - * framework internally - * - * @return string that can be used for browsers window.location.hash - */ - public String getCurrentStateKey (); - - /** - * Sets the current state key, i.e. when user clicks back or forward in browser history. - * Would normally be automatically handled by the frameworks components. - * - * @param key corresponding to browsers hash string - */ - public void setCurrentStateKey(String key); - - public boolean getAuthenticationRequired (); - - public String getCheckHistory (); - public String getWatchActiveclients (); - public String getWatchActiveclientsRecord (); - - public void setServiceTypePZ2 (); - public void setServiceTypeSP (); - public void setServiceTypeTBD (); - public void setServiceUrl(String url); - public String getServiceUrl(); - public String getServiceType(); - public boolean isPazpar2Service (); - public boolean isServiceProxyService(); - public boolean serviceIsToBeDecided (); - public SearchClient getSearchClient(); -} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java index f38d90d..9304475 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java @@ -28,17 +28,15 @@ import com.indexdata.mkjsf.errors.ConfigurationError; import com.indexdata.mkjsf.errors.ConfigurationException; import com.indexdata.mkjsf.errors.ErrorCentral; import com.indexdata.mkjsf.errors.ErrorHelper; -import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command; import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Commands; import com.indexdata.mkjsf.pazpar2.data.RecordResponse; -import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; import com.indexdata.mkjsf.pazpar2.data.Responses; import com.indexdata.mkjsf.pazpar2.state.StateListener; import com.indexdata.mkjsf.pazpar2.state.StateManager; import com.indexdata.mkjsf.utils.Utils; @Named("pz2") @SessionScoped -public class Pz2Service implements Pz2Interface, StateListener, Configurable, Serializable { +public class Pz2Service implements StateListener, Configurable, Serializable { private static final String MODULE_NAME = "service"; private static String SERVICE_TYPE_TBD = "TBD", SERVICE_TYPE_PZ2 = "PZ2", SERVICE_TYPE_SP = "SP"; @@ -145,12 +143,22 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se pzreq.getRecord().removeParametersInState(); pzreq.getSearch().removeParametersInState(); } - + + /** - * Refreshes 'show', 'stat', 'termlist', and 'bytarget' data object from pazpar2 + * Updates display data objects by issuing the following pazpar2 commands: + * 'show', 'stat', 'termlist' and 'bytarget'. * - * @return Number of activeclients at the time of the 'show' command. - */ + * If there is an outstanding change to the search command, a search + * will be issued before the updates are performed. + * + * Returns a count of the remaining active clients from the most recent search. + * + * After refreshing the data from pazpar2 the UI components displaying those + * data should be re-rendered. + * + * @return count of activeclients + */ public String update () { logger.debug("Updating show,stat,termlist,bytarget from pazpar2"); if (errors.hasConfigurationErrors()) { @@ -228,7 +236,17 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se } } - + + /** + * Will retrieve -- or alternatively remove -- the record with the given + * recid from memory. + * + * A pazpar2 'record' command will then be issued. The part of the UI + * showing record data should thus be re-rendered. + * + * @param recid + * @return + */ public String toggleRecord (String recId) { if (hasRecord(recId)) { pzreq.getRecord().removeParameters(); @@ -236,20 +254,40 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return ""; } else { pzreq.getRecord().setId(recId); - doCommand("record"); + pzreq.getRecord().run(); + // doCommand("record"); return pzresp.getRecord().getActiveClients(); } } - @Override + /** + * Resolves whether the backend has a record with the given recid in memory + * + * @return true if the bean currently holds the record with recid + */ public boolean hasRecord (String recId) { return pzreq.getCommand("record").hasParameters() && pzresp.getRecord().getRecId().equals(recId); } + /** + * Returns the current hash key, used for internal session state tracking + * and potentially for browser history entries + * + * A UI author would not normally be concerned with retrieving this. It's used by the + * framework internally + * + * @return string that can be used for browsers window.location.hash + */ public String getCurrentStateKey () { return stateMgr.getCurrentState().getKey(); } + /** + * Sets the current state key, i.e. when user clicks back or forward in browser history. + * Would normally be automatically handled by the frameworks components. + * + * @param key corresponding to browsers hash string + */ public void setCurrentStateKey(String key) { stateMgr.setCurrentStateKey(key); } @@ -258,8 +296,10 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return pzreq.getCommand("search").hasParameterValue("query"); } - - @Override + /** + * Returns a component for drawing a pager to navigate by. + * @return ResultsPager pager component + */ public ResultsPager getPager () { if (pager == null) { pager = new ResultsPager(pzresp); @@ -267,7 +307,13 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return pager; } - @Override + /** + * Initiates a pager object, a component holding the data to draw a sequence + * of page numbers to navigate by and mechanisms to navigate with + * + * @param pageRange number of pages to display in the pager + * @return ResultsPager the initiated pager component + */ public ResultsPager setPager (int pageRange) { pager = new ResultsPager(pzresp,pageRange,pzreq); return pager; @@ -304,6 +350,7 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se * @param commandName The command to be executed * @return An XML response parsed to form a response data object */ + /* protected ResponseDataObject doCommand(String commandName) { Pazpar2Command command = pzreq.getCommand(commandName); if (command.spOnly() && isPazpar2Service()) { @@ -318,6 +365,7 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return responseObject; } } + */ @Override public void stateUpdated(String commandName) { @@ -356,8 +404,6 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se } } - - @Override public void setServiceUrl(String url) { if (url!=null && searchClient != null && !url.equals(searchClient.getServiceUrl())) { pzreq.getRecord().removeParametersInState(); @@ -420,22 +466,18 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return spClient; } - @Override public boolean getAuthenticationRequired () { return spClient.isAuthenticatingClient(); } - @Override public String getCheckHistory () { return ":pz2watch:stateForm:windowlocationhash"; } - @Override public String getWatchActiveclients () { return ":pz2watch:activeclientsForm:activeclientsField"; } - @Override public String getWatchActiveclientsRecord () { return ":pz2watch:activeclientsForm:activeclientsFieldRecord"; } @@ -479,17 +521,14 @@ public class Pz2Service implements Pz2Interface, StateListener, Configurable, Se return new ArrayList(); } - @Override public void setServiceTypePZ2() { setServiceType(SERVICE_TYPE_PZ2); } - @Override public void setServiceTypeSP() { setServiceType(SERVICE_TYPE_SP); } - @Override public void setServiceTypeTBD() { setServiceType(SERVICE_TYPE_TBD); } diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java deleted file mode 100644 index ef6303e..0000000 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SingleTargetFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.indexdata.mkjsf.pazpar2.commands; - -import java.io.Serializable; - -import com.indexdata.mkjsf.pazpar2.commands.SingleTargetFilter; - -public class SingleTargetFilter implements Serializable { - - private static final long serialVersionUID = 2389085467202526537L; - - private String targetName = ""; - private String targetId = ""; - - public SingleTargetFilter (String targetId, String targetName) { - this.targetId = targetId; - this.targetName = targetName; - } - - public String getTargetName () { - return targetName; - } - - public String getTargetId () { - return targetId; - } - - public String getFilterExpression () { - return "pz:id="+targetId; - } - - @Override - public boolean equals(Object o) { - if (o instanceof SingleTargetFilter) { - return targetName.equals(((SingleTargetFilter) o).getTargetName()) && - targetId.equals(((SingleTargetFilter) o).getTargetId()); - } else { - return false; - } - } - - @Override - public int hashCode () { - return (targetId+targetName).hashCode(); - } - - @Override - public String toString () { - return targetName + " (" + targetId + ")"; - } - -} diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/state/Pazpar2State.java b/src/main/java/com/indexdata/mkjsf/pazpar2/state/Pazpar2State.java index b5b1d3e..50234e8 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/state/Pazpar2State.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/state/Pazpar2State.java @@ -81,7 +81,7 @@ public class Pazpar2State { } } } - key = "#"+querystatebuilder.toString(); + key = "#"+querystatebuilder.toString().hashCode(); return key; } else { return key;