Class SearchFacets

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

public class SearchFacets extends Object implements Serializable
Current faceting settings for a search.
See Also:
  • Constructor Details

    • SearchFacets

      public SearchFacets()
  • Method Details

    • resetAvailableFacets

      public void resetAvailableFacets()

      resetAvailableFacets.

    • resetActiveFacets

      public void resetActiveFacets()

      resetCurrentFacets.

    • resetSliderRange

      public void resetSliderRange()

      resetSliderRange.

    • generateFacetFilterQueries

      public List<String> generateFacetFilterQueries(boolean includeRangeFacets)
      Generates a list containing filter queries for the selected regular and hierarchical facets.
      Parameters:
      includeRangeFacets - a boolean.
      Returns:
      a List object.
    • getActiveFacetsForField

      public List<IFacetItem> getActiveFacetsForField(String field)
      Returns a list of FacetItem objects in activeFacets where the field name matches the given field name.
      Parameters:
      field - The field name to match.
      Returns:
      a List object.
    • isFacetStringCurrentlyUsed

      public boolean isFacetStringCurrentlyUsed(String link)
      Parameters:
      link -
      Returns:
      true if given link is part of the active facet string; false otherwise
    • isFacetCurrentlyUsed

      public boolean isFacetCurrentlyUsed(IFacetItem facet)
      Checks whether the given facet is currently in use.
      Parameters:
      facet - The facet to check.
      Returns:
      a boolean.
    • isFacetListSizeSufficient

      public boolean isFacetListSizeSufficient(String field)

      isFacetListSizeSufficient.

      Parameters:
      field - a String object.
      Returns:
      a boolean.
    • getAvailableFacetsListSizeForField

      public int getAvailableFacetsListSizeForField(String field)
      Returns the size of the full element list of the facet for the given field.
      Parameters:
      field - a String object.
      Returns:
      a int.
    • getActiveFacetsSizeForField

      public int getActiveFacetsSizeForField(String field)

      getActiveFacetsSizeForField.

      Parameters:
      field - a String object.
      Returns:
      Size of activeFacets.
    • getLimitedFacetListForField

      public List<IFacetItem> getLimitedFacetListForField(String field)
      Returns a collapsed sublist of the available facet elements for the given field.
      Parameters:
      field - a String object.
      Returns:
      a List object.
    • getAvailableFacetsForField

      public List<IFacetItem> getAvailableFacetsForField(String field, boolean excludeSelected)
      Parameters:
      field -
      excludeSelected - If true, selected facets will be removed from the list
      Returns:
      List
    • getFacet

      public IFacetItem getFacet(String field, String value)
      Parameters:
      field -
      value -
      Returns:
      Specific facet item for the given field and value; null if none found
    • isUnselectedValuesAvailable

      public boolean isUnselectedValuesAvailable()
      Checks whether there are still selectable values across all available facet fields.
      Returns:
      true if any available facet field has at least one unselected value; false otherwise
    • isHasRangeFacets

      public boolean isHasRangeFacets() throws PresentationException, IndexUnreachableException
      Returns:
      true if any configured range facet field has a value range in the current search result; false otherwise
      Throws:
      PresentationException
      IndexUnreachableException
    • expandFacet

      public void expandFacet(String field)
      Sets the expanded flag to true for the given facet field.
      Parameters:
      field - a String object.
    • collapseFacet

      public void collapseFacet(String field)
      Sets the expanded flag to false for the given facet field.
      Parameters:
      field - a String object.
    • isDisplayFacetExpandLink

      public boolean isDisplayFacetExpandLink(String field)
      Returns true if the "(more)" link is to be displayed for a facet box. This is the case if the facet has more elements than the initial number of displayed elements and the facet hasn't been manually expanded yet.
      Parameters:
      field - a String object.
      Returns:
      a boolean.
    • isDisplayFacetCollapseLink

      public boolean isDisplayFacetCollapseLink(String field)

      isDisplayFacetCollapseLink.

      Parameters:
      field - a String object.
      Returns:
      a boolean.
    • getActiveFacetString

      public String getActiveFacetString()
      Returns a URL encoded SSV string of facet fields and values from the elements in activeFacets (hyphen if empty).
      Returns:
      SSV string of facet queries or "-" if empty
    • setActiveFacetString

      public void setActiveFacetString(String activeFacetString)
      Receives an SSV string of facet fields and values (FIELD1:value1;FIELD2:value2;FIELD3:value3) and generates new Elements for currentFacets.
      Parameters:
      activeFacetString - a String object.
    • updateFacetItem

      public String updateFacetItem(String field, boolean hierarchical)
      Updates existing facet item for the given field with a new value. If no item for that field yet exist, a new one is added.
      Parameters:
      field - a String object.
      hierarchical - a boolean.
      Returns:
      a String object.
    • getHierarchicalFacets

      public static List<String> getHierarchicalFacets(String facetString, List<String> facetFields)

      getHierarchicalFacets.

      Parameters:
      facetString - a String object.
      facetFields - a List object.
      Returns:
      a List object.
    • splitHierarchicalFacet

      public static List<String> splitHierarchicalFacet(String facet)

      splitHierarchicalFacet.

      Parameters:
      facet - a String object.
      Returns:
      a List object.
    • getCurrentMinRangeValue

      public String getCurrentMinRangeValue(String field) throws PresentationException, IndexUnreachableException

      getCurrentMinRangeValue.

      Parameters:
      field - a String object.
      Returns:
      Current min value, if facet in use; otherwise absolute min value for that field
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getCurrentMaxRangeValue

      public String getCurrentMaxRangeValue(String field) throws PresentationException, IndexUnreachableException

      getCurrentMaxRangeValue.

      Parameters:
      field - a String object.
      Returns:
      Current max value, if facet in use; otherwise absolute max value for that field
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getAbsoluteMinRangeValue

      public String getAbsoluteMinRangeValue(String field) throws PresentationException, IndexUnreachableException
      Returns the minimum value for the given field available in the search index.
      Parameters:
      field - a String object.
      Returns:
      Smallest available value
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getAbsoluteMaxRangeValue

      public String getAbsoluteMaxRangeValue(String field) throws PresentationException, IndexUnreachableException
      Returns the maximum value for the given field available in the search index.
      Parameters:
      field - a String object.
      Returns:
      Largest available value
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getValueRange

      public List<Integer> getValueRange(String field) throws PresentationException, IndexUnreachableException
      Returns a sorted list of all available values for the given field among available facet values.
      Parameters:
      field - a String object.
      Returns:
      sorted list of all values for the given field among available facet values
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getValueRangeAsJsonMap

      public String getValueRangeAsJsonMap(String field)
      Parameters:
      field -
      Returns:
      String
    • isRangeFacetActive

      public boolean isRangeFacetActive(String field)
      Parameters:
      field -
      Returns:
      true if active range for field is currently smaller than the absolute range; false otherwise
    • resetActiveFacetString

      public void resetActiveFacetString()

      resetActiveFacetString.

    • getActiveFacetStringPrefix

      public String getActiveFacetStringPrefix()
      Returns a URL encoded value returned by generateFacetPrefix() for regular facets. Returns an empty string instead a hyphen if empty.
      Returns:
      a String object.
    • getActiveFacetStringPrefix

      public String getActiveFacetStringPrefix(String omitField)
      Parameters:
      omitField - Field name to not include in the string
      Returns:
      String object.
    • getActiveFacetStringPrefix

      public String getActiveFacetStringPrefix(List<String> omitFields, boolean urlEncode)
      Returns the value returned by generateFacetPrefix() for regular facets. Returns an empty string instead a hyphen if empty.
      Parameters:
      omitFields - Field names to omit from the facet string
      urlEncode -
      Returns:
      URL part for currently selected facets; empty string if empty
    • removeFacetAction

      public String removeFacetAction(String facetQuery, String ret)

      removeFacetAction.

      Parameters:
      facetQuery - a String object.
      ret - a String object.
      Returns:
      a String object.
    • isFacetExpanded

      public boolean isFacetExpanded(String field)
      Returns true if the value for the given field type in facetsExpanded has been previously set to true.
      Parameters:
      field - a String object.
      Returns:
      a boolean.
    • isFacetCollapsed

      public boolean isFacetCollapsed(String field)

      isFacetCollapsed.

      Parameters:
      field - a String object.
      Returns:
      a boolean.
    • getAllRangeFacetFields

      public List<String> getAllRangeFacetFields()
      Returns:
      All facet field names of the type "range"
    • getRangeFacetStyle

      public String getRangeFacetStyle(String field)
      Parameters:
      field -
      Returns:
      Visualization style for the given range field
    • getRangeFacetMinValue

      public int getRangeFacetMinValue(String field)
      Parameters:
      field -
      Returns:
      Configured min value for the given field
    • getRangeFacetMaxValue

      public int getRangeFacetMaxValue(String field)
      Parameters:
      field -
      Returns:
      Configured max value for the given field
    • getAllAvailableFacets

      public Map<String,List<IFacetItem>> getAllAvailableFacets()

      Returns configured facet fields of regular and hierarchical type only.

      Returns:
      a Map object.
    • hasAvailableFacets

      public boolean hasAvailableFacets()
    • getConfiguredSubelementFacetFields

      public List<String> getConfiguredSubelementFacetFields()

      getConfiguredSubelementFacetFields.

      Returns:
      Configured subelement fields names only
    • getAvailableFacets

      public Map<String,List<IFacetItem>> getAvailableFacets()

      Getter for the field availableFacets.

      Returns:
      the availableFacets
    • getActiveFacets

      public List<IFacetItem> getActiveFacets()

      Getter for the field activeFacets.

      Returns:
      the activeFacets
    • getTempValue

      public String getTempValue()

      Getter for the field tempValue.

      Returns:
      the tempValue
    • setTempValue

      public void setTempValue(String tempValue)

      Setter for the field tempValue.

      Parameters:
      tempValue - the tempValue to set
    • isHasWrongLanguageCode

      public boolean isHasWrongLanguageCode(String field, String language)
      Returns true if the given field is language-specific to a different language than the given language.
      Parameters:
      field - a String object.
      language - a String object.
      Returns:
      a boolean.
    • getFacetValue

      public String getFacetValue(String field)

      getFacetValue.

      Parameters:
      field - a String object.
      Returns:
      a String object.
    • getFacetDescription

      public String getFacetDescription(String field)

      getFacetDescription.

      Parameters:
      field - a String object.
      Returns:
      a String object.
    • getFirstHierarchicalFacetValue

      public String getFirstHierarchicalFacetValue()

      getFirstHierarchicalFacetValue.

      Returns:
      a String object.
    • getFirstHierarchicalFacetDescription

      public String getFirstHierarchicalFacetDescription(String field)

      getFirstHierarchicalFacetDescription.

      Parameters:
      field - a String object.
      Returns:
      a String object.
    • getLabelMap

      public Map<String,String> getLabelMap()
      Returns:
      the labelMap
    • getGeoFacetting

      public GeoFacetItem getGeoFacetting()
      Returns:
      the geoFacetting
    • setGeoFacetFeature

      public void setGeoFacetFeature(String feature)
      Sets the feature of the geoFacettingfield to to given feature. A new GeoFacetItem is added to currentFacets if none exists yet
      Parameters:
      feature -
    • getGeoFacetFeature

      public String getGeoFacetFeature()
    • getActiveFacetsSize

      public int getActiveFacetsSize()