Class SearchQueryItem

java.lang.Object
io.goobi.viewer.model.search.SearchQueryItem
All Implemented Interfaces:
Serializable

public class SearchQueryItem extends Object implements Serializable
Field/operator/value tuple for the advanced search.
See Also:
  • Constructor Details

    • SearchQueryItem

      public SearchQueryItem()
      Zero-argument constructor.
    • SearchQueryItem

      public SearchQueryItem(String template)
      Parameters:
      template - advanced search template name for field configuration lookup
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getAvailableOperators

      public List<SearchQueryItem.SearchItemOperator> getAvailableOperators()
      getAvailableOperators.
      Returns:
      a list of search item operators available for this query item (AND, OR, NOT)
    • getSelectItems

      getSelectItems.
      Parameters:
      language - locale language code for label translation.
      Returns:
      a list of label-value pairs for the select dropdown of this query item's field
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
    • getCheckboxSelectables

      public List<CheckboxSelectable<String>> getCheckboxSelectables(String language, String... additionalValues) throws DAOException, PresentationException, IndexUnreachableException
      Parameters:
      language - locale language code for label translation
      additionalValues - 0-n additional, manually added values
      Returns:
      List<CheckboxSelectable<String>>
      Throws:
      DAOException
      PresentationException
      IndexUnreachableException
    • reset

      public void reset()
      reset.
    • isDisplayAddNewItemButton

      public boolean isDisplayAddNewItemButton(int lineIndex)
      Parameters:
      lineIndex - zero-based index of the line to check
      Returns:
      true if multiple items are allowed and the given line is the last one, false otherwise
    • isFirstLine

      public boolean isFirstLine(int lineIndex)
      Parameters:
      lineIndex - zero-based index of the line to check
      Returns:
      true if given line is first in list; false otherwise
    • isLastLine

      public boolean isLastLine(int lineIndex)
      Parameters:
      lineIndex - zero-based index of the line to check
      Returns:
      true if given line is last in list; false otherwise
    • addNewLine

      public boolean addNewLine(int afterIndex)
      Parameters:
      afterIndex - index after which to insert the new line; -1 to append
      Returns:
      true if new line successfully added; false otherwise
    • removeLine

      public boolean removeLine(SearchQueryItemLine line)
      removeLine.
      Parameters:
      line - query item line to remove from this item.
      Returns:
      true if the line was removed successfully, false if it could not be removed (e.g. it is the last remaining line)
    • isHierarchical

      public boolean isHierarchical()
      isHierarchical.
      Returns:
      true or false
    • isRange

      public boolean isRange()
      isRange.
      Returns:
      true or false
    • isDatepicker

      public boolean isDatepicker()
      Returns:
      true if datepicker should be used for this field's range inputs
    • isUntokenizeForPhraseSearch

      public boolean isUntokenizeForPhraseSearch()
      isUntokenizeForPhraseSearch.
      Returns:
      true or false
    • isAllowMultipleItems

      public boolean isAllowMultipleItems()
      Returns:
      true if multiple search values are allowed for this query item, false otherwise
    • isAllFields

      public boolean isAllFields()
      Returns:
      true if selected field is "all fields"; false otherwise
    • getDisplaySelectItemsThreshold

      public int getDisplaySelectItemsThreshold()
      Returns:
      Configured threshold for displayed select items
    • getSelectType

      public String getSelectType()
    • getReplaceRegex

      public String getReplaceRegex()
    • getReplaceWith

      public String getReplaceWith()
    • getLabel

      public String getLabel()
      Returns:
      the display label for this search query item, or the field name if no label is set
    • setLabel

      public SearchQueryItem setLabel(String label)
      Parameters:
      label - the display label for this search query item
      Returns:
      this
    • getField

      public String getField()
      Getter for the field field.
      Returns:
      the Solr field name to search in for this query item
    • setField

      public void setField(String field)
      Setter for the field field.
      Parameters:
      field - the Solr field name to search in for this query item
    • getLines

      public List<SearchQueryItemLine> getLines()
    • getOperator

      public SearchQueryItem.SearchItemOperator getOperator()
      Convenience getter.
      Returns:
      Operator of the first line
    • setOperator

      public void setOperator(SearchQueryItem.SearchItemOperator operator)
      Convenience setter.
      Parameters:
      operator - operator to set on the first line
    • getValue

      public String getValue()
      Backwards compatibility getter.
      Returns:
      the search value of the first query line, or null if no lines exist
    • setValue

      public void setValue(String value)
      Backwards compatibility setter.
      Parameters:
      value - the search value to set on the first query line
    • isValueSet

      public boolean isValueSet(String value)
      Backwards compatibility method.
      Parameters:
      value - value to look up in the first line's values list
      Returns:
      true if values contains given value; false otherwise
    • toggleValue

      public void toggleValue(String value)
      Backwards compatibility method.
      Parameters:
      value - Value to set/unset
    • getValue2

      public String getValue2()
      Backwards compatibility method.
      Returns:
      the upper bound value of the first query line for range searches, or null if no lines exist
    • setValue2

      public void setValue2(String value2)
      Backwards compatibility method.
      Parameters:
      value2 - the upper bound value to set on the first query line (used for range searches)
    • isDisplaySelectItems

      public boolean isDisplaySelectItems()
      isDisplaySelectItems.
      Returns:
      true if the field should display a select list instead of a free-text input, false otherwise
    • setDisplaySelectItems

      public void setDisplaySelectItems(boolean displaySelectItems)
      Setter for unit tets.
      Parameters:
      displaySelectItems - true if the field should show a select list instead of a free-text input; false otherwise
    • selectOneMenuListener

      public void selectOneMenuListener(ValueChangeEvent ev)
      This is called after setField, so no point in calling toggleDisplaySelectItems here.
      Parameters:
      ev - JSF value change event from the field selector.
    • toggleDisplaySelectItems

      protected void toggleDisplaySelectItems()
      toggleDisplaySelectItems.
    • generateQuery

      public String generateQuery(Set<String> searchTerms, boolean aggregateHits, boolean allowFuzzySearch)
      Generates the advanced query part for this item.
      Parameters:
      searchTerms - set collecting all search terms encountered during query building.
      aggregateHits - if true, SUPER fields are included for aggregated hit results.
      allowFuzzySearch - If true, search terms will be augmented by fuzzy search tokens
      Returns:
      the Solr query string generated from this advanced search query item
    • getProximitySearchDistance

      public int getProximitySearchDistance()
    • getPreselectValue

      public String getPreselectValue()
    • setPreselectValue

      public void setPreselectValue(String preselectValue)