1 package com.indexdata.pz2utils4jsf.pazpar2.commands;
\r
3 import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager;
\r
5 public class ShowCommand extends Pazpar2Command {
\r
7 private static final long serialVersionUID = -8242768313266051307L;
\r
9 public ShowCommand(StateManager stateMgr) {
\r
10 super("show",stateMgr);
\r
14 * Sets the sort order for results, the updates the 'show' data object
\r
15 * from pazpar2. Set valid sort options in the documentation for pazpar2.
\r
17 * The parts of the UI that display 'show' data should be rendered following
\r
22 public void setSort (String sort) {
\r
23 setParameter(new CommandParameter("sort","=",sort));
\r
27 * Retrieves the current sort order for results
\r
28 * @return sort order - i.e. 'relevance'
\r
30 public String getSort () {
\r
31 return getParameter("sort") != null ? getParameter("sort").value : "relevance";
\r
35 * Sets the number of records that pazpar2 should show at a time. Is
\r
36 * followed by an update of the show data object from pazpar2.
\r
38 * To be used by the UI for paging. After setting page size the parts
\r
39 * of the UI that displays 'show' data should be rendered.
\r
41 * @param perPageOption i.e. 10, default is 20.
\r
43 public void setPageSize (String perPageOption) {
\r
44 setParameters(new CommandParameter("num","=",perPageOption),
\r
45 new CommandParameter("start","=",0));
\r
49 * Retrieves the currently defined number of items to show at a time
\r
51 * @return number of result records that will be shown from pazpar2
\r
53 public String getPageSize () {
\r
54 return getParameter("num") != null ? getParameter("num").value : "20";
\r
58 * Sets the first record to show - starting at record '0'. After setting
\r
59 * first record number, the 'show' data object will be updated from pazpar2,
\r
60 * and the parts of the UI displaying show data should be re-rendered.
\r
62 * To be used by the UI for paging.
\r
64 * @param start first record to show
\r
66 public void setStart (int start) {
\r
67 setParameter(new CommandParameter("start","=",start));
\r
71 * Retrieves the sequence number of the record that pazpaz2 will return as
\r
72 * the first record in 'show'
\r
74 * @return sequence number of the first record to be shown (numbering starting at '0')
\r
77 public int getStart() {
\r
78 return getParameter("start") != null ? Integer.parseInt(getParameter("start").value) : 0;
\r
82 public ShowCommand copy () {
\r
83 ShowCommand newCommand = new ShowCommand(stateMgr);
\r
84 for (String parameterName : parameters.keySet()) {
\r
85 newCommand.setParameterSilently(parameters.get(parameterName).copy());
\r