--- /dev/null
+package com.indexdata.pz2utils4jsf.pazpar2;\r
+\r
+import java.util.List;\r
+\r
+import com.indexdata.pz2utils4jsf.controls.ResultsPager;\r
+import com.indexdata.pz2utils4jsf.pazpar2.TargetFilter;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.StatResponse;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.TermListsResponse;\r
+import com.indexdata.pz2utils4jsf.pazpar2.data.TermResponse;\r
+\r
+public interface Pz2Interface {\r
+\r
+ /**\r
+ * Executes a Pazpar2 search using the given query string\r
+ * \r
+ * @param query\r
+ */\r
+ public void doSearch(String query);\r
+ \r
+ /**\r
+ * Executes a Pazpar2 search using the current query \r
+ */\r
+ public void doSearch();\r
+ \r
+ /**\r
+ * Updates display data objects by issuing the following pazpar2 commands: \r
+ * 'show', 'stat', 'termlist' and 'bytarget'.\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
+ * \r
+ * @return count of activeclients \r
+ */\r
+ public String update();\r
+ \r
+ /**\r
+ * Updates the data objects given by a comma separated list of one or more commands - \r
+ * i.e. "show,state,termlist,bytarget".\r
+ * \r
+ * May not be useful for the UI directly. \r
+ * \r
+ * @param commands Command separated list of pazpar2 commands.\r
+ * @return count of activeclients \r
+ * \r
+ */\r
+ public String update (String commands);\r
+ \r
+ /**\r
+ * Sets a query to used by the next search command\r
+ * \r
+ * @param query a query on pazpar2 query syntax\r
+ * \r
+ */\r
+ public void setQuery (String query);\r
+ \r
+ /**\r
+ * Gets the current query \r
+ * @return a pazpar2 query string\r
+ */\r
+ public String getQuery ();\r
+ \r
+ /**\r
+ * Sets a facet to limit the current query by,\r
+ * then executes the search \r
+ * \r
+ * @param facetKey i.e. 'au' for author\r
+ * @param term i.e. 'Dickens, Charles'\r
+ */\r
+ public void setFacet(String facetKey, String term);\r
+ \r
+ /**\r
+ * Removes a facet set by setFacet(...), then executes\r
+ * the search.\r
+ * \r
+ * Will not remove facets set by setFacetOnQuery(...)\r
+ * \r
+ * @param facetKey i.e. 'au' for author\r
+ * @param term i.e. 'Dickens, Charles'\r
+ */\r
+ public void removeFacet (String facetKey, String term);\r
+ \r
+ /**\r
+ * Sets a facet to limit the current query by. The \r
+ * facet is appended to the query string itself (rather\r
+ * as a separately managed entity. It will thus appear\r
+ * in a query field as retrieved by getQuery(). It will\r
+ * not be removed by removeFacet(...)\r
+ * \r
+ * @param facetKey i.e. 'au' for author\r
+ * @param term i.e. 'Dickens, Charles'\r
+ */\r
+ public void setFacetOnQuery(String facetKey, String term);\r
+ \r
+ /**\r
+ * Adds a target filter to limit the current query by, then\r
+ * executes the current search.\r
+ * \r
+ * @param targetId pazpar2's ID for the target to limit by\r
+ * @param targetName a descriptive name for the target\r
+ */\r
+ public void setTargetFilter (String targetId, String targetName);\r
+ \r
+ /**\r
+ * Removes the current target filter from the search\r
+ * \r
+ */\r
+ public void removeTargetFilter ();\r
+ \r
+ /**\r
+ * \r
+ * @return The target filter set on the current search command\r
+ */\r
+ public TargetFilter getTargetFilter();\r
+ \r
+ /**\r
+ * Resolves if the current search command has a target filter - to\r
+ * be used by the UI for conditional rendering of target filter info.\r
+ * \r
+ * @return true if the current search command is limited by a target \r
+ * filter\r
+ */\r
+ public boolean hasTargetFilter();\r
+ \r
+ /**\r
+ * Sets the ordering of records (hits) in the 'show' display object\r
+ */\r
+ \r
+ /**\r
+ * Sets the sort order for results, the updates the 'show' data object\r
+ * from pazpar2. Set valid sort options in the documentation for pazpar2.\r
+ * \r
+ * The parts of the UI that display 'show' data should be rendered following\r
+ * this request.\r
+ * \r
+ * @param sortOption\r
+ */\r
+ public void setSort(String sortOption);\r
+ \r
+ /**\r
+ * Retrieves the current sort order for results\r
+ * @return sort order - i.e. 'relevance'\r
+ */\r
+ public String getSort();\r
+ \r
+ /**\r
+ * Sets the number of records that pazpar2 should show at a time. Is \r
+ * followed by an update of the show data object from pazpar2. \r
+ * \r
+ * To be used by the UI for paging. After setting page size the parts\r
+ * of the UI that displays 'show' data should be rendered. \r
+ * \r
+ * @param perPageOption i.e. 10, default is 20.\r
+ */\r
+ public void setPageSize (int perPageOption);\r
+ \r
+ /**\r
+ * Retrieves the currently defined number of items to show at a time\r
+ * \r
+ * @return number of result records that will be shown from pazpar2\r
+ */\r
+ public int getPageSize();\r
+ \r
+ /**\r
+ * Sets the first record to show - starting at record '0'. After setting\r
+ * first record number, the 'show' data object will be updated from pazpar2,\r
+ * and the parts of the UI displaying show data should be re-rendered.\r
+ * \r
+ * To be used by the UI for paging.\r
+ * \r
+ * @param start first record to show\r
+ */\r
+ public void setStart (int start);\r
+ \r
+ /**\r
+ * Retrieves the sequence number of the record that pazpaz2 will return as\r
+ * the first record in 'show'\r
+ * \r
+ * @return sequence number of the first record to be shown (numbering starting at '0')\r
+ * \r
+ */\r
+ public int getStart();\r
+ \r
+ /**\r
+ * Will retrieve or remove the record with the given recid from memory.\r
+ * \r
+ * A pazpar2 'record' command will then be issued. The part of the UI \r
+ * showing record data should thus be re-rendered.\r
+ * \r
+ * @param recid\r
+ * @return\r
+ */\r
+ public String toggleRecord(String recid);\r
+ \r
+ /**\r
+ * Returns the 'show' data as retrieved from pazpar2 by the most \r
+ * recent update request\r
+ * \r
+ * @return pazpar2 'show' response object\r
+ */\r
+ public ShowResponse getShow();\r
+ \r
+ /**\r
+ * Returns the 'stat' data as retrieved from pazpar2 by the most \r
+ * recent update request\r
+ * \r
+ * @return pazpar2 'stat' response object\r
+ */\r
+ public StatResponse getStat();\r
+ \r
+ /**\r
+ * Resolves whether the backend has a record with the given recid in memory \r
+ * \r
+ * @return true if the bean currently holds the record with recid\r
+ */ \r
+ public boolean hasRecord (String recId);\r
+ \r
+ /**\r
+ * Resolves whether the back-end has any records in memory (in 'show') for \r
+ * display in UI\r
+ * \r
+ * @return true if there are records to display\r
+ */\r
+ public boolean hasRecords ();\r
+ \r
+ /**\r
+ * Returns a pazpar2 record as retrieved by the most recent 'record'\r
+ * request \r
+ * @return record data object\r
+ */\r
+ public RecordResponse getRecord();\r
+ \r
+ /**\r
+ * Returns a set of term lists (targets and facets) as retrieved by the \r
+ * most recent 'termlist' command \r
+ * @return set of termlists\r
+ */\r
+ public TermListsResponse getTermLists ();\r
+ \r
+ /**\r
+ * Returns up to 'count' terms from the facet given by the 'facet' parameter\r
+ * @param facet name of the facet\r
+ * @param count maximum number of facet terms to return\r
+ * @return facet term list limited to 'count' terms\r
+ */\r
+ public List<TermResponse> getFacetTerms (String facet, int count);\r
+ \r
+ /**\r
+ * Returns all the terms of a given facet - or as many as pazpar2 returns\r
+ * @param facet name of the facet\r
+ * @return facet term list\r
+ */\r
+ public List<TermResponse> getFacetTerms (String facet);\r
+ \r
+ /**\r
+ * Returns a ByTarget data object as retrieved by the most recent 'bytarget' \r
+ * request to pazpar2\r
+ * \r
+ * @return ByTarget response data object\r
+ */\r
+ public ByTarget getByTarget();\r
+ \r
+ /**\r
+ * Initiates a pager object, a component holding the data to draw a sequence\r
+ * of page numbers to navigate by and mechanisms to navigate with\r
+ * \r
+ * @param pageRange number of pages to display in the pager\r
+ * @return ResultsPager the initiated pager component\r
+ */\r
+ public ResultsPager setPager(int pageRange);\r
+ \r
+ /**\r
+ * Gives a component for drawing a pager to navigate by.\r
+ * @return ResultsPager pager component\r
+ */\r
+ public ResultsPager getPager();\r
+ \r
+ /**\r
+ * Returns the current hash key used, as used for internal session state tracking\r
+ * and potentially for browser history entries as well\r
+ * \r
+ * A UI author would not normally be concerned with retrieving this. It's used by the\r
+ * framework internally\r
+ * \r
+ * @return string that can be used for browsers window.location.hash\r
+ */\r
+ public String getCurrentStateKey ();\r
+ \r
+ /**\r
+ * Sets the current state key, i.e. when user clicks back or forward in browser history.\r
+ * Would normally be automatically handled by the frameworks components.\r
+ * \r
+ * @param key corresponding to browsers hash string\r
+ */\r
+ public void setCurrentStateKey(String key);\r
+}\r