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=dcf75a7c46e96fb6417b98a9a10b0c2a401972eb;hpb=2aa1c4adceb245c1f59f62e9adb77fda9f02291a;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 dcf75a7..845f3d9 100644 --- a/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java +++ b/src/main/java/com/indexdata/pz2utils4jsf/pazpar2/Pz2Bean.java @@ -5,14 +5,15 @@ 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.Pz2Configurator; +import com.indexdata.pz2utils4jsf.config.ConfigurationReader; import com.indexdata.pz2utils4jsf.controls.ResultsPager; -import com.indexdata.pz2utils4jsf.errors.ApplicationError; +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; @@ -21,26 +22,32 @@ 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; private static Logger logger = Logger.getLogger(Pz2Bean.class); - Pz2Session pz2; - @Inject Pz2Configurator pz2conf; + @Inject ConfigurationReader configurator; + @Inject @ForStraightPz2 Pz2Session pz2; + + protected SearchClient searchClient; + public Pz2Bean () { logger.info("Instantiating pz2 bean [" + Utils.objectId(this) + "]"); } @PostConstruct - public void initiatePz2Session() { - logger.debug(Utils.objectId(this) + " will instantiate a Pz2Session next."); - pz2 = new Pz2Session(); - logger.debug(Utils.objectId(this) + " will forward configuration to the new Pz2Session [" + Utils.objectId(pz2) + "]"); - pz2.init(pz2conf); - } + 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) @@ -53,7 +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 "+this.getQuery()); + logger.info(Utils.objectId(this) + " doing search for "+pz2.getCommandReadOnly("search").getParameterValue("query")); pz2.doSearch(); } @@ -70,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) { @@ -278,11 +180,11 @@ public class Pz2Bean implements Pz2Interface, Serializable { return pz2.hasErrors(); } - public ApplicationError getCommandError() { + public ErrorInterface getCommandError() { return pz2.getCommandError(); } - public List getConfigurationErrors () { + public List getConfigurationErrors () { return pz2.getConfigurationErrors(); } @@ -295,5 +197,5 @@ public class Pz2Bean implements Pz2Interface, Serializable { public boolean hasConfigurationErrors() { return pz2.hasConfigurationErrors(); } - + }