Package io.goobi.viewer.model.search
Class FacetItem
java.lang.Object
io.goobi.viewer.model.search.FacetItem
- All Implemented Interfaces:
IFacetItem,Serializable
Represents a single facet value with its display label, hit count, and selection state.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the structural types of a facet field, determining how its values are queried, displayed, and filtered in the search UI. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new FacetItem for active facets received via the URL.Creates a new FacetItem for active facets received via the URL.FacetItem(org.apache.solr.client.solrj.response.FacetField.Count count) -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic List<IFacetItem> generateFacetItems(String field, Map<String, Long> values, boolean sort, boolean reverseOrder, boolean hierarchical) Constructs a list of FilterLink objects for faceting.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.longgetCount()Getter for the fieldcount.Link after slash/backslash replacements for partner collection, static drill-down components and topic browsing (HU Berlin).getField()Getter for the fieldfield.getFullValue.getLabel()Getter for the fieldlabel.getLink()Getter for the fieldlink.Returns field:value (with the value escaped for the Solr query).Getter for the fieldtranslatedLabel.getType()URL escaped link for using in search drill-downs.getValue()Getter for the fieldvalue.Getter for the fieldvalue2.inthashCode()voidincreaseCount(long amount) booleanbooleanisGroup()booleanisHierarchial.setCount(long count) Setter for the fieldcount.voidSetter for the fieldfield.setGroup(boolean group) Setter for the fieldlabel.voidSetter for the fieldlink.voidsetTranslatedLabel(String translatedLabel) Dummy setter to fulfill the interface contract.voidsetType(FacetItem.FacetType type) voidSetter for the fieldvalue.voidSetter for the fieldvalue2.toString()
-
Constructor Details
-
FacetItem
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 parsehierarchical- true if this is a hierarchical facet
-
FacetItem
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 parselabel- display label; null to use the value as labelhierarchical- 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() -
equals
-
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 itemsfield- Facet fieldvalues- Map containing facet values and their countshierarchical- true if facet field is hierarchical; false otherwisegroupToLength- 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:
ArrayListofFacetItem
-
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 namevalues- map of facet values to their document countssort- if true, sort items by value before returningreverseOrder- if true, reverse the sort orderhierarchical- true if facet field is hierarchical- Returns:
- a list of facet items generated from the given values map, optionally sorted
-
getQueryEscapedLink
Returns field:value (with the value escaped for the Solr query).- Specified by:
getQueryEscapedLinkin interfaceIFacetItem- Returns:
- the Solr filter query string for this facet item, with field and value properly escaped
-
getEscapedLink
Link after slash/backslash replacements for partner collection, static drill-down components and topic browsing (HU Berlin).- Specified by:
getEscapedLinkin interfaceIFacetItem- Returns:
- the facet link with critical URL characters escaped
-
getUrlEscapedLink
URL escaped link for using in search drill-downs.- Specified by:
getUrlEscapedLinkin interfaceIFacetItem- Returns:
- the URL-encoded facet link for use in drill-down search URLs
-
getType
- Specified by:
getTypein interfaceIFacetItem
-
setType
-
getField
Getter for the fieldfield.- Specified by:
getFieldin interfaceIFacetItem- Returns:
- the Solr field name this facet item belongs to
-
setField
Setter for the fieldfield.- Specified by:
setFieldin interfaceIFacetItem- Parameters:
field- the Solr field name this facet item belongs to
-
getFullValue
getFullValue.- Specified by:
getFullValuein interfaceIFacetItem- Returns:
- Range of value - value2; just value if value2 empty
-
getValue
Getter for the fieldvalue.- Specified by:
getValuein interfaceIFacetItem- Returns:
- the facet value string
-
setValue
Setter for the fieldvalue.- Specified by:
setValuein interfaceIFacetItem- Parameters:
value- the facet value string
-
getValue2
Getter for the fieldvalue2.- Specified by:
getValue2in interfaceIFacetItem- Returns:
- the upper bound value for range facets
-
setValue2
Setter for the fieldvalue2.- Specified by:
setValue2in interfaceIFacetItem- Parameters:
value2- the upper bound value for range facets
-
getLink
Getter for the fieldlink.- Specified by:
getLinkin interfaceIFacetItem- Returns:
- the colon-separated field:value string used as the facet link
-
setLink
Setter for the fieldlink.- Specified by:
setLinkin interfaceIFacetItem- Parameters:
link- the colon-separated field:value string used as the facet link
-
getLabel
Getter for the fieldlabel.- Specified by:
getLabelin interfaceIFacetItem- Returns:
- the display label for this facet item
-
setLabel
Setter for the fieldlabel.- Specified by:
setLabelin interfaceIFacetItem- Parameters:
label- the display label for this facet item- Returns:
- this
-
getTranslatedLabel
Getter for the fieldtranslatedLabel.- Specified by:
getTranslatedLabelin interfaceIFacetItem- Returns:
- the translated label if translation is configured for this field, otherwise the raw label
-
setTranslatedLabel
Dummy setter to fulfill the interface contract.- Specified by:
setTranslatedLabelin interfaceIFacetItem- Parameters:
translatedLabel- ignored; translations are computed dynamically fromlabel
-
getCount
public long getCount()Getter for the fieldcount.- Specified by:
getCountin interfaceIFacetItem- Returns:
- the number of search results matching this facet value
-
setCount
Setter for the fieldcount.- Specified by:
setCountin interfaceIFacetItem- 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:
isGroupin interfaceIFacetItem
-
setGroup
- Specified by:
setGroupin interfaceIFacetItem
-
isHierarchial
public boolean isHierarchial()isHierarchial.- Specified by:
isHierarchialin interfaceIFacetItem- Returns:
- true if this facet item belongs to a hierarchical facet field, false otherwise
-
isBooleanType
public boolean isBooleanType()- Specified by:
isBooleanTypein interfaceIFacetItem
-
toString
-