Class Facet


  • @XStreamConverter(com.funnelback.publicui.xml.FacetConverter.class)
    public class Facet
    extends java.lang.Object

    Facets, generated from the result data (Metadata counts, GScope counts, URL counts).

    Since:
    11.0
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Facet.Category
      Category of a facet, such as "Location, based on the metadata class X".
      static class  Facet.CategoryValue
      Value of a facet category, such as "Location = Sydney".
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<Facet.Category> categories
      Categories definitions of this facet, for example a GScope category, or a Metadata field fill category.
      private @NotNull com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin  
      private java.util.Comparator<Facet.CategoryValue> customComparator
      If non-null this comparator will be used to sort values returned by the getAllValues(), getSelectedValues() and Facet#getUnselectedValues() methods.
      private java.util.Map<java.lang.String,​java.lang.Object> customData
      Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.
      private @NotNull com.funnelback.common.facetednavigation.models.FacetValues facetValues  
      private @NotNull FacetDisplayType guessedDisplayType
      The guessed type of the facet based on its configuration.
      private java.lang.String name
      Facet name, for example "Location"
      private @NotNull java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order  
      private @NotNull com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType  
      private java.lang.String unselectAllUrl
      URL to use to unselect all possible values of this facet, built from the current URL
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        Facet​(java.lang.String name)
      Deprecated.
        Facet​(java.lang.String name, com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType, com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin, com.funnelback.common.facetednavigation.models.FacetValues facetValues, java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order)  
      protected Facet​(java.lang.String name, java.lang.String unselectAllUrl, com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType, com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin, java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order, com.funnelback.common.facetednavigation.models.FacetValues facetValues, FacetDisplayType guessedDisplayType, java.util.Comparator<Facet.CategoryValue> customComparator)  
    • Field Detail

      • name

        private java.lang.String name
        Facet name, for example "Location"
      • unselectAllUrl

        private java.lang.String unselectAllUrl
        URL to use to unselect all possible values of this facet, built from the current URL

        The URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.

      • categories

        private final java.util.List<Facet.Category> categories
        Categories definitions of this facet, for example a GScope category, or a Metadata field fill category.

        This should not be used when displaying facets. Instead use allValues and selectedValues.

      • customData

        private final java.util.Map<java.lang.String,​java.lang.Object> customData
        Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.
      • selectionType

        @NotNull
        @NonNull
        private @NotNull com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType
        Since:
        15.12
      • constraintJoin

        @NotNull
        @NonNull
        private @NotNull com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin
        Since:
        15.12
      • order

        @NotNull
        @NonNull
        private @NotNull java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order
        Since:
        15.12
      • facetValues

        @NotNull
        @NonNull
        private @NotNull com.funnelback.common.facetednavigation.models.FacetValues facetValues
        Since:
        15.12
      • guessedDisplayType

        @NotNull
        @NonNull
        private @NotNull FacetDisplayType guessedDisplayType
        The guessed type of the facet based on its configuration.

        This value can give an indication of how the facet should be displayed, for example SINGLE select where values come from a UNSCOPED query would give the value RADIO_BUTTON. The UI could use this to show the facets as radio buttons.

        If the guessedType is not the way you intend to show the facet you should ignore this value and instead use the facet name or other fields which describe the facet to work out what should be shown i.e. don't have code which is if(guessedType == TAB) then show the facet as checkboxes.

        Newer versions of Funnelback may change how the type is guessed.

        Since:
        15.12
      • customComparator

        private java.util.Comparator<Facet.CategoryValue> customComparator
        If non-null this comparator will be used to sort values returned by the getAllValues(), getSelectedValues() and Facet#getUnselectedValues() methods.

        This currently does not sort the values returned by any other method such as the values in what is returned by getCategories() although this may change.

        Since:
        15.12
    • Constructor Detail

      • Facet

        public Facet​(java.lang.String name,
                     com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType,
                     com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin,
                     com.funnelback.common.facetednavigation.models.FacetValues facetValues,
                     java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order)
      • Facet

        @Deprecated
        public Facet​(java.lang.String name)
        Deprecated.
        Backwards compatible constructor so the stencils facet will continue to work.
        Parameters:
        name -
      • Facet

        protected Facet​(java.lang.String name,
                        java.lang.String unselectAllUrl,
                        @NonNull
                        com.funnelback.common.facetednavigation.models.FacetSelectionType selectionType,
                        @NonNull
                        com.funnelback.common.facetednavigation.models.FacetConstraintJoin constraintJoin,
                        @NonNull
                        java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order,
                        @NonNull
                        com.funnelback.common.facetednavigation.models.FacetValues facetValues,
                        @NonNull
                        FacetDisplayType guessedDisplayType,
                        java.util.Comparator<Facet.CategoryValue> customComparator)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSelectedValues

        public java.util.List<Facet.CategoryValue> getSelectedValues()
        Returns:
        List of selected values, useful to build breadcrumbs
      • getAllValues

        public java.util.List<Facet.CategoryValue> getAllValues()
        Returns:
        List of all facet values both selected and unselected.
      • hasValues

        public boolean hasValues()
        Recursively check if this facet has any value at all.
        Returns:
        true if the facet possess at least one value.
      • findDeepestCategory

        public Facet.Category findDeepestCategory​(java.util.List<java.lang.String> categoryParamNames)
        Recursively finds the deepest category.
        Parameters:
        categoryParamNames -
        Returns:
        The deepest Facet.Category matching the parameter names.
      • comparatorForSorting

        private final java.util.Comparator<Facet.CategoryValue> comparatorForSorting()
      • isSelected

        public boolean isSelected()
        Returns:
        True if any of the values of this facet is selected
      • getName

        public java.lang.String getName()
        Facet name, for example "Location"
      • setName

        public void setName​(java.lang.String name)
        Facet name, for example "Location"
      • getUnselectAllUrl

        public java.lang.String getUnselectAllUrl()
        URL to use to unselect all possible values of this facet, built from the current URL

        The URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.

      • setUnselectAllUrl

        public void setUnselectAllUrl​(java.lang.String unselectAllUrl)
        URL to use to unselect all possible values of this facet, built from the current URL

        The URL is one where the facet is not selected, the URL may be used as the base URL to append to to select values within the facet.

      • getCategories

        public java.util.List<Facet.Category> getCategories()
        Categories definitions of this facet, for example a GScope category, or a Metadata field fill category.

        This should not be used when displaying facets. Instead use allValues and selectedValues.

      • getCustomData

        public java.util.Map<java.lang.String,​java.lang.Object> getCustomData()
        Custom data placeholder allowing any arbitrary data to be stored for this facet by hook scripts.
      • getSelectionType

        @NonNull
        public com.funnelback.common.facetednavigation.models.FacetSelectionType getSelectionType()
        Since:
        15.12
      • getConstraintJoin

        @NonNull
        public com.funnelback.common.facetednavigation.models.FacetConstraintJoin getConstraintJoin()
        Since:
        15.12
      • getOrder

        @NonNull
        public java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> getOrder()
        Since:
        15.12
      • setOrder

        public void setOrder​(@NonNull
                             java.util.List<com.funnelback.common.facetednavigation.models.FacetValuesOrder> order)
        Since:
        15.12
      • getFacetValues

        @NonNull
        public com.funnelback.common.facetednavigation.models.FacetValues getFacetValues()
        Since:
        15.12
      • getGuessedDisplayType

        @NonNull
        public FacetDisplayType getGuessedDisplayType()
        The guessed type of the facet based on its configuration.

        This value can give an indication of how the facet should be displayed, for example SINGLE select where values come from a UNSCOPED query would give the value RADIO_BUTTON. The UI could use this to show the facets as radio buttons.

        If the guessedType is not the way you intend to show the facet you should ignore this value and instead use the facet name or other fields which describe the facet to work out what should be shown i.e. don't have code which is if(guessedType == TAB) then show the facet as checkboxes.

        Newer versions of Funnelback may change how the type is guessed.

        Since:
        15.12
      • getCustomComparator

        public java.util.Comparator<Facet.CategoryValue> getCustomComparator()
        If non-null this comparator will be used to sort values returned by the getAllValues(), getSelectedValues() and Facet#getUnselectedValues() methods.

        This currently does not sort the values returned by any other method such as the values in what is returned by getCategories() although this may change.

        Since:
        15.12
      • setCustomComparator

        public void setCustomComparator​(java.util.Comparator<Facet.CategoryValue> customComparator)
        If non-null this comparator will be used to sort values returned by the getAllValues(), getSelectedValues() and Facet#getUnselectedValues() methods.

        This currently does not sort the values returned by any other method such as the values in what is returned by getCategories() although this may change.

        Since:
        15.12