Package io.goobi.viewer.model.search
Class SearchFacets
java.lang.Object
io.goobi.viewer.model.search.SearchFacets
- All Implemented Interfaces:
Serializable
Current faceting settings for a search.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollapseFacet(String field) Sets the expanded flag tofalsefor the given facet field.voidexpandFacet(String field) Sets the expanded flag totruefor the given facet field.generateFacetFilterQueries(boolean includeRangeFacets) Generates a list containing filter queries for the selected regular and hierarchical facets.getAbsoluteMaxRangeValue(String field) Returns the maximum value for the given field available in the search index.getAbsoluteMinRangeValue(String field) Returns the minimum value for the given field available in the search index.Returns a snapshot copy of the currently active facet filters.Deprecated, for removal: This API element is subject to removal in a future version.getActiveFacetsForField(String field) Returns a list of FacetItem objects inactiveFacetswhere the field name matches the given field name.intintgetActiveFacetsSizeForField.Returns a URL encoded SSV string of facet fields and values from the elements inactiveFacets(hyphen if empty).Returns a URL encoded value returned by generateFacetPrefix() for regular facets.getActiveFacetStringPrefix(String omitField) getActiveFacetStringPrefix(List<String> omitFields, boolean urlEncode) Returns the value returned by generateFacetPrefix() for regular facets.Returns configured facet fields of regular and hierarchical type only.Getter for the fieldavailableFacets.getAvailableFacetsForField(String field, boolean excludeSelected) intReturns the size of the full element list of the facet for the given field.getConfiguredSubelementFacetFields.getCurrentMaxRangeValue(String field) getCurrentMaxRangeValue.getCurrentMinRangeValue(String field) getCurrentMinRangeValue.getFacetDescription(String field) getFacetDescription.getFacetValue(String field) getFacetValue.getFirstHierarchicalFacetDescription.getFirstHierarchicalFacetValue.getHierarchicalFacets(String facetString, List<String> facetFields) getHierarchicalFacets.Returns a collapsed sublist of the available facet elements for the given field.intgetRangeFacetMaxValue(String field) intgetRangeFacetMinValue(String field) getRangeFacetStyle(String field) Getter for the fieldtempValue.getValueRange(String field) Returns a sorted list of all available values for the given field among available facet values.getValueRangeAsJsonMap(String field) booleanbooleanReturns whetheractiveFacetsis empty without allocating a defensive copy.booleanisDisplayFacetCollapseLink(String field) isDisplayFacetCollapseLink.booleanisDisplayFacetExpandLink(String field) Returns true if the "(more)" link is to be displayed for a facet box.booleanisFacetCollapsed(String field) isFacetCollapsed.booleanisFacetCurrentlyUsed(IFacetItem facet) Checks whether the given facet is currently in use.booleanisFacetExpanded(String field) Returns true if the value for the given field type infacetsExpandedhas been previously set to true.booleanisFacetListSizeSufficient(String field) isFacetListSizeSufficient.booleanbooleanbooleanisHasWrongLanguageCode(String field, String language) Returns true if the givenfieldis language-specific to a different language than the givenlanguage.booleanisRangeFacetActive(String field) booleanChecks whether there are still selectable values across all available facet fields.voidremoveActiveFacets(Collection<? extends IFacetItem> facetsToRemove) Removes all given facet items fromactiveFacetsunder the correct lock.removeFacetAction(String facetQuery, String ret) removeFacetAction.voidresetCurrentFacets.voidresetActiveFacetString.voidresetAvailableFacets.voidresetSliderRange.voidsetActiveFacetString(String activeFacetString) Receives an SSV string of facet fields and values (FIELD1:value1;FIELD2:value2;FIELD3:value3) and generates new Elements for currentFacets.voidsetGeoFacetFeature(String feature) Sets the feature of the geoFacettingfield to to given feature.voidsetTempValue(String tempValue) Setter for the fieldtempValue.splitHierarchicalFacet(String facet) splitHierarchicalFacet.updateFacetItem(String field, boolean hierarchical) Updates existing facet item for the given field with a new value.
-
Constructor Details
-
SearchFacets
public SearchFacets()
-
-
Method Details
-
resetAvailableFacets
public void resetAvailableFacets()resetAvailableFacets. -
resetActiveFacets
public void resetActiveFacets()resetCurrentFacets. -
resetSliderRange
public void resetSliderRange()resetSliderRange. -
generateFacetFilterQueries
Generates a list containing filter queries for the selected regular and hierarchical facets.- Parameters:
includeRangeFacets- if true, range facet fields are included in the output- Returns:
- a list of Solr filter query strings for the currently active facets
-
getActiveFacetsForField
Returns a list of FacetItem objects inactiveFacetswhere the field name matches the given field name.- Parameters:
field- Solr facet field name to match against active facets- Returns:
- a list of active facet items that belong to the given Solr field
-
isFacetStringCurrentlyUsed
- Parameters:
link- facet query link string to look up in the active facets- Returns:
- true if given link is part of the active facet string; false otherwise
-
isFacetCurrentlyUsed
Checks whether the given facet is currently in use.- Parameters:
facet- facet item to check for active use- Returns:
- true if the given facet item is currently active (i.e. selected by the user), false otherwise
-
isFacetListSizeSufficient
isFacetListSizeSufficient.- Parameters:
field- Solr facet field name to check- Returns:
- true if the facet list for the given field has enough elements to be shown (more than one, or more than zero for DOCSTRCT_SUB), false otherwise
-
getAvailableFacetsListSizeForField
Returns the size of the full element list of the facet for the given field.- Parameters:
field- Solr facet field name to look up- Returns:
- a int.
-
getActiveFacetsSizeForField
getActiveFacetsSizeForField.- Parameters:
field- Solr facet field name to count active facets for- Returns:
- Size of
activeFacets.
-
getLimitedFacetListForField
Returns a collapsed sublist of the available facet elements for the given field.- Parameters:
field- Solr facet field name whose items to retrieve- Returns:
- a list of available facet items for the given field, trimmed to the configured display limit unless expanded
-
getAvailableFacetsForField
- Parameters:
field- Solr facet field name to look up in the available facets mapexcludeSelected- If true, selected facets will be removed from the list- Returns:
- List
-
getFacet
- Parameters:
field- Solr facet field name to search forvalue- facet value to match within the given field- 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
- Returns:
- true if any configured range facet field has a value range in the current search result; false otherwise
- Throws:
PresentationExceptionIndexUnreachableException
-
expandFacet
Sets the expanded flag totruefor the given facet field.- Parameters:
field- Solr facet field name to expand
-
collapseFacet
Sets the expanded flag tofalsefor the given facet field.- Parameters:
field- Solr facet field name to collapse
-
isDisplayFacetExpandLink
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- Solr facet field name to check expansion state for- Returns:
- true if the facet is collapsed and has more elements than the configured initial display count, false otherwise
-
isDisplayFacetCollapseLink
isDisplayFacetCollapseLink.- Parameters:
field- Solr facet field name to check expansion state for- Returns:
- true if the facet for the given field is currently expanded and a collapse link should be shown, false otherwise
-
getActiveFacetString
Returns a URL encoded SSV string of facet fields and values from the elements inactiveFacets(hyphen if empty).- Returns:
- SSV string of facet queries or "-" if empty
-
setActiveFacetString
Receives an SSV string of facet fields and values (FIELD1:value1;FIELD2:value2;FIELD3:value3) and generates new Elements for currentFacets.- Parameters:
activeFacetString- SSV-encoded string of active facet field:value pairs
-
updateFacetItem
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- Solr facet field name whose item to updatehierarchical- if true, the facet item is marked as hierarchical- Returns:
- the JSF navigation outcome after updating the facet (e.g. "pretty:search6")
-
getHierarchicalFacets
getHierarchicalFacets.- Parameters:
facetString- SSV-encoded string of active facet field:value pairsfacetFields- list of hierarchical facet field names to extract values for- Returns:
- a list of hierarchical facet values extracted from the facet string for the given fields
-
splitHierarchicalFacet
splitHierarchicalFacet.- Parameters:
facet- hierarchical facet value string to split into path segments- Returns:
- a list of hierarchical path segment strings from the root level down to the given facet value
-
getCurrentMinRangeValue
public String getCurrentMinRangeValue(String field) throws PresentationException, IndexUnreachableException getCurrentMinRangeValue.- Parameters:
field- Solr range facet field name to look up- 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- Solr range facet field name to look up- 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- Solr range facet field name to look up- 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- Solr range facet field name to look up- 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- Solr range facet field name to look up- Returns:
- sorted list of all values for the given field among available facet values
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getValueRangeAsJsonMap
- Parameters:
field- Solr range facet field name whose value range to serialize- Returns:
String
-
isRangeFacetActive
- Parameters:
field- Solr range facet field name to check for an active range constraint- Returns:
- true if active range for field is currently smaller than the absolute range; false otherwise
-
resetActiveFacetString
public void resetActiveFacetString()resetActiveFacetString. -
getActiveFacetStringPrefix
Returns a URL encoded value returned by generateFacetPrefix() for regular facets. Returns an empty string instead a hyphen if empty.- Returns:
- the URL-encoded active facet string prefix for non-hierarchical facets
-
getActiveFacetStringPrefix
- Parameters:
omitField- Field name to not include in the string- Returns:
Stringobject.
-
getActiveFacetStringPrefix
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 stringurlEncode- if true, the resulting string is URL-encoded- Returns:
- URL part for currently selected facets; empty string if empty
-
removeFacetAction
removeFacetAction.- Parameters:
facetQuery- facet query string to remove from active facetsret- navigation outcome string to return after removal- Returns:
- the navigation outcome string after removing the facet
-
isFacetExpanded
Returns true if the value for the given field type infacetsExpandedhas been previously set to true.- Parameters:
field- Solr facet field name to check- Returns:
- true if the facet for the given field has been explicitly expanded, false otherwise
-
isFacetCollapsed
isFacetCollapsed.- Parameters:
field- Solr facet field name to check- Returns:
- true if the facet for the given field is not expanded (i.e. collapsed), false otherwise
-
getAllRangeFacetFields
- Returns:
- All facet field names of the type "range"
-
getRangeFacetStyle
- Parameters:
field- Solr range facet field name whose visualization style to retrieve- Returns:
- Visualization style for the given range field
-
getRangeFacetMinValue
- Parameters:
field- Solr range facet field name whose configured minimum to retrieve- Returns:
- Configured min value for the given field
-
getRangeFacetMaxValue
- Parameters:
field- Solr range facet field name whose configured maximum to retrieve- Returns:
- Configured max value for the given field
-
getAllAvailableFacets
Returns configured facet fields of regular and hierarchical type only.- Returns:
- a map of facet field name to facet items for all regular and hierarchical facet fields
-
hasAvailableFacets
public boolean hasAvailableFacets() -
getConfiguredSubelementFacetFields
getConfiguredSubelementFacetFields.- Returns:
- Configured subelement fields names only
-
getAvailableFacets
Getter for the fieldavailableFacets.- Returns:
- the map of Solr field names to their available facet items
-
getActiveFacets
Returns a snapshot copy of the currently active facet filters.Returns a defensive copy so that callers (e.g. JSF
c:forEachtemplates) cannot receive aConcurrentModificationExceptionif a concurrent request modifies the list. Uses the samelockobject as all write operations so that the copy is taken atomically with respect to any concurrentsetActiveFacetString(java.lang.String)orsetGeoFacetFeature(java.lang.String)call.- Returns:
- a new, mutable
ArrayListsnapshot of the active facet filters; nevernull
-
getActiveFacetsCopy
Deprecated, for removal: This API element is subject to removal in a future version.UsegetActiveFacets()which now already returns a defensive copy.Get a shallow copy ofactiveFacets.- Returns:
- a new ArrayList containing all activeFacets
-
removeActiveFacets
Removes all given facet items fromactiveFacetsunder the correct lock.- Parameters:
facetsToRemove- collection of facet items to remove; must not benull
-
isActiveFacetsEmpty
public boolean isActiveFacetsEmpty()Returns whetheractiveFacetsis empty without allocating a defensive copy.- Returns:
trueif no active facets are set;falseotherwise
-
getTempValue
Getter for the fieldtempValue.- Returns:
- the temporary value held during facet editing before it is applied
-
setTempValue
Setter for the fieldtempValue.- Parameters:
tempValue- a temporary value held during facet editing before it is applied
-
isHasWrongLanguageCode
Returns true if the givenfieldis language-specific to a different language than the givenlanguage.- Parameters:
field- Solr field name to test for a language code suffixlanguage- BCP 47 language code to compare against the field suffix- Returns:
- true if the field has a language code suffix that does not match the given language and no active facet is selected for it, false otherwise
-
getFacetValue
getFacetValue.- Parameters:
field- Solr facet field name whose active value to retrieve- Returns:
- the active facet value for the given field, or an empty string if no active facet exists for that field
-
getFacetDescription
getFacetDescription.- Parameters:
field- Solr facet field name whose active description to retrieve- Returns:
- the CMS collection description for the active facet of the given field, or an empty string if not found
-
getFirstHierarchicalFacetValue
getFirstHierarchicalFacetValue.- Returns:
- the value of the first active hierarchical facet, or an empty string if none exist
-
getFirstHierarchicalFacetDescription
getFirstHierarchicalFacetDescription.- Parameters:
field- Solr facet field name (unused; description taken from first hierarchical active facet)- Returns:
- the CMS collection description for the first active hierarchical facet, or an empty string if none exist
-
getLabelMap
-
getGeoFacetting
-
setGeoFacetFeature
Sets the feature of the geoFacettingfield to to given feature. A new GeoFacetItem is added to currentFacets if none exists yet- Parameters:
feature- GeoJSON feature string defining the geographic filter area
-
getGeoFacetFeature
-
getActiveFacetsSize
public int getActiveFacetsSize()
-
getActiveFacets()which now already returns a defensive copy.