Class SearchComponentHelper

java.lang.Object
org.ametys.web.frontoffice.search.requesttime.impl.SearchComponentHelper
All Implemented Interfaces:
Component, Serviceable

public class SearchComponentHelper extends Object implements Serviceable, Component
A helper for all search component
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • getCriterionTreeQuery

      public Query getCriterionTreeQuery(SearchComponentArguments args, boolean checkValidInputs, boolean logTree) throws org.ametys.web.frontoffice.search.requesttime.impl.InvalidUserInputException
      Get the criterion tree query from arguments
      Parameters:
      args - the search arguments
      checkValidInputs - true if inputs needs to be checked
      logTree - true if the criterion tree need to be logged
      Returns:
      the criterion tree query
      Throws:
      org.ametys.web.frontoffice.search.requesttime.impl.InvalidUserInputException - if an invalid user input occurred
    • checkValidInputs

      protected Map<String,Object> checkValidInputs(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria, boolean isFromUserPref, Logger logger) throws org.ametys.web.frontoffice.search.requesttime.impl.InvalidUserInputException
      Checks the user inputs are valid.
      Parameters:
      criterionTree - The criterion tree of the service instance
      userCriteria - The user input criteria
      isFromUserPref - true if the criteria are from user pref. Then return only the valid input, otherwise throw an exception
      logger - The logger
      Returns:
      the filtered user criteria
      Throws:
      org.ametys.web.frontoffice.search.requesttime.impl.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, boolean isMandatory) throws org.ametys.web.frontoffice.search.requesttime.impl.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 value
      criterionId - The criterion id
      mode - The criterion mode
      optionalRestrictedValues - The EnumeratedValues.RestrictedValues if mode is FOSearchCriterionMode.RESTRICTED_USER_INPUT
      validator - The criterion validator
      isMandatory - true if the criterion is linked to a mandatory data
      Throws:
      org.ametys.web.frontoffice.search.requesttime.impl.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, boolean isMandatory) throws org.ametys.web.frontoffice.search.requesttime.impl.InvalidUserInputException
      Checks a single value of one user input for one criterion is valid
      Parameters:
      userCriterionSingleValue - The single user value
      criterionId - The criterion id
      mode - The criterion mode
      optionalRestrictedValues - The EnumeratedValues.RestrictedValues if mode is FOSearchCriterionMode.RESTRICTED_USER_INPUT
      validator - The criterion validator
      isMandatory - true if the criterion is linked to a mandatory data
      Throws:
      org.ametys.web.frontoffice.search.requesttime.impl.InvalidUserInputException - if the user input is invalid
    • buildQuery

      public Query buildQuery(AbstractTreeNode<FOSearchCriterion> criterionTree, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Predicate<FOSearchCriterion> filterCriterionPredicate, Map<String,Object> contextualParameters)
      Builds the query of the criterion tree
      Parameters:
      criterionTree - The criterion tree of the service instance
      userCriteria - The user input criteria
      returnables - The returnables of the service instance
      searchables - The searchables of the service instance
      additionalParameters - The values of additional parameters of the service instance
      currentLang - The current lang
      filterCriterionPredicate - A function to filter criterion. Can be null for TruePredicate
      contextualParameters - the search contextual parameters.
      Returns:
      The query of the criterion tree
    • singleCriterionToQuery

      public Query singleCriterionToQuery(FOSearchCriterion searchCriterion, Map<String,Object> userCriteria, Collection<Returnable> returnables, Collection<Searchable> searchables, AdditionalParameterValueMap additionalParameters, String currentLang, Predicate<FOSearchCriterion> filterCriterionPredicate, Map<String,Object> contextualParameters)
      Builds the query of the single criterion
      Parameters:
      searchCriterion - The criterion
      userCriteria - The user input criteria
      returnables - The returnables of the service instance
      searchables - The searchables of the service instance
      additionalParameters - The values of additional parameters of the service instance
      currentLang - The current lang
      filterCriterionPredicate - A function to filter criterion
      contextualParameters - the search contextual parameters.
      Returns:
      The query of the single criterion
    • getFilterQuery

      Get the filter query from arguments
      Parameters:
      args - the search arguments
      Returns:
      the filter query
    • _createContextQueriesWrapper

      protected ContextQueriesWrapper _createContextQueriesWrapper(SearchContext searchContext, Site currentSite, Page currentPage, String currentLang)
      Creates a ContextQueriesWrapper given one SearchContext and the current site, page and lang.
      Parameters:
      searchContext - The search context
      currentSite - The current site
      currentPage - The current page
      currentLang - The current lang
      Returns:
      The created wrapper of queries of a SearchContext