1 package com.indexdata.pz2utils4jsf.pazpar2;
\r
3 import java.io.Serializable;
\r
4 import java.util.List;
\r
6 import javax.annotation.PostConstruct;
\r
7 import javax.enterprise.context.SessionScoped;
\r
8 import javax.enterprise.inject.Alternative;
\r
9 import javax.inject.Inject;
\r
10 import javax.inject.Named;
\r
12 import org.apache.log4j.Logger;
\r
14 import com.indexdata.pz2utils4jsf.config.ConfigurationReader;
\r
15 import com.indexdata.pz2utils4jsf.controls.ResultsPager;
\r
16 import com.indexdata.pz2utils4jsf.errors.ErrorInterface;
\r
17 import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget;
\r
18 import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse;
\r
19 import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse;
\r
20 import com.indexdata.pz2utils4jsf.pazpar2.data.StatResponse;
\r
21 import com.indexdata.pz2utils4jsf.pazpar2.data.TermListsResponse;
\r
22 import com.indexdata.pz2utils4jsf.pazpar2.data.TermResponse;
\r
23 import com.indexdata.pz2utils4jsf.utils.Utils;
\r
25 @Named("pz2") @SessionScoped @Alternative
\r
26 public class Pz2Bean implements Pz2Interface, Serializable {
\r
28 private static final long serialVersionUID = 3440277287081557861L;
\r
29 private static Logger logger = Logger.getLogger(Pz2Bean.class);
\r
31 @Inject ConfigurationReader configurator;
\r
33 @Inject @ForStraightPz2 Pz2Session pz2;
\r
35 protected SearchClient searchClient;
\r
38 logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]");
\r
42 public void instantiatePz2SessionObject() {
\r
43 logger.debug("in start of Pz2Bean post-construct configurator is " + configurator);
\r
44 logger.debug(Utils.objectId(this) + " will instantiate a Pz2Client next.");
\r
45 searchClient = new Pz2Client();
\r
46 logger.info("Using [" + Utils.objectId(searchClient) + "] configured by ["
\r
47 + Utils.objectId(configurator) + "] on session ["
\r
48 + Utils.objectId(pz2) + "]" );
\r
49 pz2.configureClient(searchClient,configurator);
\r
53 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch(java.lang.String)
\r
55 public void doSearch(String query) {
\r
56 pz2.doSearch(query);
\r
60 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch()
\r
62 public void doSearch() {
\r
63 logger.info(Utils.objectId(this) + " doing search for "+pz2.getCommandReadOnly("search").getParameterValue("query"));
\r
68 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#update()
\r
70 public String update() {
\r
71 return pz2.update();
\r
75 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#update(java.lang.String)
\r
77 public String update(String commands) {
\r
78 return pz2.update(commands);
\r
82 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setQuery(java.lang.String)
\r
84 public void setQuery(String query) {
\r
85 pz2.req.getSearch().setQuery(query);
\r
89 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getQuery()
\r
92 public String getQuery() {
\r
93 return pz2.getQuery();
\r
98 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setFacet(java.lang.String, java.lang.String)
\r
100 public void setFacet(String facetKey, String term) {
\r
101 pz2.setFacet(facetKey, term);
\r
105 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#removeFacet(java.lang.String, java.lang.String)
\r
107 public void removeFacet(String facetKey, String term) {
\r
108 pz2.removeFacet(facetKey, term);
\r
112 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setFacetOnQuery(java.lang.String, java.lang.String)
\r
114 public void setFacetOnQuery(String facetKey, String term) {
\r
115 pz2.setFacetOnQuery(facetKey, term);
\r
119 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setTargetFilter(java.lang.String, java.lang.String)
\r
121 public void setSingleTargetFilter(String targetId, String targetName) {
\r
122 pz2.setSingleTargetFilter(targetId, targetName);
\r
126 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getTargetFilter()
\r
128 public SingleTargetFilter getSingleTargetFilter() {
\r
129 return pz2.getSingleTargetFilter();
\r
133 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#removeTargetFilter()
\r
135 public void removeSingleTargetFilter () {
\r
136 pz2.removeSingleTargetFilter();
\r
140 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#hasTargetFilter()
\r
142 public boolean hasSingleTargetFilter() {
\r
143 return pz2.hasSingleTargetFilter();
\r
147 public String getFilter () {
\r
148 return pz2.getFilter();
\r
151 public void setFilter (String filterExpression) {
\r
152 pz2.setFilter(filterExpression);
\r
157 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setSort(java.lang.String)
\r
159 public void setSort(String sortOption) {
\r
160 pz2.setSort(sortOption);
\r
164 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getSort()
\r
166 public String getSort() {
\r
167 return pz2.getSort();
\r
171 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setPageSize(int)
\r
173 public void setPageSize(int perPageOption) {
\r
174 pz2.setPageSize(perPageOption);
\r
178 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getPageSize()
\r
180 public int getPageSize() {
\r
181 return pz2.getPageSize();
\r
185 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setStart(int)
\r
187 public void setStart(int start) {
\r
188 pz2.setStart(start);
\r
192 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getStart()
\r
194 public int getStart() {
\r
195 return pz2.getStart();
\r
199 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#toggleRecord(java.lang.String)
\r
201 public String toggleRecord(String recid) {
\r
202 return pz2.toggleRecord(recid);
\r
206 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getShow()
\r
208 public ShowResponse getShow() {
\r
209 return pz2.getShow();
\r
213 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getStat()
\r
215 public StatResponse getStat() {
\r
216 return pz2.getStat();
\r
220 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#hasRecord(java.lang.String)
\r
222 public boolean hasRecord(String recId) {
\r
223 return pz2.hasRecord(recId);
\r
227 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getRecord()
\r
229 public RecordResponse getRecord() {
\r
230 return pz2.getRecord();
\r
234 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getTermLists()
\r
236 public TermListsResponse getTermLists() {
\r
237 return pz2.getTermLists();
\r
241 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getFacetTerms(java.lang.String, int)
\r
243 public List<TermResponse> getFacetTerms(String facet, int count) {
\r
244 return pz2.getFacetTerms(facet, count);
\r
248 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getFacetTerms(java.lang.String)
\r
250 public List<TermResponse> getFacetTerms(String facet) {
\r
251 return pz2.getFacetTerms(facet);
\r
255 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getByTarget()
\r
257 public ByTarget getByTarget() {
\r
258 return pz2.getByTarget();
\r
262 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#hasRecords()
\r
264 public boolean hasRecords() {
\r
265 return pz2.hasRecords();
\r
269 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setPager(int)
\r
271 public ResultsPager setPager(int pageRange) {
\r
272 return pz2.setPager(pageRange);
\r
276 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getPager()
\r
278 public ResultsPager getPager() {
\r
279 return pz2.getPager();
\r
283 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getCurrentStateKey()
\r
285 public String getCurrentStateKey() {
\r
286 return pz2.getCurrentStateKey();
\r
290 * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setCurrentStateKey(java.lang.String)
\r
292 public void setCurrentStateKey(String key) {
\r
293 pz2.setCurrentStateKey(key);
\r
296 public boolean hasErrors() {
\r
297 return pz2.hasErrors();
\r
300 public ErrorInterface getCommandError() {
\r
301 return pz2.getCommandError();
\r
304 public List<ErrorInterface> getConfigurationErrors () {
\r
305 return pz2.getConfigurationErrors();
\r
309 public boolean hasCommandErrors() {
\r
310 return pz2.hasCommandErrors();
\r
314 public boolean hasConfigurationErrors() {
\r
315 return pz2.hasConfigurationErrors();
\r
319 public void setRecordId(String recId) {
\r
320 pz2.setRecordId(recId);
\r
324 public String getRecordId() {
\r
325 return pz2.getRecordId();
\r