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
FieldsModifier and TypeFieldDescriptionprotected AdvancedQueryBuilderThe advanced query builderprotected TreeMakerThe Advanced tree makerprotected ContentTypeExtensionPointThe content type extension point.protected LanguagesManagerThe languages managerstatic final StringThe query default language.static final StringKey of flag present in contextual parameters to indicate the current search is multilingualstatic final StringThe component role.static final StringPrefix for id of metadata search criteriastatic final StringPrefix for id of system property search criteriastatic final StringKey of flag present in contextual parameters to indicate the provided value was already escaped -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchUIModel model, String searchMode, boolean createContentTypeQuery, Map<String, Object> values, Map<String, Object> contextualParameters) Build theQueryobject.createContentTypeOrMixinQuery(Set<String> modelContentTypes, Object cTypeOrMixinParam, boolean criterionIsMultiple) Create a content type or mixin query.protected QuerycreateContentTypeOrMixinQuery(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type or mixin query.protected QuerycreateContentTypeQuery(Set<String> modelContentTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a content type query.protected QuerycreateMixinTypeQuery(Set<String> mixinTypes, Map<String, Object> values, Map<String, SearchCriterion> criteria, String searchMode) Create a mixin type query.protected QuerygetAdvancedCriteriaQuery(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 StringGet the default language for searchvoidservice(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:
servicein interfaceServiceable- Throws:
ServiceException
-
build
public Query build(SearchUIModel model, String searchMode, boolean createContentTypeQuery, Map<String, Object> values, Map<String, Object> contextualParameters) Build theQueryobject.- 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
Queryobject 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-trueif 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.
-