Class CriterionTreeSearchComponent
- java.lang.Object
-
- org.ametys.web.frontoffice.search.requesttime.impl.CriterionTreeSearchComponent
-
- All Implemented Interfaces:
SearchComponent
,Serviceable
- Direct Known Subclasses:
MatchingSubprogramSearchComponent
public class CriterionTreeSearchComponent extends Object implements SearchComponent, Serviceable
-
-
Field Summary
Fields Modifier and Type Field Description protected static Query
__EMPTY_QUERY
TheQuery
building to the empty stringprotected AdvancedQueryBuilder
_advancedQueryBuilder
The builder of advanced queriesprotected I18nUtils
_i18nUtils
The utils for i18nizable textsprotected TreeMaker
_treeMaker
The Advanced tree maker-
Fields inherited from interface org.ametys.web.frontoffice.search.requesttime.SearchComponent
DISABLE_DEFAULT_SAX_PARAMETER_NAME, MAX_PRIORITY, MIN_PRIORITY, SEARCH_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description CriterionTreeSearchComponent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Map<String,Object>
_contextualParameters(Site currentSite)
private void
_logTree(org.slf4j.Logger logger, AbstractTreeNode<FOSearchCriterion> tree, Map<String,Object> userCriteria)
private Query
_queryFromTransformedValAndRealOperator(SearchCriterionDefinition criterionDefinition, Object transformedVal, Query.Operator realOperator, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
protected Query
buildQuery(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
Builds the query of the criterion treeprotected void
checkValidInputs(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria)
Checks the user inputs are validprotected void
checkValidInputSingleValue(Object userCriterionSingleValue, String criterionId, FOSearchCriterionMode mode, Optional<EnumeratedValues.RestrictedValues> optionalRestrictedValues, Validator validator)
Checks a single value of one user input for one criterion is validprotected void
checkValidInputValues(Object userCriterionValues, String criterionId, FOSearchCriterionMode mode, Optional<EnumeratedValues.RestrictedValues> optionalRestrictedValues, Validator validator)
Checks the user inputs for one criterion (can be multiple) are validvoid
execute(SearchComponentArguments args)
Executes the component.int
priority()
Get the priority of the component.void
service(ServiceManager manager)
protected Query
singleCriterionToQuery(FOSearchCriterion searchCriterion, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
Builds the query of the single criterionboolean
supports(SearchComponentArguments args)
Returnstrue
if the component must beexecuted
.
-
-
-
Field Detail
-
__EMPTY_QUERY
protected static final Query __EMPTY_QUERY
TheQuery
building to the empty string
-
_i18nUtils
protected I18nUtils _i18nUtils
The utils for i18nizable texts
-
_advancedQueryBuilder
protected AdvancedQueryBuilder _advancedQueryBuilder
The builder of advanced queries
-
_treeMaker
protected TreeMaker _treeMaker
The Advanced tree maker
-
-
Constructor Detail
-
CriterionTreeSearchComponent
public CriterionTreeSearchComponent()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
priority
public int priority()
Description copied from interface:SearchComponent
Get the priority of the component. The lowest one will be executed first, and so on.- Specified by:
priority
in interfaceSearchComponent
- Returns:
- the priority of the component
-
supports
public boolean supports(SearchComponentArguments args)
Description copied from interface:SearchComponent
Returnstrue
if the component must beexecuted
.- Specified by:
supports
in interfaceSearchComponent
- Parameters:
args
- the arguments- Returns:
true
if the component must beexecuted
.
-
execute
public void execute(SearchComponentArguments args) throws Exception
Description copied from interface:SearchComponent
Executes the component.- Specified by:
execute
in interfaceSearchComponent
- Parameters:
args
- the arguments- Throws:
Exception
- if an exception occurs. Other search components will be attempted to be executed
-
_contextualParameters
private Map<String,Object> _contextualParameters(Site currentSite)
-
checkValidInputs
protected void checkValidInputs(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria) throws InvalidUserInputException
Checks the user inputs are valid- Parameters:
criterionTree
- The criterion tree of the service instanceuserCriteria
- The user input criteria- Throws:
InvalidUserInputException
- if at least one user input is invalid
-
checkValidInputValues
protected void checkValidInputValues(Object userCriterionValues, String criterionId, FOSearchCriterionMode mode, Optional<EnumeratedValues.RestrictedValues> optionalRestrictedValues, Validator validator) throws InvalidUserInputException
Checks the user inputs for one criterion (can be multiple) are valid- Parameters:
userCriterionValues
- The multiple user values (then it is a List) or the single user valuecriterionId
- The criterion idmode
- The criterion modeoptionalRestrictedValues
- TheEnumeratedValues.RestrictedValues
if mode isFOSearchCriterionMode.RESTRICTED_USER_INPUT
validator
- The criterion validator- Throws:
InvalidUserInputException
- if at least one user input is invalid
-
checkValidInputSingleValue
protected void checkValidInputSingleValue(Object userCriterionSingleValue, String criterionId, FOSearchCriterionMode mode, Optional<EnumeratedValues.RestrictedValues> optionalRestrictedValues, Validator validator) throws InvalidUserInputException
Checks a single value of one user input for one criterion is valid- Parameters:
userCriterionSingleValue
- The single user valuecriterionId
- The criterion idmode
- The criterion modeoptionalRestrictedValues
- TheEnumeratedValues.RestrictedValues
if mode isFOSearchCriterionMode.RESTRICTED_USER_INPUT
validator
- The criterion validator- Throws:
InvalidUserInputException
- if the user input is invalid
-
_logTree
private void _logTree(org.slf4j.Logger logger, AbstractTreeNode<FOSearchCriterion> tree, Map<String,Object> userCriteria)
-
buildQuery
protected Query buildQuery(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
Builds the query of the criterion tree- Parameters:
criterionTree
- The criterion tree of the service instanceuserCriteria
- The user input criteriareturnables
- The returnables of the service instancesearchables
- The searchables of the service instanceadditionalParameters
- The values of additional parameters of the service instancecurrentLang
- The current langcontextualParameters
- the search contextual parameters.- Returns:
- The query of the criterion tree
-
singleCriterionToQuery
protected Query singleCriterionToQuery(FOSearchCriterion searchCriterion, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
Builds the query of the single criterion- Parameters:
searchCriterion
- The criterionuserCriteria
- The user input criteriareturnables
- The returnables of the service instancesearchables
- The searchables of the service instanceadditionalParameters
- The values of additional parameters of the service instancecurrentLang
- The current langcontextualParameters
- the search contextual parameters.- Returns:
- The query of the single criterion
-
_queryFromTransformedValAndRealOperator
private Query _queryFromTransformedValAndRealOperator(SearchCriterionDefinition criterionDefinition, Object transformedVal, Query.Operator realOperator, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Map<String,Object> contextualParameters)
-
-