X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2FSearchCommand.java;h=7d74b6cba24b55e578153bc12b53536031107916;hb=0c500bea459cf05157e0f753755466ce1b46604c;hp=671e723f26fcee8a0505157542659a1aff50915f;hpb=969f879c807d127cbf47c5656771fcf5adc27a02;p=mkjsf-moved-to-github.git diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java index 671e723..7d74b6c 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -9,11 +9,12 @@ import javax.inject.Named; import org.apache.log4j.Logger; import com.indexdata.mkjsf.pazpar2.Pz2Service; +import com.indexdata.mkjsf.pazpar2.commands.sp.SearchCommandSp; import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; /** - * Represents a Pazpar2 search command. + * search Pazpar2 command, referenced as: pzreq.search * * @author Niels Erik * @@ -56,14 +57,14 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand * were added as expressions (that is, not set with setQuery()). */ public String getQuery () { - return getParameter("query") == null ? null : getParameter("query").getSimpleValue(); + return getParameter("query") == null ? null : ((QueryParameter)getParameter("query")).getSimpleValue(); } /** * Returns the complete query parameter value, including expressions. */ public String getExtendedQuery () { - return getParameter("query") == null ? null : getParameter("query").getValueWithExpressions(); + return getParameter("query") == null ? null : ((QueryParameter)getParameter("query")).getValueWithExpressions(); } /** @@ -231,7 +232,7 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand * Returns the limit parameter value. */ public String getLimit () { - return getParameter("limit") == null ? null : ((FilterParameter)getParameter("limit")).getValueWithExpressions(); + return getParameter("limit") == null ? null : ((LimitParameter)getParameter("limit")).getValueWithExpressions(); } /** @@ -420,18 +421,32 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand /** - * Sets a facet, in CQL, to restrict the current results + * Adds an expression - for instance a facet criterion, with an optional label - to the query parameter * - * @param facetKey i.e. 'au' for author - * @param term i.e. 'Dickens, Charles' + *

Example:

+ * */ - public void setFacet(String facetKey, String term) { + public void addQueryExpression(String field, String operator, String term, String label) { if (term != null && term.length()>0) { - addExpression("query", new Expression(facetKey,"=",term,null)); + addExpression("query", new Expression(field,operator,term,label)); } } /** + * Removes a query expression - for instance a facet criterion - by its exact attributes + * + * @param field + * @param operator + * @param value + */ + public void removeQueryExpression(String field, String operator, String value) { + removeExpression("query",new Expression(field, operator, value, null)); + } + + + /** * Sets a facet to limit the current query by. The * facet is appended to the query string itself (rather * as a separately managed entity. It will thus appear @@ -444,8 +459,8 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand public void setFacetOnQuery (String facetKey, String term) { String facetExpression = facetKey + "=" + term; if (term != null && term.length()>0) { - String currentQuery= getParameterValue("query"); - setParameter(new CommandParameter("query","=", currentQuery + " and " + facetExpression)); + String currentQuery= getQuery(); + setParameter(new QueryParameter("query","=", currentQuery + " and " + facetExpression)); } } @@ -473,7 +488,7 @@ public class SearchCommand extends Pazpar2Command implements ServiceProxyCommand @Override public ServiceProxyCommand getSp() { - return this; + return new SearchCommandSp(this); } @Override