X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fpz2utils4jsf%2Fpazpar2%2FPz2Bean.java;h=845f3d959968f8fe715a7e67d71f17f3f357f5fa;hb=46a090cd2f2e2069c684084eeded75c9d5ed71f5;hp=73042fb7aea74a10d23780d4a557678fb4118b66;hpb=1724e77234e35c61de392b943730b76771ce5bb3;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java index 73042fb..845f3d9 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -3,34 +3,56 @@ package com.indexdata.pz2utils4jsf.pazpar2; import java.io.Serializable; import java.util.List; +import javax.annotation.PostConstruct; import javax.enterprise.context.SessionScoped; +import javax.enterprise.inject.Alternative; +import javax.inject.Inject; import javax.inject.Named; +import org.apache.log4j.Logger; + +import com.indexdata.pz2utils4jsf.config.ConfigurationReader; import com.indexdata.pz2utils4jsf.controls.ResultsPager; -import com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface; -import com.indexdata.pz2utils4jsf.pazpar2.Pz2Session; -import com.indexdata.pz2utils4jsf.pazpar2.TargetFilter; +import com.indexdata.pz2utils4jsf.errors.ErrorInterface; import com.indexdata.pz2utils4jsf.pazpar2.data.ByTarget; import com.indexdata.pz2utils4jsf.pazpar2.data.RecordResponse; import com.indexdata.pz2utils4jsf.pazpar2.data.ShowResponse; import com.indexdata.pz2utils4jsf.pazpar2.data.StatResponse; import com.indexdata.pz2utils4jsf.pazpar2.data.TermListsResponse; import com.indexdata.pz2utils4jsf.pazpar2.data.TermResponse; +import com.indexdata.pz2utils4jsf.utils.Utils; -@Named("pz2") -@SessionScoped +@Named("pz2") @SessionScoped @Alternative public class Pz2Bean implements Pz2Interface, Serializable { private static final long serialVersionUID = 3440277287081557861L; - Pz2Session pz2; + private static Logger logger = Logger.getLogger(Pz2Bean.class); + + @Inject ConfigurationReader configurator; + + @Inject @ForStraightPz2 Pz2Session pz2; + protected SearchClient searchClient; + public Pz2Bean () { - pz2 = new Pz2Session(); + logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]"); } + + @PostConstruct + public void instantiatePz2SessionObject() { + logger.debug("in start of Pz2Bean post-construct configurator is " + configurator); + logger.debug(Utils.objectId(this) + " will instantiate a Pz2Client next."); + searchClient = new Pz2Client(); + logger.info("Using [" + Utils.objectId(searchClient) + "] configured by [" + + Utils.objectId(configurator) + "] on session [" + + Utils.objectId(pz2) + "]" ); + pz2.configureClient(searchClient,configurator); + } + /* (non-Javadoc) * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch(java.lang.String) */ - public void doSearch(String query) { + public void doSearch(String query) { pz2.doSearch(query); } @@ -38,6 +60,7 @@ public class Pz2Bean implements Pz2Interface, Serializable { * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#doSearch() */ public void doSearch() { + logger.info(Utils.objectId(this) + " doing search for "+pz2.getCommandReadOnly("search").getParameterValue("query")); pz2.doSearch(); } @@ -54,113 +77,8 @@ public class Pz2Bean implements Pz2Interface, Serializable { public String update(String commands) { return pz2.update(commands); } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setQuery(java.lang.String) - */ - public void setQuery(String query) { - pz2.setQuery(query); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getQuery() - */ - public String getQuery() { - return pz2.getQuery(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setFacet(java.lang.String, java.lang.String) - */ - public void setFacet(String facetKey, String term) { - pz2.setFacet(facetKey, term); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#removeFacet(java.lang.String, java.lang.String) - */ - public void removeFacet(String facetKey, String term) { - pz2.removeFacet(facetKey, term); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setFacetOnQuery(java.lang.String, java.lang.String) - */ - public void setFacetOnQuery(String facetKey, String term) { - pz2.setFacetOnQuery(facetKey, term); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setTargetFilter(java.lang.String, java.lang.String) - */ - public void setTargetFilter(String targetId, String targetName) { - pz2.setTargetFilter(targetId, targetName); - } /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#removeTargetFilter() - */ - public void removeTargetFilter () { - pz2.removeTargetFilter(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getTargetFilter() - */ - public TargetFilter getTargetFilter() { - return pz2.getTargetFilter(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#hasTargetFilter() - */ - public boolean hasTargetFilter() { - return pz2.hasTargetFilter(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setSort(java.lang.String) - */ - public void setSort(String sortOption) { - pz2.setSort(sortOption); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getSort() - */ - public String getSort() { - return pz2.getSort(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setPageSize(int) - */ - public void setPageSize(int perPageOption) { - pz2.setPageSize(perPageOption); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getPageSize() - */ - public int getPageSize() { - return pz2.getPageSize(); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setStart(int) - */ - public void setStart(int start) { - pz2.setStart(start); - } - - /* (non-Javadoc) - * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getStart() - */ - public int getStart() { - return pz2.getStart(); - } - - /* (non-Javadoc) * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#toggleRecord(java.lang.String) */ public String toggleRecord(String recid) { @@ -257,5 +175,27 @@ public class Pz2Bean implements Pz2Interface, Serializable { public void setCurrentStateKey(String key) { pz2.setCurrentStateKey(key); } + + public boolean hasErrors() { + return pz2.hasErrors(); + } + + public ErrorInterface getCommandError() { + return pz2.getCommandError(); + } + + public List getConfigurationErrors () { + return pz2.getConfigurationErrors(); + } + @Override + public boolean hasCommandErrors() { + return pz2.hasCommandErrors(); + } + + @Override + public boolean hasConfigurationErrors() { + return pz2.hasConfigurationErrors(); + } + }