org.hd.d.pg2k.webSvr.catalogue
Class SearchPageJavaBean

java.lang.Object
  extended by org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
      extended by org.hd.d.pg2k.webSvr.catalogue.SearchPageJavaBean
All Implemented Interfaces:
java.io.Serializable

public final class SearchPageJavaBean
extends ExhibitHandlerBeanBase

This is the JavaBean that backs the (HTML) catalogue search page. This should be held at page scope so that its state is set from fresh on each page load.

This attempts to sanitise values as they are set.

Most methods are synchronized to provide thread-safety.

See Also:
Serialized Form

Field Summary
static int DAY_MS
          How long in milliseconds we consider a day to be.
static java.util.SortedMap<java.lang.Integer,java.lang.String> daysFilterSym
          Sorted map from number of days back to symbolic name if any (Integer to String).
private  long lastSearchTimeMs
          Last search time in ms, -1 if no search yet done.
static int MAX_GET_QUERY_CHARS
          Maximum (UTF-8 URL-encoded) GET-style query string that we will generate; strictly positive.
private  java.lang.String q
          The sanitised simple text query, or "" if none.
private  int recentDaysFilter
          The number of recent days to filter for; 0 means no filter.
private static long serialVersionUID
          Unique Serialisation class ID generated by http://random.hd.org/.
static java.util.Map<java.lang.String,java.lang.Integer> symFilterDays
          Map from symbolic filter period to number of days (String to Integer); immutable.
 
Fields inherited from class org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
onlyAllowExtant, SETTER_ALL
 
Constructor Summary
SearchPageJavaBean()
           
 
Method Summary
 java.lang.String computeGETQueryStringURLTail(int pg)
          Make simple (length-limited) GET query string.
 java.util.List<Name.ExhibitFull> doLookup(DataSourceBean dataSource, int maxResults)
          Get search results as immutable list of full exhibit names; may be zero-length but never null.
 long getLastSearchTimeMs()
          Gets the last search time in ms, -1 if no search yet done.
 java.lang.String getQ()
          Get the sanitised query text, or "" if none (never null, never longer than WebConsts.MAX_SIMPLE_QUERY_LEN).
 int getRecentDaysFilter()
          Get the "recent days" filter period; 0 for none else (positive) number of days.
 ORG.hd.d.jIndexer.server.JIndexBean.SearchFilterByName getSearchFilter()
          Gets the search filter, or null if none.
 java.lang.String makeRecentDaysFilterBody(LocaleBeanBase l)
          Generates body of recent-days filter select statement (dependent on old value, if any).
 void setQ(java.lang.String rawQueryText)
          Sets the simple query, or "" if none.
 void setRecentDaysFilter(java.lang.String sRecentDaysFilter)
          Set the recent period (to today) for which exhibits are wanted.
 
Methods inherited from class org.hd.d.pg2k.svrCore.uploader.ExhibitHandlerBeanBase
dedupAttrs, getAep, getAllAuthors, getAllCategories, getAllSuffixes, getAttributeWords, getAttributeWordsAsList, getAuthor, getCategory, getInUseAttrWordListAsString, getLegalAttrWordListAsString, getSuffix, makeAttributeSelectBody, makeAttributeSelectBody, makeAuthorSelectBody, makeCategorySelectBody, makeCategorySelectBody, makeSuffixSelectBody, setAep, setAttributeWords, setAttributeWords, setAttributeWords, setAuthor, setCategory, setCommonValuesForUnsetFields, setSuffix
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

q

private java.lang.String q
The sanitised simple text query, or "" if none.


DAY_MS

public static final int DAY_MS
How long in milliseconds we consider a day to be.

See Also:
Constant Field Values

recentDaysFilter

private int recentDaysFilter
The number of recent days to filter for; 0 means no filter.


symFilterDays

public static final java.util.Map<java.lang.String,java.lang.Integer> symFilterDays
Map from symbolic filter period to number of days (String to Integer); immutable. Keys in here can also be suffixed to common i18n resource "common.cat.filtersince.recent." to get descriptive text.


daysFilterSym

public static final java.util.SortedMap<java.lang.Integer,java.lang.String> daysFilterSym
Sorted map from number of days back to symbolic name if any (Integer to String).


MAX_GET_QUERY_CHARS

public static final int MAX_GET_QUERY_CHARS
Maximum (UTF-8 URL-encoded) GET-style query string that we will generate; strictly positive. We base this on the maximum simple query text length that we support.

See Also:
Constant Field Values

lastSearchTimeMs

private long lastSearchTimeMs
Last search time in ms, -1 if no search yet done.


serialVersionUID

private static final long serialVersionUID
Unique Serialisation class ID generated by http://random.hd.org/.

See Also:
Constant Field Values
Constructor Detail

SearchPageJavaBean

public SearchPageJavaBean()
Method Detail

setQ

public void setQ(java.lang.String rawQueryText)
Sets the simple query, or "" if none. This truncates and canonicalises and sanitises the query text as necessary.


getQ

public java.lang.String getQ()
Get the sanitised query text, or "" if none (never null, never longer than WebConsts.MAX_SIMPLE_QUERY_LEN).


setRecentDaysFilter

public void setRecentDaysFilter(java.lang.String sRecentDaysFilter)
Set the recent period (to today) for which exhibits are wanted. The parameter can either be one of the single letter keys in symFilterDays, or null or "" or "-" (SETTER_ALL) or "0" for no filter, or a positive Integer number of days.


getRecentDaysFilter

public int getRecentDaysFilter()
Get the "recent days" filter period; 0 for none else (positive) number of days.


makeRecentDaysFilterBody

public java.lang.String makeRecentDaysFilterBody(LocaleBeanBase l)
Generates body of recent-days filter select statement (dependent on old value, if any). Assumed not to require localisation or internationalisation.

This takes the symbolic values in increasing number of days. If the locale bean is passed in this makes full labels else it makes none.


getSearchFilter

public ORG.hd.d.jIndexer.server.JIndexBean.SearchFilterByName getSearchFilter()
Gets the search filter, or null if none. Note that we expect short exhibit names to be presented to these filters, as that is what is stored in the index.


doLookup

public java.util.List<Name.ExhibitFull> doLookup(DataSourceBean dataSource,
                                                 int maxResults)
                                          throws java.io.IOException
Get search results as immutable list of full exhibit names; may be zero-length but never null. Using the query string and other details that the user has supplied this does the search and returns a (possibly-zero-length) list of exhibit names.

As a side-effect this sets the time the search takes in milliseconds accessible by getLastSearchTimeMs().

Parameters:
maxResults - maximum length list of results to return; should be positive
Throws:
java.io.IOException

computeGETQueryStringURLTail

public java.lang.String computeGETQueryStringURLTail(int pg)
Make simple (length-limited) GET query string. Can be used where POST is not possible or desirable.

Takes an optional (positive) page number argument.

This is UTF-8 encoded.

Parameter are separated with &amp; ready for direct inclusion at the end of a URL.

If the result is getting too long we stop adding fields, so we encode the more critical ones first.

Parameters:
pg - if positive then the pg (page) parameter is included
Returns:
non-empty result starting with '?' suitably encoded to drop into an [X]HTML attribute value at the end of a URL

getLastSearchTimeMs

public long getLastSearchTimeMs()
Gets the last search time in ms, -1 if no search yet done.


DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.