@Named(value="pz2") @SessionScoped public class Pz2Service extends java.lang.Object implements StateListener, Configurable, java.io.Serializable
Command and response beans are also obtained through Pz2Service - although it is transparent to the UI that they are retrieved through this object.
Pz2Service is exposed to the UI as pz2
. However, if the service is pre-configured,
the Faces pages might never need to reference pz2
explicitly. Indirectly they will,
though, if the polling mechanism in the tag <pz2utils:pz2watch>
is used.
When configuring the client using the Mk2Config scheme, this is the prefix to use in the .properties file. When using web.xml context parameters for configuration the configuration name has no effect.
Pz2Service will acknowledge following configuration parameters:
Modifier and Type | Class and Description |
---|---|
static interface |
Pz2Service.Preferred |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PAZPAR2_URL_LIST |
static java.lang.String |
SERVICE_PROXY_URL_LIST |
Constructor and Description |
---|
Pz2Service() |
Modifier and Type | Method and Description |
---|---|
void |
configure(ConfigurationReader reader)
Configures the Configurable using the configuration obtained by the
provided configuration reader
|
void |
configureClient(SearchClient client,
ConfigurationReader configReader)
Configures the selected search client using the selected configuration reader.
|
java.util.List<java.lang.String> |
documentConfiguration()
The components documentation of how it was configured.
|
static Pz2Service |
get() |
boolean |
getAuthenticationRequired() |
java.lang.String |
getCheckHistory() |
java.lang.String |
getCurrentStateKey()
Returns the current hash key, used for internal session state tracking
and potentially for browser history entries
A UI author would not normally be concerned with retrieving this.
|
java.util.Map<java.lang.String,java.lang.String> |
getDefaults()
Returns the default parameters that the configurable has defined for itself
Should be invoked by the configuration reader before it possibly overrides
some parameters obtained from the external configuration source
|
ErrorCentral |
getErrors() |
java.lang.String |
getModuleName()
Returns the name of the module, can be used by a configuration reader that
distinguishes between sets of configuration properties by component name, a
name space of sorts.
|
ResultsPager |
getPager()
Returns a component for drawing a pager to navigate by.
|
java.lang.String |
getPazpar2Url()
Returns the Pazpar2 URL currently defined for servicing requests
|
java.util.List<java.lang.String> |
getPazpar2Urls() |
Pazpar2Commands |
getPzreq() |
Responses |
getPzresp() |
SearchClient |
getSearchClient() |
java.lang.String |
getServiceId() |
java.lang.String |
getServiceProxyUrl()
Returns the Service Proxy URL currently defined for servicing requests
|
java.util.List<java.lang.String> |
getServiceProxyUrls() |
java.lang.String |
getServiceType() |
java.lang.String |
getServiceUrl()
Gets the currently selected URL used for executing requests.
|
boolean |
getServiceUrlIsDefined() |
ServiceProxyClient |
getSpClient() |
StateManager |
getStateMgr() |
java.lang.String |
getWatchActiveclients() |
java.lang.String |
getWatchActiveclientsRecord() |
boolean |
hasRecord(java.lang.String recId)
Resolves whether the back-end has a record with the given recid in memory
|
boolean |
isPazpar2Service() |
boolean |
isServiceProxyService() |
void |
postConstruct() |
void |
resetSearchAndRecordCommands() |
boolean |
serviceIsToBeDecided() |
void |
setCurrentStateKey(java.lang.String key)
Sets the current state key, i.e.
|
ResultsPager |
setPager(int pageRange)
Initiates a pager object, a component holding the data to draw a sequence
of page numbers to navigate by and mechanisms to navigate with
|
void |
setPazpar2Url(java.lang.String url)
Sets the URL of the Pazpar2 to use for requests
|
void |
setServiceId() |
void |
setServiceProxyUrl(java.lang.String url)
Sets the URL of the Service Proxy to use for requests
|
void |
setServiceTypePZ2() |
void |
setServiceTypeSP() |
void |
setServiceTypeTBD() |
void |
setServiceUrl(java.lang.String url)
Sets the URL to be used by the currently selected search client
when running requests.
|
void |
stateUpdated(java.lang.String commandName)
Used by the state manager to notify Pz2Service about state changes
|
java.lang.String |
toggleRecord(java.lang.String recId)
Will retrieve -- or alternatively remove -- the record with the given
recid from memory.
|
java.lang.String |
update()
Updates display data objects by simultaneously issuing the following Pazpar2 commands:
'show', 'stat', 'termlist' and 'bytarget'.
|
java.lang.String |
update(java.lang.String commands)
Simultaneously refreshes the data objects listed in 'commands' from pazpar2, potentially running a
search or a record command first if any of these two commands have outstanding parameter changes.
|
public static final java.lang.String SERVICE_PROXY_URL_LIST
public static final java.lang.String PAZPAR2_URL_LIST
public static Pz2Service get()
@PostConstruct public void postConstruct() throws MissingConfigurationContextException
@Produces @SessionScoped @Named(value="pzresp") public Responses getPzresp()
@Produces @SessionScoped @Named(value="pzreq") public Pazpar2Commands getPzreq()
@Produces @SessionScoped @Named(value="errors") public ErrorCentral getErrors()
@Produces @SessionScoped @Named(value="stateMgr") public StateManager getStateMgr()
public void configureClient(SearchClient client, ConfigurationReader configReader) throws MissingConfigurationContextException
client
- search client to useconfigReader
- the selected configuration mechanismMissingConfigurationContextException
- if this object is injected before there is a Faces context
for example in a Servlet filter.public void resetSearchAndRecordCommands()
public java.lang.String update()
If there are outstanding changes to the search command, a search will be issued before the updates are performed. Outstanding changes could come from the UI changing a search parameter and not executing search before starting the update cycle - OR - it could come from the user clicking the browsers back/forward buttons.
This method is invoked from the composite 'pz2watch', which uses Ajax to keep invoking this method until it returns '0' (for zero active clients).
UI components that display data from show, stat, termlist or bytarget, should be re-rendered after each update.
Example of invocation in UI:<pz2utils:pz2watch id="pz2watch" renderWhileActiveclients="myshowui mystatui mytermsui" /< <h:form> <h:inputText id="query" value="#{pzreq.search.query}" size="50"/> <h:commandButton id="button" value="Search"> <f:ajax execute="query" render="${pz2.watchActiveclients}"/> </h:commandButton> </h:form>The expression pz2.watchActiveClients will invoke the method repeatedly, and the UI sections myshowui, mystatui, and mytermsui will be rendered on each poll.
public java.lang.String update(java.lang.String commands)
commands,
- a comma-separated list of Pazpar2 commands to executepublic void stateUpdated(java.lang.String commandName)
stateUpdated
in interface StateListener
public java.lang.String toggleRecord(java.lang.String recId)
recid
- public boolean hasRecord(java.lang.String recId)
public java.lang.String getCurrentStateKey()
public void setCurrentStateKey(java.lang.String key)
key
- corresponding to browsers hash stringpublic ResultsPager getPager()
public ResultsPager setPager(int pageRange)
pageRange
- number of pages to display in the pagerpublic void setServiceProxyUrl(java.lang.String url)
url
- public java.lang.String getServiceProxyUrl()
public void setPazpar2Url(java.lang.String url)
url
- public java.lang.String getPazpar2Url()
public void setServiceUrl(java.lang.String url)
url
- public java.lang.String getServiceUrl()
public void setServiceId()
public java.lang.String getServiceId()
public boolean getServiceUrlIsDefined()
public java.util.List<java.lang.String> getServiceProxyUrls()
public java.util.List<java.lang.String> getPazpar2Urls()
public java.lang.String getServiceType()
public boolean isPazpar2Service()
public boolean isServiceProxyService()
public boolean serviceIsToBeDecided()
public ServiceProxyClient getSpClient()
public boolean getAuthenticationRequired()
public java.lang.String getCheckHistory()
public java.lang.String getWatchActiveclients()
public java.lang.String getWatchActiveclientsRecord()
public void configure(ConfigurationReader reader) throws ConfigurationException
Configurable
configure
in interface Configurable
reader
- used for reading the configurationConfigurationException
public java.util.Map<java.lang.String,java.lang.String> getDefaults()
Configurable
getDefaults
in interface Configurable
public java.lang.String getModuleName()
Configurable
getModuleName
in interface Configurable
public java.util.List<java.lang.String> documentConfiguration()
Configurable
documentConfiguration
in interface Configurable
public void setServiceTypePZ2()
public void setServiceTypeSP()
public void setServiceTypeTBD()
public SearchClient getSearchClient()