public class QueryBuilder extends AbstractLogEnabled implements Component, Serviceable
Query object from a user search.| Modifier and Type | Class and Description | 
|---|---|
private static class  | 
QueryBuilder.ValuedSearchCriterion  | 
| Modifier and Type | Field and Description | 
|---|---|
protected AdvancedQueryBuilder | 
_advancedQueryBuilder
The advanced query builder 
 | 
protected TreeMaker | 
_advancedTreeMaker
The Advanced tree maker 
 | 
protected ContentTypeExtensionPoint | 
_cTypeEP
The content type extension point. 
 | 
protected LanguagesManager | 
_languagesManager
The languages manager 
 | 
static String | 
DEFAULT_LANGUAGE
The query default language. 
 | 
static String | 
MULTILINGUAL_SEARCH
Key of flag present in contextual parameters to indicate the current search is multilingual 
 | 
static String | 
ROLE
The component role. 
 | 
static String | 
SEARCH_CRITERIA_METADATA_PREFIX
Prefix for id of metadata search criteria 
 | 
static String | 
SEARCH_CRITERIA_SYSTEM_PREFIX
Prefix for id of system property search criteria 
 | 
static String | 
VALUE_IS_ESCAPED
Key of flag present in contextual parameters to indicate the provided value was already escaped 
 | 
| Constructor and Description | 
|---|
QueryBuilder()  | 
| Modifier and Type | Method and Description | 
|---|---|
private boolean | 
_containsAny(Set<String> cTypes,
            String[] supertypeIds)  | 
private Query | 
_contentTypeQueryOrMixinQuery(Collection<String> contentTypes)  | 
private AbstractTreeNode<QueryBuilder.ValuedSearchCriterion> | 
_createTreeNode(Map<String,SearchCriterion> criteria,
               Map<String,Object> values)  | 
private String | 
_findSystemCriterionId(String systemPropertyId,
                      Map<String,SearchCriterion> criteria)  | 
private Object | 
_getAndRemoveValueForSytemCriterion(String systemCriterionId,
                                   Map<String,Object> values,
                                   String searchMode)  | 
private Set<String> | 
_getOnlySuperTypes(Set<String> cTypes)  | 
private boolean | 
_isFlatAndExpression(String rootType,
                    Map<String,Object> values)  | 
private boolean | 
_isMultilingualSearch(Query cTypeQuery)  | 
Query | 
build(SearchUIModel model,
     String searchMode,
     boolean createContentTypeQuery,
     Map<String,Object> values,
     Map<String,Object> contextualParameters)
Build the  
Query object. | 
protected Query | 
createContentTypeOrMixinQuery(Set<String> modelContentTypes,
                             Map<String,Object> values,
                             Map<String,SearchCriterion> criteria,
                             String searchMode)
Create a content type or mixin query. 
 | 
Query | 
createContentTypeOrMixinQuery(Set<String> modelContentTypes,
                             Object cTypeOrMixinParam,
                             boolean criterionIsMultiple)
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 | 
createContentTypeQuery(Set<String> modelContentTypes,
                      Map<String,Object> values,
                      Map<String,SearchCriterion> criteria,
                      String searchMode,
                      boolean exclude)
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. 
 | 
String | 
getCriteriaLanguage(Map<String,SearchUICriterion> criteria,
                   String searchMode,
                   Map<String,Object> values,
                   Map<String,Object> contextualParameters)
Get the language. 
 | 
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. 
 | 
protected String | 
getDefaultLanguage()
Get the default language for search 
 | 
void | 
service(ServiceManager serviceManager)  | 
enableLogging, getLogger, setupLogger, setupLogger, setupLoggerpublic static final String SEARCH_CRITERIA_METADATA_PREFIX
public static final String SEARCH_CRITERIA_SYSTEM_PREFIX
public static final String MULTILINGUAL_SEARCH
public static final String VALUE_IS_ESCAPED
public static final String DEFAULT_LANGUAGE
protected ContentTypeExtensionPoint _cTypeEP
protected LanguagesManager _languagesManager
protected TreeMaker _advancedTreeMaker
protected AdvancedQueryBuilder _advancedQueryBuilder
public QueryBuilder()
public void service(ServiceManager serviceManager) throws ServiceException
service in interface ServiceableServiceExceptionpublic Query build(SearchUIModel model, String searchMode, boolean createContentTypeQuery, Map<String,Object> values, Map<String,Object> contextualParameters)
Query object.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.Query object representing the search.private boolean _isMultilingualSearch(Query cTypeQuery)
private Set<String> _getOnlySuperTypes(Set<String> cTypes)
private boolean _containsAny(Set<String> cTypes, String[] supertypeIds)
public String getCriteriaLanguage(Map<String,SearchUICriterion> criteria, String searchMode, Map<String,Object> values, Map<String,Object> contextualParameters)
criteria - the list of search criteriasearchMode - The search mode (advanced or simple)values - The user values.contextualParameters - The search contextual parameters.protected String getDefaultLanguage()
protected Query createContentTypeQuery(Set<String> modelContentTypes, Map<String,Object> values, Map<String,SearchCriterion> criteria, String searchMode)
modelContentTypes - the content types to search on.values - the user search values.criteria - the list of search criteriasearchMode - The search mode (advanced or simple)Query.protected Query createContentTypeQuery(Set<String> modelContentTypes, Map<String,Object> values, Map<String,SearchCriterion> criteria, String searchMode, boolean exclude)
modelContentTypes - the content types to search on.values - the user search values.criteria - the list of search criteriasearchMode - The search mode (advanced or simple)exclude - true to create a negative query ("all but the given content types"), false to create a standard "include" query.Query.protected Query createMixinTypeQuery(Set<String> mixinTypes, Map<String,Object> values, Map<String,SearchCriterion> criteria, String searchMode)
mixinTypes - the mixin types to search on.values - the user search values.criteria - the list of search criteriasearchMode - The search mode (advanced or simple)Query.protected Query createContentTypeOrMixinQuery(Set<String> modelContentTypes, Map<String,Object> values, Map<String,SearchCriterion> criteria, String searchMode)
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)Query.public Query createContentTypeOrMixinQuery(Set<String> modelContentTypes, Object cTypeOrMixinParam, boolean criterionIsMultiple)
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 criterionQuery.private Query _contentTypeQueryOrMixinQuery(Collection<String> contentTypes)
private Object _getAndRemoveValueForSytemCriterion(String systemCriterionId, Map<String,Object> values, String searchMode)
private String _findSystemCriterionId(String systemPropertyId, Map<String,SearchCriterion> criteria)
private boolean _isFlatAndExpression(String rootType, Map<String,Object> values)
protected List<Query> getCriteriaQueries(Map<String,SearchUICriterion> criteria, Map<String,Object> values, String language, Map<String,Object> contextualParameters)
criteria - the list of search criteriavalues - The submitted valueslanguage - The query language.contextualParameters - The contextual parametersQuery.protected Query getAdvancedCriteriaQuery(Map<String,SearchCriterion> criteria, Map<String,Object> values, String language, Map<String,Object> contextualParameters)
criteria - the list of search criteriavalues - The submitted valueslanguage - The query language.contextualParameters - The contextual parametersQuery.private AbstractTreeNode<QueryBuilder.ValuedSearchCriterion> _createTreeNode(Map<String,SearchCriterion> criteria, Map<String,Object> values)