Package org.ametys.cms.search
Class QueryBuilder
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.ametys.cms.search.QueryBuilder
- All Implemented Interfaces:
Component
,LogEnabled
,Serviceable
Builds a
Query
object from a user search.-
Field Summary
Modifier and TypeFieldDescriptionprotected AdvancedQueryBuilder
The advanced query builderprotected TreeMaker
The Advanced tree makerprotected ContentTypeExtensionPoint
The content type extension point.protected LanguagesManager
The languages managerstatic final String
The query default language.static final String
Key of flag present in contextual parameters to indicate the current search is multilingualstatic final String
The component role.static final String
Prefix for id of metadata search criteriastatic final String
Prefix for id of system property search criteriastatic final String
Key of flag present in contextual parameters to indicate the provided value was already escaped -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild
(SearchUIModel model, String searchMode, boolean createContentTypeQuery, Map<String, Object> values, Map<String, Object> contextualParameters) Build theQuery
object.createContentTypeOrMixinQuery
(Set<String> modelContentTypes, Object cTypeOrMixinParam, boolean criterionIsMultiple) Create a content type or mixin query.protected Query
createContentTypeOrMixinQuery
(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type or mixin query.protected Query
createContentTypeQuery
(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type query.protected Query
createMixinTypeQuery
(Set<String> mixinTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a mixin type query.protected Query
getAdvancedCriteriaQuery
(Map<String, SearchCriterion> criteria, Map<String, Object> values, String language, Map<String, Object> contextualParameters) Get a complex Query from the advanced search values.getCriteriaLanguage
(Map<String, SearchUICriterion> criteria, String searchMode, Map<String, Object> values, Map<String, Object> contextualParameters) Get the language.getCriteriaQueries
(Map<String, SearchUICriterion> criteria, Map<String, Object> values, String language, Map<String, Object> contextualParameters) Get the list of query on criteria.protected String
Get the default language for searchvoid
service
(ServiceManager serviceManager) Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Field Details
-
ROLE
The component role. -
SEARCH_CRITERIA_METADATA_PREFIX
Prefix for id of metadata search criteria- See Also:
-
SEARCH_CRITERIA_SYSTEM_PREFIX
Prefix for id of system property search criteria- See Also:
-
MULTILINGUAL_SEARCH
Key of flag present in contextual parameters to indicate the current search is multilingual- See Also:
-
VALUE_IS_ESCAPED
Key of flag present in contextual parameters to indicate the provided value was already escaped- See Also:
-
DEFAULT_LANGUAGE
The query default language.- See Also:
-
_cTypeEP
The content type extension point. -
_languagesManager
The languages manager -
_advancedTreeMaker
The Advanced tree maker -
_advancedQueryBuilder
The advanced query builder
-
-
Constructor Details
-
QueryBuilder
public QueryBuilder()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
build
public Query build(SearchUIModel model, String searchMode, boolean createContentTypeQuery, Map<String, Object> values, Map<String, Object> contextualParameters) Build theQuery
object.- Parameters:
model
- the search model.searchMode
- the search mode.createContentTypeQuery
- True to generate a query based on the content types of the model, and the 'property-contentTypes-eq' if present in valuesvalues
- the user search values.contextualParameters
- the search contextual parameters.- Returns:
- a
Query
object representing the search.
-
getCriteriaLanguage
public String getCriteriaLanguage(Map<String, SearchUICriterion> criteria, String searchMode, Map<String, Object> values, Map<String, Object> contextualParameters) Get the language.- Parameters:
criteria
- the list of search criteriasearchMode
- The search mode (advanced or simple)values
- The user values.contextualParameters
- The search contextual parameters.- Returns:
- the query language.
-
getDefaultLanguage
Get the default language for search- Returns:
- The default language
-
createContentTypeQuery
protected Query createContentTypeQuery(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type query.- Parameters:
modelContentTypes
- the content types to search on.values
- the user search values.criteria
- the list of search criteriasearchMode
- The search mode (advanced or simple)- Returns:
- the content type
Query
.
-
createMixinTypeQuery
protected Query createMixinTypeQuery(Set<String> mixinTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a mixin type query.- Parameters:
mixinTypes
- the mixin types to search on.values
- the user search values.criteria
- the list of search criteriasearchMode
- The search mode (advanced or simple)- Returns:
- the mixin type
Query
.
-
createContentTypeOrMixinQuery
protected Query createContentTypeOrMixinQuery(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type or mixin query.- Parameters:
modelContentTypes
- the content types or mixins to search on.values
- the user search values.criteria
- the list of search criteriasearchMode
- The search mode (advanced or simple)- Returns:
- the content type
Query
.
-
createContentTypeOrMixinQuery
public Query createContentTypeOrMixinQuery(Set<String> modelContentTypes, Object cTypeOrMixinParam, boolean criterionIsMultiple) Create a content type or mixin query.- Parameters:
modelContentTypes
- the content types or mixins to search on.cTypeOrMixinParam
- The contentTypes or mixin parameter on which you want to build the QuerycriterionIsMultiple
-true
if the given parameter is a value for a multiple criterion- Returns:
- the content type
Query
.
-
getCriteriaQueries
protected List<Query> getCriteriaQueries(Map<String, SearchUICriterion> criteria, Map<String, Object> values, String language, Map<String, Object> contextualParameters) Get the list of query on criteria.- Parameters:
criteria
- the list of search criteriavalues
- The submitted valueslanguage
- The query language.contextualParameters
- The contextual parameters- Returns:
- The criteria
Query
.
-
getAdvancedCriteriaQuery
protected Query getAdvancedCriteriaQuery(Map<String, SearchCriterion> criteria, Map<String, Object> values, String language, Map<String, Object> contextualParameters) Get a complex Query from the advanced search values.- Parameters:
criteria
- the list of search criteriavalues
- The submitted valueslanguage
- The query language.contextualParameters
- The contextual parameters- Returns:
- The criteria
Query
.
-