Class CategoryDefinition
- java.lang.Object
-
- com.funnelback.publicui.search.model.collection.facetednavigation.CategoryDefinition
-
- Direct Known Subclasses:
AllDocumentsFill,CollectionFill,DateFieldFill,GScopeItem,MetadataFieldFill,URLFill
public abstract class CategoryDefinition extends java.lang.ObjectCategory definition for faceted navigation.
A category definition possess a label (Ex: "Cities") and defines the way the values will be generated (Ex: "Take all the existing values of the metadata class X").
- Since:
- 11.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCategoryDefinition.CountSupplierstatic classCategoryDefinition.FacetSearchDatastatic classCategoryDefinition.MetadataAndValueAggregate of a metadata class + a value.static interfaceCategoryDefinition.SearchResonseForCountSupplier
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringdataSpecific data for this category type.private FacetedNavigationPropertiesfacetedNavPropsprotected java.lang.StringfacetNameName of the facet containing this category typeprotected java.lang.StringlabelLabel of this category.private static org.apache.logging.log4j.Loggerlogstatic java.lang.StringMD_VALUE_SEPARATORSeparator used in PADRE results between a metadata field and its value (Ex: <rmc item="a:new south wales">)static java.lang.StringQS_PARAM_SEPARATORSeparator used in the query string parameters between a facet name and its specific configuration (metadatafield or gscope number).protected java.util.List<CategoryDefinition>subCategoriesList of nested category definitions
-
Constructor Summary
Constructors Constructor Description CategoryDefinition(java.lang.String data)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanallValuesDefinedByUser()Tells you if all the CategoryValues this CategoryDefiniton can produce are ones that must be set on the category by the user.abstract java.util.List<CategoryValueComputedDataHolder>computeData(SearchTransaction st, FacetDefinition fdef)java.util.List<Facet.CategoryValue>computeValues(SearchTransaction st, FacetDefinition fdef)Generates a list of correspondingFacet.CategoryValueby applying this category type rule over aResultPacket.java.util.Set<java.lang.String>getAllQueryStringParamNames()Recursively get the list of all query string parameters names used.java.lang.StringgetData()Specific data for this category type.java.lang.StringgetFacetName()Name of the facet containing this category typeprotected CategoryDefinition.FacetSearchDatagetFacetSearchData(SearchTransaction st, FacetDefinition facetDefinition)java.lang.StringgetLabel()Label of this category.protected java.util.List<FacetSelectedDetails>getMatchingFacetSelectedDetails(SearchQuestion question)abstract java.util.List<QueryProcessorOption<?>>getQueryProcessorOptions(SearchQuestion question)Get additional query processor options to apply for this category definition.abstract java.lang.StringgetQueryStringCategoryExtraPart()Gets the extra part of the query string param name e.g.java.lang.StringgetQueryStringParamName()Get the query string parameter name for this category.java.util.List<CategoryDefinition>getSubCategories()List of nested category definitionsprotected booleanmatches(FacetSelectedDetails facetSelectionDetails)Tests if the facetSelectionDetails matches this category definition.abstract booleanmatches(java.lang.String value, java.lang.String extraParams)Given the value of a query string parameter, and any extra parameters, whether this category types is relevant for this parameter.static CategoryDefinition.MetadataAndValueparseMetadata(java.lang.String item)Parses a String containing a metadata class and a value such as x:Red cars, to separated the metadata class from the value.abstract booleanselectedValuesAreNested()voidsetData(java.lang.String data)Specific data for this category type.voidsetFacetedNavProps(FacetedNavigationProperties facetedNavProps)voidsetFacetName(java.lang.String facetName)Name of the facet containing this category typevoidsetLabel(java.lang.String label)Label of this category.java.lang.StringtoString()
-
-
-
Field Detail
-
log
private static final org.apache.logging.log4j.Logger log
-
facetedNavProps
private FacetedNavigationProperties facetedNavProps
-
MD_VALUE_SEPARATOR
public static final java.lang.String MD_VALUE_SEPARATOR
Separator used in PADRE results between a metadata field and its value (Ex: <rmc item="a:new south wales">)
- See Also:
- Constant Field Values
-
QS_PARAM_SEPARATOR
public static final java.lang.String QS_PARAM_SEPARATOR
Separator used in the query string parameters between a facet name and its specific configuration (metadatafield or gscope number).
Ex: f.Location|a=new%20south%20wales- See Also:
- Constant Field Values
-
facetName
protected java.lang.String facetName
Name of the facet containing this category type
-
data
@NonNull protected java.lang.String data
Specific data for this category type.
Depending of the actual type, can be a metadata class, a query expression, etc.
-
label
protected java.lang.String label
Label of this category.
-
subCategories
protected final java.util.List<CategoryDefinition> subCategories
List of nested category definitions
-
-
Method Detail
-
getAllQueryStringParamNames
public java.util.Set<java.lang.String> getAllQueryStringParamNames()
Recursively get the list of all query string parameters names used.- Returns:
- The list of query string parameter names used by this category definition and all its nested definitions.
-
computeValues
public java.util.List<Facet.CategoryValue> computeValues(SearchTransaction st, FacetDefinition fdef)
Generates a list of corresponding
Facet.CategoryValueby applying this category type rule over aResultPacket.Used to generate categories values on the UI from the faceted navigation configuration.
The size of the list will depend of the type of the category:
- For "fill" types it will be a multivalued list (metadata field fill, etc.)
- For "item" types it will contain a single value (Gscope item, etc.)
- Parameters:
st- SearchTransaction to use to compute the values.- Returns:
- The computed values.
-
computeData
public abstract java.util.List<CategoryValueComputedDataHolder> computeData(SearchTransaction st, FacetDefinition fdef)
-
getQueryStringParamName
public final java.lang.String getQueryStringParamName()
Get the query string parameter name for this category.- Returns:
- the name of the query string parameter used to select this category (Ex: f.By Date|dc.date)
-
getQueryStringCategoryExtraPart
public abstract java.lang.String getQueryStringCategoryExtraPart()
Gets the extra part of the query string param name e.g. f.| =value. - Returns:
-
matches
public abstract boolean matches(java.lang.String value, java.lang.String extraParams)Given the value of a query string parameter, and any extra parameters, whether this category types is relevant for this parameter.
For example: f.By Date|dc.date=2010-01-01:
- value = 2010-01-01
- extra = dc.date
A category of type "metadata fill" for the "dc.date" metadata should return true.
- Parameters:
value- The value to check for.extraParams- The extra parameter to check for.- Returns:
- true if this category definition matches, false otherwise.
-
matches
protected boolean matches(FacetSelectedDetails facetSelectionDetails)
Tests if the facetSelectionDetails matches this category definition.- Parameters:
facetSelectionDetails-facetDef- The facet definition that this category definition is in.- Returns:
-
getMatchingFacetSelectedDetails
protected java.util.List<FacetSelectedDetails> getMatchingFacetSelectedDetails(SearchQuestion question)
-
getQueryProcessorOptions
public abstract java.util.List<QueryProcessorOption<?>> getQueryProcessorOptions(SearchQuestion question)
Get additional query processor options to apply for this category definition.
That gives the opportunity to the category definition to add additional QPOs that it may need. QPOs may differ depending if the facet is currently selected or not, such as setting
-count_urlsdynamically depending on the current number of segments in the URL drill down facet- Parameters:
question- Can be used to inspect the currently selected facets and return appropriate QPOs- Returns:
- A list of query processor options
-
allValuesDefinedByUser
public abstract boolean allValuesDefinedByUser()
Tells you if all the CategoryValues this CategoryDefiniton can produce are ones that must be set on the category by the user.Values defined by the user are ones like gscopes where values not from the user come from other sources such as metadata.
- Returns:
- true if all values are defined by the user and not generated from the data.
-
selectedValuesAreNested
public abstract boolean selectedValuesAreNested()
- Returns:
- true if returned selected values are nested.
-
parseMetadata
public static CategoryDefinition.MetadataAndValue parseMetadata(java.lang.String item)
Parses a String containing a metadata class and a value such as x:Red cars, to separated the metadata class from the value.
- Parameters:
item- Item to parse, containing the metadata class, a colon, and the value- Returns:
- The metadata + value
-
getFacetSearchData
protected CategoryDefinition.FacetSearchData getFacetSearchData(SearchTransaction st, FacetDefinition facetDefinition)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
setFacetedNavProps
public void setFacetedNavProps(FacetedNavigationProperties facetedNavProps)
-
getFacetName
public java.lang.String getFacetName()
Name of the facet containing this category type
-
setFacetName
public void setFacetName(java.lang.String facetName)
Name of the facet containing this category type
-
getData
@NonNull public java.lang.String getData()
Specific data for this category type.
Depending of the actual type, can be a metadata class, a query expression, etc.
-
setData
public void setData(@NonNull java.lang.String data)Specific data for this category type.
Depending of the actual type, can be a metadata class, a query expression, etc.
-
getLabel
public java.lang.String getLabel()
Label of this category.
-
setLabel
public void setLabel(java.lang.String label)
Label of this category.
-
getSubCategories
public java.util.List<CategoryDefinition> getSubCategories()
List of nested category definitions
-
-