public String update(String commands) {\r
return pz2.update(commands);\r
}\r
-\r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#setTargetFilter(java.lang.String, java.lang.String)\r
- */\r
- public void setSingleTargetFilter(String targetId, String targetName) {\r
- pz2.setSingleTargetFilter(targetId, targetName);\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#getTargetFilter()\r
- */\r
- public SingleTargetFilter getSingleTargetFilter() {\r
- return pz2.getSingleTargetFilter();\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#removeTargetFilter()\r
- */\r
- public void removeSingleTargetFilter () {\r
- pz2.removeSingleTargetFilter();\r
- }\r
- \r
- /* (non-Javadoc)\r
- * @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#hasTargetFilter()\r
- */\r
- public boolean hasSingleTargetFilter() {\r
- return pz2.hasSingleTargetFilter();\r
- }\r
-\r
- \r
- public String getFilter () {\r
- return pz2.getFilter();\r
- }\r
- \r
- public void setFilter (String filterExpression) {\r
- pz2.setFilter(filterExpression);\r
- }\r
\r
/* (non-Javadoc)\r
* @see com.indexdata.pz2utils4jsf.pazpar2.Pz2Interface#toggleRecord(java.lang.String)\r
* \r
*/\r
public String update (String commands);\r
- \r
- \r
- public void setFilter(String filterExpression);\r
- \r
- public String getFilter();\r
-\r
- \r
- /**\r
- * Adds a single target filter to restrict the current query by, \r
- * then executes the current search.\r
- * \r
- * This is a special case of the general setFilter function, \r
- * allowing to associate a descriptive target name with the \r
- * filter expression for display in UI. \r
- * \r
- * @param targetId pazpar2's ID for the target to limit by\r
- * @param targetName a descriptive name for the target\r
- */\r
- public void setSingleTargetFilter (String targetId, String targetName);\r
- \r
- /**\r
- * Removes the current target filter from the search\r
- * \r
- */\r
- public void removeSingleTargetFilter ();\r
- \r
- /**\r
- * \r
- * @return The target filter set on the current search command\r
- */\r
- public SingleTargetFilter getSingleTargetFilter();\r
- \r
- /**\r
- * Resolves if the current search command has a target filter - to\r
- * be used by the UI for conditional rendering of target filter info.\r
- * \r
- * @return true if the current search command is limited by a target \r
- * filter\r
- */\r
- public boolean hasSingleTargetFilter();\r
- \r
+ \r
/**\r
* Will retrieve or remove the record with the given recid from memory.\r
* \r
\r
}\r
\r
- public void setSingleTargetFilter (String targetId, String targetName) { \r
- if (hasSingleTargetFilter(new SingleTargetFilter(targetId,targetName))) {\r
- logger.debug("Already using target filter " + this.singleTargetFilter.getFilterExpression());\r
- } else { \r
- this.singleTargetFilter = new SingleTargetFilter(targetId,targetName);\r
- setCommandParameter("search",new CommandParameter("filter","=",this.singleTargetFilter.getFilterExpression())); \r
- doSearch();\r
- } \r
- }\r
-\r
- public SingleTargetFilter getSingleTargetFilter () {\r
- return singleTargetFilter;\r
- }\r
- \r
- public void removeSingleTargetFilter () {\r
- logger.debug("Removing target filter " + singleTargetFilter.getFilterExpression());\r
- this.singleTargetFilter = null;\r
- removeCommandParameter("search","filter"); \r
- doSearch();\r
- }\r
- \r
- public boolean hasSingleTargetFilter() {\r
- return singleTargetFilter != null; \r
- }\r
\r
public String toggleRecord (String recId) {\r
if (hasRecord(recId)) {\r
error.setErrorHelper(errorHelper);\r
return error; \r
}\r
-\r
- \r
- protected boolean hasSingleTargetFilter(SingleTargetFilter targetFilter) {\r
- return hasSingleTargetFilter() && targetFilter.equals(this.singleTargetFilter);\r
- }\r
\r
protected boolean hasQuery() { \r
return req.getSearch().getParameter("query") != null && req.getSearch().getParameter("query").getValueWithExpressions().length()>0;\r
dataObjects.put("search", new SearchResponse());\r
}\r
\r
- @Override\r
- public void setFilter(String filterExpression) {\r
- logger.debug("Setting filter to " + filterExpression);\r
- setCommandParameter("search",new CommandParameter("filter","=",filterExpression)); \r
- }\r
- \r
- public String getFilter() {\r
- return getCommandParameterValue("search", "filter", "");\r
- }\r
- \r
- public boolean hasFilter () {\r
- return getFilter().length()>0;\r
- }\r
\r
@Override\r
public void stateUpdated(String commandName) {\r
public String getRecordId () {\r
return getParameterValue("id");\r
}\r
+ \r
+ \r
\r
@Override\r
public RecordCommand copy () {\r
} \r
return newCommand;\r
}\r
-\r
- \r
-\r
}\r
import org.apache.log4j.Logger;\r
\r
import com.indexdata.pz2utils4jsf.pazpar2.Expression;\r
+import com.indexdata.pz2utils4jsf.pazpar2.SingleTargetFilter;\r
import com.indexdata.pz2utils4jsf.pazpar2.state.StateManager;\r
\r
@SessionScoped\r
\r
private static final long serialVersionUID = -1888520867838597236L;\r
private static Logger logger = Logger.getLogger(SearchCommand.class);\r
+ private SingleTargetFilter singleTargetFilter = null;\r
\r
public SearchCommand(StateManager stateMgr) {\r
super("search",stateMgr);\r
public String getFilter() {\r
return getParameter("filter") == null ? null : getParameter("filter").getValueWithExpressions();\r
}\r
+ \r
+ public boolean hasFilter () {\r
+ return getFilter().length()>0;\r
+ }\r
+ \r
+ /**\r
+ * Adds a single target filter to restrict the current query by, \r
+ * then executes the current search.\r
+ * \r
+ * This is a special case of the general setFilter function, \r
+ * allowing to associate a descriptive target name with the \r
+ * filter expression for display in UI. \r
+ * \r
+ * @param targetId pazpar2's ID for the target to limit by\r
+ * @param targetName a descriptive name for the target\r
+ */\r
+ public void setSingleTargetFilter (String targetId, String targetName) { \r
+ if (hasSingleTargetFilter(new SingleTargetFilter(targetId,targetName))) {\r
+ logger.debug("Already using target filter " + this.singleTargetFilter.getFilterExpression());\r
+ } else { \r
+ this.singleTargetFilter = new SingleTargetFilter(targetId,targetName);\r
+ setParameter(new CommandParameter("filter","=",this.singleTargetFilter.getFilterExpression())); \r
+ } \r
+ }\r
+\r
+ public SingleTargetFilter getSingleTargetFilter () {\r
+ logger.debug("request to get the current single target filter");\r
+ return singleTargetFilter;\r
+ }\r
+ \r
+ /**\r
+ * Removes the current target filter from the search\r
+ * \r
+ */\r
+ public void removeSingleTargetFilter () {\r
+ logger.debug("Removing target filter " + singleTargetFilter.getFilterExpression());\r
+ this.singleTargetFilter = null;\r
+ removeParameter("filter"); \r
+ }\r
+ \r
+ /**\r
+ * \r
+ * @return The target filter set on the current search command\r
+ */\r
+ public boolean hasSingleTargetFilter() {\r
+ logger.debug("Checking if a single target filter is set: " + (singleTargetFilter != null));\r
+ return singleTargetFilter != null; \r
+ }\r
+\r
+ /**\r
+ * Resolves if the current search command has a target filter - to\r
+ * be used by the UI for conditional rendering of target filter info.\r
+ * \r
+ * @return true if the current search command is limited by a target \r
+ * filter\r
+ */\r
+ protected boolean hasSingleTargetFilter(SingleTargetFilter targetFilter) {\r
+ return hasSingleTargetFilter() && targetFilter.equals(this.singleTargetFilter);\r
+ }\r
\r
\r
public void setLimit (String limit) {\r
- \r
+ // TODO\r
}\r
\r
public void addFilter(String filterExpression) {\r
public void removeFilter(String filterExpression) {\r
\r
}\r
- \r
+ \r
public SearchCommand copy () {\r
SearchCommand newCommand = new SearchCommand(stateMgr);\r
for (String parameterName : parameters.keySet()) {\r
newCommand.setParameterSilently(parameters.get(parameterName).copy()); \r
- } \r
+ }\r
+ newCommand.singleTargetFilter = this.singleTargetFilter;\r
return newCommand;\r
}\r
\r