import org.apache.log4j.Logger;\r
\r
import com.indexdata.mkjsf.pazpar2.Pz2Service;\r
+import com.indexdata.mkjsf.pazpar2.commands.sp.SearchCommandSp;\r
import com.indexdata.mkjsf.pazpar2.commands.sp.ServiceProxyCommand;\r
import com.indexdata.mkjsf.pazpar2.data.ResponseDataObject;\r
\r
/**\r
- * Represents a Pazpar2 <code>search</code> command. \r
+ * <b><code>search</code></b> Pazpar2 command, referenced as: <code>pzreq.search</code> \r
* \r
* @author Niels Erik\r
*\r
* were added as expressions (that is, not set with <code>setQuery()</code>).\r
*/\r
public String getQuery () { \r
- return getParameter("query") == null ? null : getParameter("query").getSimpleValue();\r
+ return getParameter("query") == null ? null : ((QueryParameter)getParameter("query")).getSimpleValue();\r
}\r
\r
/** \r
* Returns the complete <code>query</code> parameter value, including expressions.\r
*/\r
public String getExtendedQuery () { \r
- return getParameter("query") == null ? null : getParameter("query").getValueWithExpressions();\r
+ return getParameter("query") == null ? null : ((QueryParameter)getParameter("query")).getValueWithExpressions();\r
}\r
\r
/**\r
* Returns the <code>limit</code> parameter value.\r
*/\r
public String getLimit () {\r
- return getParameter("limit") == null ? null : ((FilterParameter)getParameter("limit")).getValueWithExpressions(); \r
+ return getParameter("limit") == null ? null : ((LimitParameter)getParameter("limit")).getValueWithExpressions(); \r
}\r
\r
/**\r
\r
\r
/**\r
- * Sets a facet, in CQL, to restrict the current results\r
+ * Adds an expression - for instance a facet criterion, with an optional label - to the query parameter\r
* \r
- * @param facetKey i.e. 'au' for author\r
- * @param term i.e. 'Dickens, Charles'\r
+ * <p>Example:</p>\r
+ * <ul>\r
+ * <li><code>{au}{=}{"Steinbeck, John"}{Steinbeck, John}</code>\r
+ * </ul>\r
*/\r
- public void setFacet(String facetKey, String term) {\r
+ public void addQueryExpression(String field, String operator, String term, String label) {\r
if (term != null && term.length()>0) { \r
- addExpression("query", new Expression(facetKey,"=",term,null)); \r
+ addExpression("query", new Expression(field,operator,term,label)); \r
} \r
}\r
\r
/**\r
+ * Removes a query expression - for instance a facet criterion - by its exact attributes\r
+ * \r
+ * @param field\r
+ * @param operator\r
+ * @param value\r
+ */\r
+ public void removeQueryExpression(String field, String operator, String value) {\r
+ removeExpression("query",new Expression(field, operator, value, null)); \r
+ }\r
+\r
+ \r
+ /**\r
* Sets a facet to limit the current query by. The \r
* facet is appended to the query string itself (rather\r
* as a separately managed entity. It will thus appear\r
public void setFacetOnQuery (String facetKey, String term) {\r
String facetExpression = facetKey + "=" + term; \r
if (term != null && term.length()>0) {\r
- String currentQuery= getParameterValue("query");\r
- setParameter(new CommandParameter("query","=", currentQuery + " and " + facetExpression)); \r
+ String currentQuery= getQuery();\r
+ setParameter(new QueryParameter("query","=", currentQuery + " and " + facetExpression)); \r
} \r
}\r
\r
\r
@Override\r
public ServiceProxyCommand getSp() {\r
- return this;\r
+ return new SearchCommandSp(this);\r
}\r
\r
@Override\r