com.indexdata.mkjsf.pazpar2.commands
Class SearchCommand

java.lang.Object
  extended by com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command
      extended by com.indexdata.mkjsf.pazpar2.commands.SearchCommand
All Implemented Interfaces:
ServiceProxyCommand, Serializable

@SessionScoped
@Named
public class SearchCommand
extends Pazpar2Command
implements ServiceProxyCommand

Represents a Pazpar2 search command, can be accessed by pzreq.search

Author:
Niels Erik
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command
name, parameters
 
Constructor Summary
SearchCommand()
           
 
Method Summary
 void addFilter(String field, String operator, String value, String label)
          Adds a filter expression with a label for display.
 void addLimit(String field, String operator, String value, String label)
          Adds a limit expression with a label for display.
 void addQueryExpression(String field, String operator, String term, String label)
          Adds an expression - for instance a facet criterion, with an optional label - to the query parameter
 SearchCommand copy()
          Commands must implement this method to provide an completely detached, deep clone of themselves.
 String getExtendedQuery()
          Returns the complete query parameter value, including expressions.
 String getFilter()
          Returns the filter parameter value.
 List<Expression> getFilterExpressions()
          Returns list of all filter expressions
 List<Expression> getFilterExpressions(String... expressionFields)
           
 String getLimit()
          Returns the limit parameter value.
 List<Expression> getLimitExpressions()
          Return a list of all current limit expressions
 List<Expression> getLimitExpressions(String... expressionFields)
          Returns a list of limit expressions with fields that matches on of expressionFields
 String getMaxrecs()
          Returns the maxrecs parameter value.
 String getMergekey()
          Returns the mergekey parameter value.
 Expression getOneFilterExpression(String expressionField)
          Returns the first filter expression of the given type
 Expression getOneLimitExpression(String expressionField)
          Returns the first limit expression of the given type
 String getQuery()
          Returns the simple part of the query parameter value, excluding parts that were added as expressions (that is, not set with setQuery()).
 String getRank()
          Returns the rank parameter value.
 String getSort()
          Returns the sort parameter value.
 ServiceProxyCommand getSp()
          Implementing classes must provide their Service Proxy extension command if any extension parameters exists, or -- just to be polite -- 'this' if there is no Service Proxy extension to the given command.
 String getStartrecs()
          Returns the startrecs parameter value.
 boolean hasFilter()
           
 boolean hasFilterExpression(String... expressionFields)
          Checks if there are any filter expressions matching any of the given expressionFields
 boolean hasLimitExpression(String... expressionFields)
          Checks if there are any limit expressions matching any of the given expressionFields
 void removeFacet(String facetKey, String term)
          Removes a facet set by setFacet(...) Will not remove facets set by setFacetOnQuery(...)
 void removeFilter(String field, String operator, String value)
          Removes a filter expression by exact attributes
 void removeFilters()
          Clears the filter parameter
 void removeFilters(String... fieldsToRemove)
          Removes all filter expressions matching a field listed in fieldsToRemove
 void removeFiltersAfter(String field, String operator, String value, String... fieldsToRemove)
          Removes filter expressions coming after the expression matching the provided filter expression, if they have a field listed in fieldsToRemove.
 void removeLimit(String field, String operator, String value)
          Removes a limit expression by exact attributes
 void removeLimits()
          Clears the limit parameter
 void removeLimits(String... fieldsToRemove)
          Removes all limit expressions that have fields as listed in fieldsToRemove
 void removeLimitsAfter(String field, String operator, String value, String... fieldsToRemove)
          Removes limit expressions coming after the provided limit expression, if they have a field listed in fieldsToRemove.
 void removeQueryExpression(String field, String operator, String value)
          Removes a query expression - for instance a facet criterion - by its exact attributes
 ResponseDataObject run()
          Executes the command with the currently selected parameters against the currently selected Pazpar2 service
 void setBooleanOperatorForQuery(String operator)
           
 void setFacetOnQuery(String facetKey, String term)
          Sets a facet to limit the current query by.
 void setFilter(String filterExpression)
          Sets the filter parameter.
 void setFilter(String field, String operator, String value, String label)
          Sets the filter parameter.
 void setLimit(String limitExpression)
          Sets the limit parameter.
 void setLimit(String field, String operator, String value, String label)
          Sets the limit parameter including a label.
 void setMaxrecs(String maxrecs)
          Sets the maxrecs parameter.
 void setMergekey(String mergekey)
          Sets the mergekey parameter.
 void setQuery(String query)
          Sets the query parameter.
 void setRank(String rank)
          Sets the rank parameter.
 void setSort(String sort)
          Sets the sort parameter.
 void setStartrecs(String startrecs)
          Sets the startrecs parameter.
 boolean spOnly()
          Here implementing commands publish whether they only apply to the Service Proxy or can be executed against straight Pazpar2 as well.
 
Methods inherited from class com.indexdata.mkjsf.pazpar2.commands.Pazpar2Command
addExpression, checkInState, equals, getCommandName, getEncodedQueryString, getParameter, getParameterValue, getSession, getValueWithExpressions, hashCode, hasParameters, hasParameterValue, removeExpression, removeExpressions, removeExpressionsAfter, removeParameter, removeParameters, removeParametersInState, run, runWith, setCommandName, setParameter, setParameterInState, setParameters, setParametersInState, setSession, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SearchCommand

public SearchCommand()
Method Detail

run

public ResponseDataObject run()
Description copied from class: Pazpar2Command
Executes the command with the currently selected parameters against the currently selected Pazpar2 service

Overrides:
run in class Pazpar2Command
Returns:
Response data object based on the Pazpar2 service response.

setQuery

public void setQuery(String query)
Sets the query parameter. See Pazpar2 documentation for details.


setBooleanOperatorForQuery

public void setBooleanOperatorForQuery(String operator)

getQuery

public String getQuery()
Returns the simple part of the query parameter value, excluding parts that were added as expressions (that is, not set with setQuery()).


getExtendedQuery

public String getExtendedQuery()
Returns the complete query parameter value, including expressions.


setFilter

public void setFilter(String filterExpression)
Sets the filter parameter. See Pazpar2 documentation for details.


setFilter

public void setFilter(String field,
                      String operator,
                      String value,
                      String label)
Sets the filter parameter. See Pazpar2 documentation for details.


hasFilterExpression

public boolean hasFilterExpression(String... expressionFields)
Checks if there are any filter expressions matching any of the given expressionFields

Parameters:
expressionFields - expression fields (left-of-operator entities) to look for
Returns:
true if expression(s) found with any of expressionFields

getFilter

public String getFilter()
Returns the filter parameter value.


getOneFilterExpression

public Expression getOneFilterExpression(String expressionField)
Returns the first filter expression of the given type

Parameters:
expressionField - expression field (left-of-operator entity) to look for
Returns:
the first filter expression found with the field expressionField or null if none found

getFilterExpressions

public List<Expression> getFilterExpressions()
Returns list of all filter expressions


getFilterExpressions

public List<Expression> getFilterExpressions(String... expressionFields)

hasFilter

public boolean hasFilter()

addFilter

public void addFilter(String field,
                      String operator,
                      String value,
                      String label)
Adds a filter expression with a label for display. The filter is added to the end of an ordered list.

Parameters:
field -
operator -
value -
label -

removeFilters

public void removeFilters()
Clears the filter parameter


removeFilter

public void removeFilter(String field,
                         String operator,
                         String value)
Removes a filter expression by exact attributes

Parameters:
field -
operator -
value -

removeFilters

public void removeFilters(String... fieldsToRemove)
Removes all filter expressions matching a field listed in fieldsToRemove

Parameters:
fieldsToRemove -

removeFiltersAfter

public void removeFiltersAfter(String field,
                               String operator,
                               String value,
                               String... fieldsToRemove)
Removes filter expressions coming after the expression matching the provided filter expression, if they have a field listed in fieldsToRemove. To be used for bread crumb like UI controls.

Parameters:
field -
operator -
value -
fieldsToRemove -

setLimit

public void setLimit(String limitExpression)
Sets the limit parameter. See Pazpar2 documentation for details.


setLimit

public void setLimit(String field,
                     String operator,
                     String value,
                     String label)
Sets the limit parameter including a label. See Pazpar2 documentation for details.


getLimit

public String getLimit()
Returns the limit parameter value.


hasLimitExpression

public boolean hasLimitExpression(String... expressionFields)
Checks if there are any limit expressions matching any of the given expressionFields

Parameters:
expressionFields - expression fields (left-of-operator entities) to look for
Returns:
true if expression(s) found with any of expressionFields

getOneLimitExpression

public Expression getOneLimitExpression(String expressionField)
Returns the first limit expression of the given type

Parameters:
expressionField - expression field (left-of-operator entity) to look for
Returns:
the first limit expression found with the field expressionField or null if none found

getLimitExpressions

public List<Expression> getLimitExpressions()
Return a list of all current limit expressions


getLimitExpressions

public List<Expression> getLimitExpressions(String... expressionFields)
Returns a list of limit expressions with fields that matches on of expressionFields

Parameters:
expressionFields - limit expressions to look for

addLimit

public void addLimit(String field,
                     String operator,
                     String value,
                     String label)
Adds a limit expression with a label for display. The limit is added to the end of an ordered list.

Parameters:
field -
operator -
value -
label -

removeLimits

public void removeLimits()
Clears the limit parameter


removeLimits

public void removeLimits(String... fieldsToRemove)
Removes all limit expressions that have fields as listed in fieldsToRemove

Parameters:
fieldsToRemove -

removeLimit

public void removeLimit(String field,
                        String operator,
                        String value)
Removes a limit expression by exact attributes

Parameters:
field -
operator -
value -

removeLimitsAfter

public void removeLimitsAfter(String field,
                              String operator,
                              String value,
                              String... fieldsToRemove)
Removes limit expressions coming after the provided limit expression, if they have a field listed in fieldsToRemove. To be used for bread crumb like UI controls.

Parameters:
field -
operator -
value -
fieldsToRemove -

setStartrecs

public void setStartrecs(String startrecs)
Sets the startrecs parameter. See Pazpar2 documentation for details.


getStartrecs

public String getStartrecs()
Returns the startrecs parameter value.


setMaxrecs

public void setMaxrecs(String maxrecs)
Sets the maxrecs parameter. See Pazpar2 documentation for details.


getMaxrecs

public String getMaxrecs()
Returns the maxrecs parameter value.


setSort

public void setSort(String sort)
Sets the sort parameter. See Pazpar2 documentation for details.


getSort

public String getSort()
Returns the sort parameter value.


setRank

public void setRank(String rank)
Sets the rank parameter. See Pazpar2 documentation for details.


getRank

public String getRank()
Returns the rank parameter value.


setMergekey

public void setMergekey(String mergekey)
Sets the mergekey parameter. See Pazpar2 documentation for details.


getMergekey

public String getMergekey()
Returns the mergekey parameter value.


addQueryExpression

public void addQueryExpression(String field,
                               String operator,
                               String term,
                               String label)
Adds an expression - for instance a facet criterion, with an optional label - to the query parameter

Example:


removeQueryExpression

public void removeQueryExpression(String field,
                                  String operator,
                                  String value)
Removes a query expression - for instance a facet criterion - by its exact attributes

Parameters:
field -
operator -
value -

setFacetOnQuery

public void setFacetOnQuery(String facetKey,
                            String term)
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 in a query field as retrieved by getQuery(). It will not be removed by removeFacet(...)

Parameters:
facetKey - i.e. 'au' for author
term - i.e. 'Dickens, Charles'

removeFacet

public void removeFacet(String facetKey,
                        String term)
Removes a facet set by setFacet(...) Will not remove facets set by setFacetOnQuery(...)

Parameters:
facetKey - i.e. 'au' for author
term - i.e. 'Dickens, Charles'

copy

public SearchCommand copy()
Description copied from class: Pazpar2Command
Commands must implement this method to provide an completely detached, deep clone of themselves. The clone is needed by the state manager to transfer commands with current setting from one state to the next. Whenever a non-standard attribute is added to a command class, the copy method must be updated to ensure that the new attribute is brought over as well.

Specified by:
copy in class Pazpar2Command
Returns:
a Pazpar2 command of the given type

getSp

public ServiceProxyCommand getSp()
Description copied from class: Pazpar2Command
Implementing classes must provide their Service Proxy extension command if any extension parameters exists, or -- just to be polite -- 'this' if there is no Service Proxy extension to the given command.

Specified by:
getSp in class Pazpar2Command
Returns:

spOnly

public boolean spOnly()
Description copied from class: Pazpar2Command
Here implementing commands publish whether they only apply to the Service Proxy or can be executed against straight Pazpar2 as well. This is convenient for a UI that switches between service types either deployment time or run time.

Specified by:
spOnly in interface ServiceProxyCommand
Specified by:
spOnly in class Pazpar2Command
Returns:
false if the command applies to straight Pazpar2


Copyright © 2013. All Rights Reserved.