Class FacetItem

java.lang.Object
io.goobi.viewer.model.search.FacetItem
All Implemented Interfaces:
IFacetItem, Serializable

public class FacetItem extends Object implements Serializable, IFacetItem
Represents a single facet value with its display label, hit count, and selection state.
See Also:
  • Constructor Details

    • FacetItem

      public FacetItem(String link, boolean hierarchical)
      Creates a new FacetItem for active facets received via the URL. The Solr query is split into individual field/value.
      Parameters:
      link - Solr field:value query string to parse
      hierarchical - true if this is a hierarchical facet
    • FacetItem

      public FacetItem(String link, String label, boolean hierarchical)
      Creates a new FacetItem for active facets received via the URL. The Solr query is split into individual field/value.
      Parameters:
      link - Solr field:value query string to parse
      label - display label; null to use the value as label
      hierarchical - true if this is a hierarchical facet
    • FacetItem

      public FacetItem(org.apache.solr.client.solrj.response.FacetField.Count count)
      Parameters:
      count - Solr facet count object to build the item from
  • Method Details

    • hashCode

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

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

      public static List<IFacetItem> generateFilterLinkList(List<IFacetItem> existingFacetsItems, String field, FacetSorting.SortingMap<String,Long> values, boolean hierarchical, int groupToLength, Map<String,String> labelMap)
      Constructs facet items from the list of given field:value combinations. Always sorted by the label translation.
      Parameters:
      existingFacetsItems - List of previously generated items (e.g. via other result groups) to combine with new items
      field - Facet field
      values - Map containing facet values and their counts
      hierarchical - true if facet field is hierarchical; false otherwise
      groupToLength - If value is greater than 0, facet values will be grouped together by if they contain equal characters at {0-groupByLength}
      labelMap - Optional map for storing alternate labels for later use by the client
      Returns:
      ArrayList of FacetItem
    • generateFacetItems

      public static List<IFacetItem> generateFacetItems(String field, Map<String,Long> values, boolean sort, boolean reverseOrder, boolean hierarchical)
      Constructs a list of FilterLink objects for faceting. Optionally sorted by the raw values.
      Parameters:
      field - Solr facet field name
      values - map of facet values to their document counts
      sort - if true, sort items by value before returning
      reverseOrder - if true, reverse the sort order
      hierarchical - true if facet field is hierarchical
      Returns:
      a list of facet items generated from the given values map, optionally sorted
    • getQueryEscapedLink

      public String getQueryEscapedLink()
      Returns field:value (with the value escaped for the Solr query).
      Specified by:
      getQueryEscapedLink in interface IFacetItem
      Returns:
      the Solr filter query string for this facet item, with field and value properly escaped
    • getEscapedLink

      public String getEscapedLink()
      Link after slash/backslash replacements for partner collection, static drill-down components and topic browsing (HU Berlin).
      Specified by:
      getEscapedLink in interface IFacetItem
      Returns:
      the facet link with critical URL characters escaped
    • getUrlEscapedLink

      public String getUrlEscapedLink()
      URL escaped link for using in search drill-downs.
      Specified by:
      getUrlEscapedLink in interface IFacetItem
      Returns:
      the URL-encoded facet link for use in drill-down search URLs
    • getType

      public FacetItem.FacetType getType()
      Specified by:
      getType in interface IFacetItem
    • setType

      public void setType(FacetItem.FacetType type)
    • getField

      public String getField()
      Getter for the field field.
      Specified by:
      getField in interface IFacetItem
      Returns:
      the Solr field name this facet item belongs to
    • setField

      public void setField(String field)
      Setter for the field field.
      Specified by:
      setField in interface IFacetItem
      Parameters:
      field - the Solr field name this facet item belongs to
    • getFullValue

      public String getFullValue()
      getFullValue.
      Specified by:
      getFullValue in interface IFacetItem
      Returns:
      Range of value - value2; just value if value2 empty
    • getValue

      public String getValue()
      Getter for the field value.
      Specified by:
      getValue in interface IFacetItem
      Returns:
      the facet value string
    • setValue

      public void setValue(String value)
      Setter for the field value.
      Specified by:
      setValue in interface IFacetItem
      Parameters:
      value - the facet value string
    • getValue2

      public String getValue2()
      Getter for the field value2.
      Specified by:
      getValue2 in interface IFacetItem
      Returns:
      the upper bound value for range facets
    • setValue2

      public void setValue2(String value2)
      Setter for the field value2.
      Specified by:
      setValue2 in interface IFacetItem
      Parameters:
      value2 - the upper bound value for range facets
    • getLink

      public String getLink()
      Getter for the field link.
      Specified by:
      getLink in interface IFacetItem
      Returns:
      the colon-separated field:value string used as the facet link
    • setLink

      public void setLink(String link)
      Setter for the field link.
      Specified by:
      setLink in interface IFacetItem
      Parameters:
      link - the colon-separated field:value string used as the facet link
    • getLabel

      public String getLabel()
      Getter for the field label.
      Specified by:
      getLabel in interface IFacetItem
      Returns:
      the display label for this facet item
    • setLabel

      public FacetItem setLabel(String label)
      Setter for the field label.
      Specified by:
      setLabel in interface IFacetItem
      Parameters:
      label - the display label for this facet item
      Returns:
      this
    • getTranslatedLabel

      public String getTranslatedLabel()
      Getter for the field translatedLabel.
      Specified by:
      getTranslatedLabel in interface IFacetItem
      Returns:
      the translated label if translation is configured for this field, otherwise the raw label
    • setTranslatedLabel

      public void setTranslatedLabel(String translatedLabel)
      Dummy setter to fulfill the interface contract.
      Specified by:
      setTranslatedLabel in interface IFacetItem
      Parameters:
      translatedLabel - ignored; translations are computed dynamically from label
    • getCount

      public long getCount()
      Getter for the field count.
      Specified by:
      getCount in interface IFacetItem
      Returns:
      the number of search results matching this facet value
    • setCount

      public FacetItem setCount(long count)
      Setter for the field count.
      Specified by:
      setCount in interface IFacetItem
      Parameters:
      count - the number of search results matching this facet value
      Returns:
      this
    • increaseCount

      public void increaseCount(long amount)
    • isGroup

      public boolean isGroup()
      Specified by:
      isGroup in interface IFacetItem
    • setGroup

      public IFacetItem setGroup(boolean group)
      Specified by:
      setGroup in interface IFacetItem
    • isHierarchial

      public boolean isHierarchial()
      isHierarchial.
      Specified by:
      isHierarchial in interface IFacetItem
      Returns:
      true if this facet item belongs to a hierarchical facet field, false otherwise
    • isBooleanType

      public boolean isBooleanType()
      Specified by:
      isBooleanType in interface IFacetItem
    • toString

      public String toString()
      Overrides:
      toString in class Object