Package org.ametys.cms.search.model
Class CriterionDefinitionHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.cms.search.model.CriterionDefinitionHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
Helper for
CriterionDefinition
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ModelItemTypeExtensionPoint
The extension point containing all available criterion typesstatic final String
The component role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetCriterionDefinitionDefaultWidget
(CriterionDefinition criterionDefinition) Retrieves the default widget for the given criterion definitiongetCriterionDefinitionDefaultWidgetParameters
(CriterionDefinition criterionDefinition) Retrieves the default widget parameters for the given criterion definition<T> IndexableElementType
<T> getCriterionDefinitionType
(String criterionTypeId) Retrieves the type implementation of the given criterion type identifier<T> I18nizableText
getFacetLabel
(CriterionDefinition<T> criterion, String value, Locale currentLocale) Get the label of a facet value for the given criterion.boolean
isQueryValueEmpty
(Object value) Check if the given query value is emptyparseCriterionDefinitionDefaultValue
(Configuration defaultValueConfig, ElementDefinition definition, String defaultValueType) Parses the criterion definition default value.void
service
(ServiceManager manager) wrapCriterionConfiguration
(Configuration originalConf, Set<ContentType> contentTypes) Wrap the given configuration to add content typesMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The component role. -
_criterionTypeExtensionPoint
The extension point containing all available criterion types
-
-
Constructor Details
-
CriterionDefinitionHelper
public CriterionDefinitionHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCriterionDefinitionType
Retrieves the type implementation of the given criterion type identifier- Type Parameters:
T
- the type of the criterion type- Parameters:
criterionTypeId
- the criterion type identifier- Returns:
- the criterion type implementation
-
getCriterionDefinitionDefaultWidget
Retrieves the default widget for the given criterion definition- Parameters:
criterionDefinition
- the criterion definition- Returns:
- the default widget for the given criterion definition
-
getCriterionDefinitionDefaultWidgetParameters
public Map<String,I18nizableText> getCriterionDefinitionDefaultWidgetParameters(CriterionDefinition criterionDefinition) Retrieves the default widget parameters for the given criterion definition- Parameters:
criterionDefinition
- the criterion definition- Returns:
- the default widget parameters for the given criterion definition
-
wrapCriterionConfiguration
public Configuration wrapCriterionConfiguration(Configuration originalConf, Set<ContentType> contentTypes) throws ConfigurationException Wrap the given configuration to add content types- Parameters:
originalConf
- the configuration to wrapcontentTypes
- the content types to add in wrapped configuration- Returns:
- the wrapped configuration
- Throws:
ConfigurationException
- if an error occurs
-
getFacetLabel
public <T> I18nizableText getFacetLabel(CriterionDefinition<T> criterion, String value, Locale currentLocale) Get the label of a facet value for the given criterion.- Type Parameters:
T
- the type of the facet criterion- Parameters:
criterion
- the criterionvalue
- the facet value.currentLocale
- the current locale- Returns:
- the label, or null if the value does not exist.
-
isQueryValueEmpty
Check if the given query value is empty- Parameters:
value
- the query value to check- Returns:
true
if the given query value is empty,false
otherwise
-
parseCriterionDefinitionDefaultValue
public Object parseCriterionDefinitionDefaultValue(Configuration defaultValueConfig, ElementDefinition definition, String defaultValueType) throws ConfigurationException Parses the criterion definition default value.- Parameters:
defaultValueConfig
- the default value configuration.definition
- the element definition.defaultValueType
- the type of the default value- Returns:
- the default value or
null
if none default value is defined. - Throws:
ConfigurationException
- if the configuration is not valid.
-