Package io.goobi.viewer.model.search
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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SearchFacets()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
collapseFacet(String field)
Sets the expanded flag tofalse
for the given facet field.void
expandFacet(String field)
Sets the expanded flag totrue
for the given facet field.List<String>
generateFacetFilterQueries(boolean includeRangeFacets)
Generates a list containing filter queries for the selected regular and hierarchical facets.String
getAbsoluteMaxRangeValue(String field)
Returns the maximum value for the given field available in the search index.String
getAbsoluteMinRangeValue(String field)
Returns the minimum value for the given field available in the search index.Map<String,List<IFacetItem>>
getAllAvailableFacets()
getAllAvailableFacets.Map<String,List<IFacetItem>>
getAvailableFacets()
Getter for the fieldavailableFacets
.int
getAvailableFacetsListSizeForField(String field)
Returns the size of the full element list of the facet for the given field.List<String>
getConfiguredSubelementFacetFields()
getConfiguredSubelementFacetFields.IFacetItem
getCurrentFacetForField(String field)
Returns the first FacetItem objects incurrentFacets
where the field name matches the given field name.List<IFacetItem>
getCurrentFacets()
Getter for the fieldcurrentFacets
.List<IFacetItem>
getCurrentFacetsForField(String field)
Returns a list of FacetItem objects incurrentFacets
where the field name matches the given field name.int
getCurrentFacetsSizeForField(String field)
getCurrentFacetsSizeForField.String
getCurrentFacetString()
Returns a URL encoded SSV string of facet fields and values from the elements in currentFacets (hyphen if empty).String
getCurrentFacetString(boolean urlEncode)
getCurrentFacetString.String
getCurrentFacetStringPrefix()
Returns a URL encoded value returned by generateFacetPrefix() for regular facets.String
getCurrentFacetStringPrefix(boolean urlEncode)
Returns the value returned by generateFacetPrefix() for regular facets.String
getCurrentMaxRangeValue(String field)
getCurrentMaxRangeValue.String
getCurrentMinRangeValue(String field)
getCurrentMinRangeValue.String
getFacetDescription(String field)
getFacetDescription.int
getFacetElementDisplayNumber(String field)
Deprecated.Check whether still in useString
getFacetValue(String field)
getFacetValue.String
getFirstHierarchicalFacetDescription(String field)
getFirstHierarchicalFacetDescription.String
getFirstHierarchicalFacetValue()
getFirstHierarchicalFacetValue.String
getGeoFacetFeature()
GeoFacetItem
getGeoFacetting()
static List<String>
getHierarchicalFacets(String facetString, List<String> facetFields)
getHierarchicalFacets.Map<String,String>
getLabelMap()
List<IFacetItem>
getLimitedFacetListForField(String field)
Returns a collapsed sublist of the available facet elements for the given field.String
getTempValue()
Getter for the fieldtempValue
.List<Integer>
getValueRange(String field)
Returns a sorted list of all available values for the given field among available facet values.boolean
isDisplayFacetCollapseLink(String field)
isDisplayFacetCollapseLink.boolean
isDisplayFacetExpandLink(String field)
Returns true if the "(more)" link is to be displayed for a facet box.boolean
isFacetCollapsed(String field)
isFacetCollapsed.boolean
isFacetCurrentlyUsed(IFacetItem facet)
Checks whether the given facet is currently in use.boolean
isFacetExpanded(String field)
Returns true if the value for the given field type infacetsExpanded
has been previously set to true.boolean
isFacetListSizeSufficient(String field)
isFacetListSizeSufficient.boolean
isHasWrongLanguageCode(String field, String language)
Returns true if the givenfield
is language-specific to a different language than the givenlanguage
.String
removeFacetAction(String facetQuery, String ret)
removeFacetAction.void
resetAvailableFacets()
resetAvailableFacets.void
resetCurrentFacets()
resetCurrentFacets.void
resetCurrentFacetString()
resetCurrentFacetString.void
resetSliderRange()
resetSliderRange.void
setCurrentFacetString(String currentFacetString)
Receives an SSV string of facet fields and values (FIELD1:value1;FIELD2:value2;FIELD3:value3) and generates new Elements for currentFacets.void
setGeoFacetFeature(String feature)
Sets the feature of the geoFacettingfield to to given feature.void
setTempValue(String tempValue)
Setter for the fieldtempValue
.static List<String>
splitHierarchicalFacet(String facet)
splitHierarchicalFacet.String
updateFacetItem(String field, boolean hierarchical)
Updates existing facet item for the given field with a new value.
-
-
-
Method Detail
-
resetAvailableFacets
public void resetAvailableFacets()
resetAvailableFacets.
-
resetCurrentFacets
public void resetCurrentFacets()
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:
advancedSearchGroupOperator
- a int.includeRangeFacets
- a boolean.- Returns:
- a
List
object.
-
getCurrentFacetForField
public IFacetItem getCurrentFacetForField(String field)
Returns the first FacetItem objects incurrentFacets
where the field name matches the given field name.- Parameters:
field
- The field name to match.- Returns:
- a
FacetItem
object.
-
getCurrentFacetsForField
public List<IFacetItem> getCurrentFacetsForField(String field)
Returns a list of FacetItem objects incurrentFacets
where the field name matches the given field name.- Parameters:
field
- The field name to match.- Returns:
- a
List
object.
-
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
- aString
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
- aString
object.- Returns:
- a int.
-
getCurrentFacetsSizeForField
public int getCurrentFacetsSizeForField(String field)
getCurrentFacetsSizeForField.
- Parameters:
field
- aString
object.- Returns:
- Size of
currentFacets
.
-
getLimitedFacetListForField
public List<IFacetItem> getLimitedFacetListForField(String field)
Returns a collapsed sublist of the available facet elements for the given field.
-
getFacetElementDisplayNumber
@Deprecated public int getFacetElementDisplayNumber(String field)
Deprecated.Check whether still in useIf the facet for given field is expanded, return the size of the facet, otherwise the initial (collapsed) number of elements as configured.- Parameters:
field
- aString
object.- Returns:
- a int.
-
expandFacet
public void expandFacet(String field)
Sets the expanded flag totrue
for the given facet field.- Parameters:
field
- aString
object.
-
collapseFacet
public void collapseFacet(String field)
Sets the expanded flag tofalse
for the given facet field.- Parameters:
field
- aString
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
- aString
object.- Returns:
- a boolean.
-
isDisplayFacetCollapseLink
public boolean isDisplayFacetCollapseLink(String field)
isDisplayFacetCollapseLink.
- Parameters:
field
- aString
object.- Returns:
- a boolean.
-
getCurrentFacetString
public String getCurrentFacetString()
Returns a URL encoded SSV string of facet fields and values from the elements in currentFacets (hyphen if empty).- Returns:
- SSV string of facet queries or "-" if empty
-
getCurrentFacetString
public String getCurrentFacetString(boolean urlEncode)
getCurrentFacetString.
- Parameters:
urlEncode
- a boolean.- Returns:
- a
String
object.
-
setCurrentFacetString
public void setCurrentFacetString(String currentFacetString)
Receives an SSV string of facet fields and values (FIELD1:value1;FIELD2:value2;FIELD3:value3) and generates new Elements for currentFacets.- Parameters:
currentFacetString
- aString
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.
-
getHierarchicalFacets
public static List<String> getHierarchicalFacets(String facetString, List<String> facetFields)
getHierarchicalFacets.
-
splitHierarchicalFacet
public static List<String> splitHierarchicalFacet(String facet)
splitHierarchicalFacet.
-
getCurrentMinRangeValue
public String getCurrentMinRangeValue(String field) throws PresentationException, IndexUnreachableException
getCurrentMinRangeValue.
- Parameters:
field
- aString
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
- aString
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
- aString
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
- aString
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
- aString
object.- Returns:
- sorted list of all values for the given field among available facet values
- Throws:
PresentationException
- if any.IndexUnreachableException
- if any.
-
resetCurrentFacetString
public void resetCurrentFacetString()
resetCurrentFacetString.
-
getCurrentFacetStringPrefix
public String getCurrentFacetStringPrefix()
Returns a URL encoded value returned by generateFacetPrefix() for regular facets. Returns an empty string instead a hyphen if empty.- Returns:
- a
String
object.
-
getCurrentFacetStringPrefix
public String getCurrentFacetStringPrefix(boolean urlEncode)
Returns the value returned by generateFacetPrefix() for regular facets. Returns an empty string instead a hyphen if empty.- Parameters:
urlEncode
-- Returns:
-
removeFacetAction
public String removeFacetAction(String facetQuery, String ret)
removeFacetAction.
-
isFacetExpanded
public boolean isFacetExpanded(String field)
Returns true if the value for the given field type infacetsExpanded
has been previously set to true.- Parameters:
field
- aString
object.- Returns:
- a boolean.
-
isFacetCollapsed
public boolean isFacetCollapsed(String field)
isFacetCollapsed.
- Parameters:
field
- aString
object.- Returns:
- a boolean.
-
getAllAvailableFacets
public Map<String,List<IFacetItem>> getAllAvailableFacets()
getAllAvailableFacets.
- Returns:
- a
Map
object.
-
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
-
getCurrentFacets
public List<IFacetItem> getCurrentFacets()
Getter for the field
currentFacets
.- Returns:
- the currentFacets
-
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 givenfield
is language-specific to a different language than the givenlanguage
.
-
getFirstHierarchicalFacetValue
public String getFirstHierarchicalFacetValue()
getFirstHierarchicalFacetValue.
- Returns:
- a
String
object.
-
getFirstHierarchicalFacetDescription
public String getFirstHierarchicalFacetDescription(String field)
getFirstHierarchicalFacetDescription.
-
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()
-
-