X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fcom%2Findexdata%2Fmkjsf%2Fpazpar2%2Fcommands%2FSearchCommand.java;h=f2c53da7a97e5c24829cba165a5d0d7adb482c02;hb=86f289cd42ba95846c80d22129ed565e4e9d6dde;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..f2c53da 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/commands/SearchCommand.java @@ -13,7 +13,7 @@ import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand; import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject; /** - * Represents a Pazpar2 search command. + * Represents a Pazpar2 search command, can be accessed by pzreq.search * * @author Niels Erik * @@ -56,14 +56,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(); } /** @@ -420,18 +420,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 +458,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)); } }