Javadoc
authorNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 6 Jun 2013 01:30:52 +0000 (21:30 -0400)
committerNiels Erik G. Nielsen <nielserik@indexdata.com>
Thu, 6 Jun 2013 01:30:52 +0000 (21:30 -0400)
overview.html [new file with mode: 0644]
src/main/java/com/indexdata/mkjsf/pazpar2/Pz2Service.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/Pazpar2Commands.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/AuthCommand.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/CategoriesCommand.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/InitCommandSp.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/InitDocUpload.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/RecordCommandSp.java
src/main/java/com/indexdata/mkjsf/pazpar2/commands/sp/ServiceProxyCommands.java
src/main/java/com/indexdata/mkjsf/pazpar2/package-info.java [new file with mode: 0644]

diff --git a/overview.html b/overview.html
new file mode 100644 (file)
index 0000000..17f74dd
--- /dev/null
@@ -0,0 +1,5 @@
+<html>\r
+  <body>\r
+    Overview\r
+  </body>\r
+</html>
\ No newline at end of file
index 55c4f25..734d177 100644 (file)
@@ -36,6 +36,21 @@ import com.indexdata.mkjsf.pazpar2.state.StateListener;
 import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
+/**  \r
+ * Pz2Service is the main controller of the search logic, used for selecting the service \r
+ * type (which can be done by configuration and/or run-time), selecting which search client \r
+ * to use, and performing high-level control of request cycles and state management. \r
+ * <p>\r
+ * Command and response beans are also obtained through Pz2Service - although it is \r
+ * transparent to the UI that they are retrieved through this object.\r
+ * </p>\r
+ * <p>\r
+ * Pz2Service is exposed to the UI as 'pz2'. However, if the service is pre-configured, \r
+ * the Faces pages might never need to reference 'pz2' explicitly. Indirectly they UI will, \r
+ * though, if the polling mechanism in the tag &lt;pz2utils:pz2watch&gt; is used.\r
+ * \r
+ * \r
+ **/ \r
 @Named("pz2") @SessionScoped\r
 public class Pz2Service implements StateListener, Configurable, Serializable {\r
 \r
@@ -131,6 +146,16 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
     return stateMgr;\r
   }\r
   \r
+  /**\r
+   * Configures the selected search client using the selected configuration reader.\r
+   * \r
+   * The configuration reader is select deploy-time - by configuration in the application's beans.xml.\r
+   * \r
+   * @param client search client to use\r
+   * @param configReader the selected configuration mechanism\r
+   * @throws MissingConfigurationContextException if this object is injected before there is a Faces context\r
+   * for example in a Servlet filter.\r
+   */\r
   public void configureClient(SearchClient client, ConfigurationReader configReader)  throws MissingConfigurationContextException {\r
     logger.debug(Utils.objectId(this) + " will configure search client for the session");\r
     try {\r
@@ -153,18 +178,39 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
      \r
   \r
   /**\r
-   * Updates display data objects by issuing the following pazpar2 commands: \r
-   * 'show', 'stat', 'termlist' and 'bytarget'.\r
-   * \r
-   * If there is an outstanding change to the search command, a search\r
-   * will be issued before the updates are performed. \r
-   *  \r
-   * Returns a count of the remaining active clients from the most recent search.\r
-   * \r
-   * After refreshing the data from pazpar2 the UI components displaying those \r
-   * data should be re-rendered.\r
+   * Updates display data objects by simultaneously issuing the following pazpar2 commands: \r
+   * 'show', 'stat', 'termlist' and 'bytarget'. \r
+   * <p>\r
+   * If there are outstanding changes to the search command, a search\r
+   * will be issued before the updates are performed. Outstanding changes could come \r
+   * from the UI changing a search parameter and not executing search before starting \r
+   * the update cycle - OR - it could come from the user clicking the browsers back/forward\r
+   * buttons. \r
+   * </p>\r
+   * <p>\r
+   * This method is invoked from the composite 'pz2watch', which uses Ajax\r
+   * to keep invoking this method until it returns '0' (for zero active clients).\r
+   * </p>\r
+   * <p>\r
+   * UI components that display data from show, stat, termlist or bytarget, \r
+   * should be re-rendered after each update. \r
+   * </p>\r
+   * Example of invocation in UI:\r
+   * <pre>\r
+   *    &lt;pz2utils:pz2watch id="pz2watch"\r
+   *       renderWhileActiveclients="myshowui mystatui mytermsui" /&lt; \r
+   *       \r
+   *    &lt;h:form&gt;\r
+   *     &lt;h:inputText id="query" value="#{pzreq.search.query}" size="50"/&gt;                            \r
+   *      &lt;h:commandButton id="button" value="Search"&gt;              \r
+   *       &lt;f:ajax execute="query" render="${pz2.watchActiveclients}"/&gt;\r
+   *      &lt;/h:commandButton&gt;\r
+   *     &lt;/h:form&gt;\r
+   * </pre>\r
+   * The expression pz2.watchActiveClients will invoke the method repeatedly, and the\r
+   * UI sections myshowui, mystatui, and mytermsui will be rendered on each poll. \r
    * \r
-   * @return count of activeclients \r
+   * @return a count of the remaining active clients from the most recent search. \r
    */  \r
   public String update () {\r
     logger.debug("Updating show,stat,termlist,bytarget from pazpar2");\r
@@ -183,9 +229,11 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
   }\r
      \r
   /**\r
-   * Refreshes the data objects listed in 'commands' from pazpar2\r
+   * Simultaneously refreshes the data objects listed in 'commands' from pazpar2, potentially running a\r
+   * search or a record command first if any of these two commands have outstanding parameter changes.\r
+   * \r
+   * @param commands comma separated list of Pazpar2 commands to execute\r
    * \r
-   * @param commands\r
    * @return Number of activeclients at the time of the 'show' command,\r
    *         or 'new' if search was just initiated.\r
    */\r
@@ -254,6 +302,10 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
    * etc) this method checks if a search must be executed\r
    * before those updates are performed.\r
    *  \r
+   * It will consequently also run a search if the UI updates a\r
+   * search parameter without actually explicitly executing the search \r
+   * before setting of the polling.\r
+   *  \r
    * @see {@link com.indexdata.mkjsf.pazpar2.state.StateManager#setCurrentStateKey} \r
    * @param commands\r
    */\r
@@ -298,13 +350,12 @@ public class Pz2Service implements StateListener, Configurable, Serializable {
     } else {\r
       pzreq.getRecord().setId(recId);\r
       pzreq.getRecord().run();\r
-      // doCommand("record");\r
       return pzresp.getRecord().getActiveClients();\r
     }\r
   }\r
   \r
   /**\r
-   * Resolves whether the backend has a record with the given recid in memory \r
+   * Resolves whether the back-end has a record with the given recid in memory \r
    * \r
    * @return true if the bean currently holds the record with recid\r
    */  \r
index 67213e3..c9dc4c0 100644 (file)
@@ -11,6 +11,25 @@ import com.indexdata.mkjsf.pazpar2.Pz2Service;
 import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommands;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
+/**\r
+ * Pazpar2Commands holds references to all Pazpar2 commands. \r
+ * <p>\r
+ * The Pazpar2Commands object itself is exposed to the UI as 'pzreq'. \r
+ * </p>\r
+ * <p>\r
+ * When the UI request a command it will be retrieved from the current state\r
+ * through the state manager, so that the command can trigger a mutation of \r
+ * the state if the user/UI modifies its parameters. \r
+ * </p>\r
+ * Examples:\r
+ * <ul>\r
+ *  <li>pzreq.show    - will retrieve the show command for editing or execution\r
+ *  <li>pzreq.sp.auth - will retrieve the Service Proxy extension command 'auth'\r
+ * </ul>\r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 @SessionScoped @Named\r
 public class Pazpar2Commands implements Serializable {\r
 \r
@@ -31,52 +50,93 @@ public class Pazpar2Commands implements Serializable {
   public Pazpar2Commands() {\r
     logger.info("Initializing Pazpar2Commands [" + Utils.objectId(this) + "]");   \r
   }\r
-      \r
-  // public void setService(Pz2Service service) {\r
-  //   this.pz2 = service;\r
-  //  logger.info("Post construct Pazpar2Command: Service is " + pz2);    \r
-  // }\r
-      \r
+  \r
+  /**\r
+   * \r
+   * @return init command from current state\r
+   */\r
   public InitCommand getInit() {\r
     return (InitCommand) (Pz2Service.get().getStateMgr().getCommand(INIT));    \r
   }\r
     \r
+  /** \r
+   * \r
+   * @return ping command from current state \r
+   */\r
   public PingCommand getPing() {\r
     return (PingCommand) (Pz2Service.get().getStateMgr().getCommand(PING));\r
   }\r
   \r
+  /**\r
+   * \r
+   * @return settings command from current state\r
+   */\r
   public SettingsCommand getSettings() {\r
     return (SettingsCommand) (Pz2Service.get().getStateMgr().getCommand(SETTINGS));\r
   }\r
 \r
+  /**\r
+   * \r
+   * @return search command from current state\r
+   */\r
   public SearchCommand getSearch() {\r
     return (SearchCommand) (Pz2Service.get().getStateMgr().getCommand(SEARCH));\r
   }\r
   \r
+  /**\r
+   * \r
+   * @return stat command from current state\r
+   */\r
   public StatCommand getStat() {\r
     return (StatCommand) (Pz2Service.get().getStateMgr().getCommand(STAT));\r
   }\r
   \r
+  /**\r
+   * \r
+   * @return show command from current state\r
+   */\r
   public ShowCommand getShow() {\r
     return (ShowCommand) (Pz2Service.get().getStateMgr().getCommand(SHOW));\r
   }\r
     \r
+  /**\r
+   * \r
+   * @return record command from current state\r
+   */\r
   public RecordCommand getRecord() {\r
     return (RecordCommand) (Pz2Service.get().getStateMgr().getCommand(RECORD));\r
   }\r
 \r
+  /**\r
+   * \r
+   * @return termlist command from current state\r
+   */\r
   public TermlistCommand getTermlist() {\r
     return (TermlistCommand) (Pz2Service.get().getStateMgr().getCommand(TERMLIST));\r
   }\r
   \r
+  /**\r
+   * \r
+   * @return bytarget command from current state\r
+   */\r
   public BytargetCommand getBytarget() {\r
     return (BytargetCommand) (Pz2Service.get().getStateMgr().getCommand(BYTARGET));\r
   }\r
   \r
+  /**\r
+   * Generically retrieves any command\r
+   * \r
+   * @param name name of command to retrieve\r
+   * @return command of the given type\r
+   */\r
   public Pazpar2Command getCommand(String name) {    \r
     return Pz2Service.get().getStateMgr().getCommand(name);\r
   }\r
   \r
+  /**\r
+   * Gets the object holding references to Service Proxy-only commands.\r
+   * @return\r
+   */\r
   public ServiceProxyCommands getSp() {\r
     if (sp == null) {\r
       sp = new ServiceProxyCommands(Pz2Service.get().getStateMgr());\r
index 5013271..3167720 100644 (file)
@@ -9,6 +9,12 @@ import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;
 import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
 import com.indexdata.mkjsf.pazpar2.data.sp.SpResponseDataObject;\r
 \r
+/**\r
+ * Authenticates a user against a Pazpar2 Service Proxy\r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class AuthCommand extends Pazpar2Command implements ServiceProxyCommand {\r
 \r
   private static final long serialVersionUID = 5487611235664162578L;\r
index bccd65c..b3794ec 100644 (file)
@@ -6,6 +6,20 @@ import com.indexdata.mkjsf.pazpar2.Pz2Service;
 import com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command;\r
 import com.indexdata.mkjsf.pazpar2.data.sp.CategoriesResponse;\r
 \r
+/**\r
+ * Retrieves target categories available to the current Service Proxy user.\r
+ * <p>\r
+ * Target categories can be used to limit a search to resources tagged with the given \r
+ * category. The following request in a Faces page would obtain categories for displaying, say, a select list:\r
+ * <p>\r
+ *  pzreq.sp.categories.run().targetCategories   \r
+ * <p>\r
+ * This would get the Service Proxy extension commands, pick the categories command, execute it, and retrieve\r
+ *  a list of TargetCategory objects from the returned response data object.  \r
+ * </p>\r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class CategoriesCommand extends Pazpar2Command implements ServiceProxyCommand {\r
 \r
   private static final long serialVersionUID = 5023993689780291641L;\r
index 629c07c..dba12b0 100644 (file)
@@ -15,6 +15,14 @@ import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;
 import com.indexdata.mkjsf.pazpar2.data.ResponseParser;\r
 import com.indexdata.mkjsf.pazpar2.data.sp.SpResponseDataObject;\r
 \r
+/**\r
+ * Service Proxy extensions to the init command - specifically \r
+ * support for POSTing to the Service Proxy an init doc containing Pazpar2 \r
+ * definitions and settings. \r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class InitCommandSp implements Serializable, ServiceProxyCommand {\r
 \r
   private static final long serialVersionUID = -6609045941782375651L;\r
index 1d0b90f..1d3d228 100644 (file)
@@ -11,6 +11,12 @@ import org.apache.myfaces.custom.fileupload.UploadedFile;
 import com.indexdata.mkjsf.utils.FileUpload;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
+/**\r
+ * Helper class for file upload of an Service Proxy init doc.\r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 @Named\r
 @SessionScoped\r
 public class InitDocUpload extends FileUpload {\r
index 0662df1..1d7cfc8 100644 (file)
@@ -5,6 +5,12 @@ import java.io.Serializable;
 import com.indexdata.mkjsf.pazpar2.commands.CommandParameter;\r
 import com.indexdata.mkjsf.pazpar2.commands.RecordCommand;\r
 \r
+/**\r
+ * Service Proxy extensions to the record command. \r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class RecordCommandSp  implements Serializable, ServiceProxyCommand {\r
 \r
   private static final long serialVersionUID = -3901864271733337221L;\r
index 8c4fefa..8c34260 100644 (file)
@@ -7,6 +7,13 @@ import org.apache.log4j.Logger;
 import com.indexdata.mkjsf.pazpar2.state.StateManager;\r
 import com.indexdata.mkjsf.utils.Utils;\r
 \r
+/**\r
+ * ServiceProxyCommands holds references to all commands that are \r
+ * Service Proxy-only, that is, not supported by straight Pazpar2.\r
+ * \r
+ * @author Niels Erik\r
+ *\r
+ */\r
 public class ServiceProxyCommands implements Serializable {\r
 \r
   public static final String AUTH = "auth";\r
diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/package-info.java b/src/main/java/com/indexdata/mkjsf/pazpar2/package-info.java
new file mode 100644 (file)
index 0000000..640b810
--- /dev/null
@@ -0,0 +1,9 @@
+/**\r
+ * Overall control and execution of search logic. \r
+ * <p>\r
+ * Classes in this package selects a service type and controls and performs \r
+ * the actual execution of commands against the selected service, eventually producing  \r
+ * ClientCommandResponses for further processing elsewhere.  \r
+ * </p>    \r
+ */\r
+package com.indexdata.mkjsf.pazpar2;
\ No newline at end of file