1 package com.indexdata.pz2utils4jsf.pazpar2;
\r
3 import java.io.Serializable;
\r
4 import java.util.List;
\r
6 import com.indexdata.pz2utils4jsf.controls.ResultsPager;
\r
7 import com.indexdata.pz2utils4jsf.errors.ErrorInterface;
\r
8 import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget;
\r
9 import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse;
\r
10 import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse;
\r
11 import com.indexdata.pz2utils4jsf.pazpar2.data.StatResponse;
\r
12 import com.indexdata.pz2utils4jsf.pazpar2.data.TermListsResponse;
\r
13 import com.indexdata.pz2utils4jsf.pazpar2.data.TermResponse;
\r
15 public interface Pz2Interface extends Serializable {
\r
18 * Executes a Pazpar2 search using the given query string
\r
22 public void doSearch(String query);
\r
25 * Executes a Pazpar2 search using the current query
\r
27 public void doSearch();
\r
30 * Updates display data objects by issuing the following pazpar2 commands:
\r
31 * 'show', 'stat', 'termlist' and 'bytarget'.
\r
33 * Returns a count of the remaining active clients from the most recent search.
\r
35 * After refreshing the data from pazpar2 the UI components displaying those
\r
36 * data should be re-rendered.
\r
38 * @return count of activeclients
\r
40 public String update();
\r
43 * Updates the data objects given by a comma separated list of one or more commands -
\r
44 * i.e. "show,state,termlist,bytarget".
\r
46 * May not be useful for the UI directly.
\r
48 * @param commands Command separated list of pazpar2 commands.
\r
49 * @return count of activeclients
\r
52 public String update (String commands);
\r
55 * Sets a query to used by the next search command
\r
57 * @param query a query on pazpar2 query syntax
\r
60 public void setQuery (String query);
\r
63 * Gets the current query
\r
64 * @return a pazpar2 query string
\r
66 public String getQuery ();
\r
69 * Sets a facet to limit the current query by,
\r
70 * then executes the search
\r
72 * @param facetKey i.e. 'au' for author
\r
73 * @param term i.e. 'Dickens, Charles'
\r
75 public void setFacet(String facetKey, String term);
\r
78 * Removes a facet set by setFacet(...), then executes
\r
81 * Will not remove facets set by setFacetOnQuery(...)
\r
83 * @param facetKey i.e. 'au' for author
\r
84 * @param term i.e. 'Dickens, Charles'
\r
86 public void removeFacet (String facetKey, String term);
\r
89 * Sets a facet to limit the current query by. The
\r
90 * facet is appended to the query string itself (rather
\r
91 * as a separately managed entity. It will thus appear
\r
92 * in a query field as retrieved by getQuery(). It will
\r
93 * not be removed by removeFacet(...)
\r
95 * @param facetKey i.e. 'au' for author
\r
96 * @param term i.e. 'Dickens, Charles'
\r
98 public void setFacetOnQuery(String facetKey, String term);
\r
101 * Adds a target filter to limit the current query by, then
\r
102 * executes the current search.
\r
104 * @param targetId pazpar2's ID for the target to limit by
\r
105 * @param targetName a descriptive name for the target
\r
107 public void setTargetFilter (String targetId, String targetName);
\r
110 * Removes the current target filter from the search
\r
113 public void removeTargetFilter ();
\r
117 * @return The target filter set on the current search command
\r
119 public TargetFilter getTargetFilter();
\r
122 * Resolves if the current search command has a target filter - to
\r
123 * be used by the UI for conditional rendering of target filter info.
\r
125 * @return true if the current search command is limited by a target
\r
128 public boolean hasTargetFilter();
\r
131 * Sets the ordering of records (hits) in the 'show' display object
\r
135 * Sets the sort order for results, the updates the 'show' data object
\r
136 * from pazpar2. Set valid sort options in the documentation for pazpar2.
\r
138 * The parts of the UI that display 'show' data should be rendered following
\r
141 * @param sortOption
\r
143 public void setSort(String sortOption);
\r
146 * Retrieves the current sort order for results
\r
147 * @return sort order - i.e. 'relevance'
\r
149 public String getSort();
\r
152 * Sets the number of records that pazpar2 should show at a time. Is
\r
153 * followed by an update of the show data object from pazpar2.
\r
155 * To be used by the UI for paging. After setting page size the parts
\r
156 * of the UI that displays 'show' data should be rendered.
\r
158 * @param perPageOption i.e. 10, default is 20.
\r
160 public void setPageSize (int perPageOption);
\r
163 * Retrieves the currently defined number of items to show at a time
\r
165 * @return number of result records that will be shown from pazpar2
\r
167 public int getPageSize();
\r
170 * Sets the first record to show - starting at record '0'. After setting
\r
171 * first record number, the 'show' data object will be updated from pazpar2,
\r
172 * and the parts of the UI displaying show data should be re-rendered.
\r
174 * To be used by the UI for paging.
\r
176 * @param start first record to show
\r
178 public void setStart (int start);
\r
181 * Retrieves the sequence number of the record that pazpaz2 will return as
\r
182 * the first record in 'show'
\r
184 * @return sequence number of the first record to be shown (numbering starting at '0')
\r
187 public int getStart();
\r
190 * Will retrieve or remove the record with the given recid from memory.
\r
192 * A pazpar2 'record' command will then be issued. The part of the UI
\r
193 * showing record data should thus be re-rendered.
\r
198 public String toggleRecord(String recid);
\r
201 * Returns the 'show' data as retrieved from pazpar2 by the most
\r
202 * recent update request
\r
204 * @return pazpar2 'show' response object
\r
206 public ShowResponse getShow();
\r
209 * Returns the 'stat' data as retrieved from pazpar2 by the most
\r
210 * recent update request
\r
212 * @return pazpar2 'stat' response object
\r
214 public StatResponse getStat();
\r
217 * Resolves whether the backend has a record with the given recid in memory
\r
219 * @return true if the bean currently holds the record with recid
\r
221 public boolean hasRecord (String recId);
\r
224 * Resolves whether the back-end has any records in memory (in 'show') for
\r
227 * @return true if there are records to display
\r
229 public boolean hasRecords ();
\r
232 * Returns a pazpar2 record as retrieved by the most recent 'record'
\r
234 * @return record data object
\r
236 public RecordResponse getRecord();
\r
239 * Returns a set of term lists (targets and facets) as retrieved by the
\r
240 * most recent 'termlist' command
\r
241 * @return set of termlists
\r
243 public TermListsResponse getTermLists ();
\r
246 * Returns up to 'count' terms from the facet given by the 'facet' parameter
\r
247 * @param facet name of the facet
\r
248 * @param count maximum number of facet terms to return
\r
249 * @return facet term list limited to 'count' terms
\r
251 public List<TermResponse> getFacetTerms (String facet, int count);
\r
254 * Returns all the terms of a given facet - or as many as pazpar2 returns
\r
255 * @param facet name of the facet
\r
256 * @return facet term list
\r
258 public List<TermResponse> getFacetTerms (String facet);
\r
261 * Returns a ByTarget data object as retrieved by the most recent 'bytarget'
\r
262 * request to pazpar2
\r
264 * @return ByTarget response data object
\r
266 public ByTarget getByTarget();
\r
269 * Initiates a pager object, a component holding the data to draw a sequence
\r
270 * of page numbers to navigate by and mechanisms to navigate with
\r
272 * @param pageRange number of pages to display in the pager
\r
273 * @return ResultsPager the initiated pager component
\r
275 public ResultsPager setPager(int pageRange);
\r
278 * Gives a component for drawing a pager to navigate by.
\r
279 * @return ResultsPager pager component
\r
281 public ResultsPager getPager();
\r
284 * Returns the current hash key used, as used for internal session state tracking
\r
285 * and potentially for browser history entries as well
\r
287 * A UI author would not normally be concerned with retrieving this. It's used by the
\r
288 * framework internally
\r
290 * @return string that can be used for browsers window.location.hash
\r
292 public String getCurrentStateKey ();
\r
295 * Sets the current state key, i.e. when user clicks back or forward in browser history.
\r
296 * Would normally be automatically handled by the frameworks components.
\r
298 * @param key corresponding to browsers hash string
\r
300 public void setCurrentStateKey(String key);
\r
303 * @return true if any errors encountered so far
\r
305 public boolean hasErrors();
\r
309 * @return true if errors encountered during execution of commands
\r
311 public boolean hasCommandErrors();
\r
315 * @return true if errors encountered when configuring the service
\r
317 public boolean hasConfigurationErrors();
\r
320 * Returns one (of possibly multiple) errors encountered during execution of commands
\r
321 * Will prefer to show the search errors - if any - as the search command is usually
\r
326 public ErrorInterface getCommandError();
\r
329 * Returns all errors encountered during configuration of the application, in particular
\r
330 * the Pazpar2 client.
\r
334 public List<ErrorInterface> getConfigurationErrors();
\r
336 void setRecordId(String recId);
\r
338 String getRecordId();
\r