public class QueryBuilder extends AbstractLogEnabled implements Component, Serviceable
Query
object from a user search.Modifier and Type | Field and Description |
---|---|
protected ContentTypeExtensionPoint |
_cTypeEP
The content type extension point.
|
protected LanguagesManager |
_languagesManager
The languages manager
|
static String |
DEFAULT_LANGUAGE
The query default language.
|
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
|
Constructor and Description |
---|
QueryBuilder() |
Modifier and Type | Method and Description |
---|---|
Query |
build(SearchUIModel model,
String searchMode,
Map<String,Object> values,
Map<String,Object> contextualParameters)
Build the
Query object. |
protected Query |
createContentTypeOrMixinQuery(Set<String> contentTypes,
Map<String,Object> values,
Map<String,Object> contextualParameters)
Create a content type or mixin query.
|
protected Query |
createContentTypeQuery(Set<String> contentTypes,
Map<String,Object> values,
Map<String,Object> contextualParameters)
Create a content type query.
|
protected Query |
createContentTypeQuery(Set<String> contentTypes,
Map<String,Object> values,
Map<String,Object> contextualParameters,
boolean exclude)
Create a content type query.
|
protected Query |
createMixinTypeQuery(Set<String> mixinTypes,
Map<String,Object> values,
Map<String,Object> contextualParameters)
Create a mixin type query.
|
protected String |
filterWildcardChars(String string)
Filter wildcard characters '*' and '?' from the input string by replacing them with a space.
|
protected Query |
getAdvancedCriteriaQuery(SearchUIModel model,
Map<String,Object> values,
String language,
Map<String,Object> contextualParameters)
Get a complex Query from the advanced search values.
|
protected Query |
getAdvancedCriterionQuery(SearchUICriterion criterion,
String op,
Object value,
String language,
Map<String,Object> contextualParameters)
Build the
Query object corresponding to an advanced criterion value. |
protected String |
getCriteriaLanguage(SearchUIModel model,
String searchMode,
Map<String,Object> values,
Map<String,Object> contextualParameters)
Get the language.
|
protected List<Query> |
getCriteriaQueries(SearchUIModel model,
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, setupLogger
public static final String SEARCH_CRITERIA_METADATA_PREFIX
public static final String SEARCH_CRITERIA_SYSTEM_PREFIX
public static final String DEFAULT_LANGUAGE
protected ContentTypeExtensionPoint _cTypeEP
protected LanguagesManager _languagesManager
public QueryBuilder()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public Query build(SearchUIModel model, String searchMode, Map<String,Object> values, Map<String,Object> contextualParameters)
Query
object.model
- the search model.searchMode
- the search mode.values
- the user search values.contextualParameters
- the search contextual parameters.Query
object representing the search.protected String getCriteriaLanguage(SearchUIModel model, String searchMode, Map<String,Object> values, Map<String,Object> contextualParameters)
model
- The search model.searchMode
- The search mode (advanced or simple)values
- The user values.contextualParameters
- The search contextual parameters.protected String getDefaultLanguage()
protected Query createContentTypeQuery(Set<String> contentTypes, Map<String,Object> values, Map<String,Object> contextualParameters)
contentTypes
- the content types to search on.values
- the user search values.contextualParameters
- the search contextual parameters.Query
.protected Query createContentTypeQuery(Set<String> contentTypes, Map<String,Object> values, Map<String,Object> contextualParameters, boolean exclude)
contentTypes
- the content types to search on.values
- the user search values.contextualParameters
- the search contextual parameters.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,Object> contextualParameters)
mixinTypes
- the mixin types to search on.values
- the user search values.contextualParameters
- the search contextual parameters.Query
.protected Query createContentTypeOrMixinQuery(Set<String> contentTypes, Map<String,Object> values, Map<String,Object> contextualParameters)
contentTypes
- the content types or mixins to search on.values
- the user search values.contextualParameters
- the search contextual parameters.Query
.protected List<Query> getCriteriaQueries(SearchUIModel model, Map<String,Object> values, String language, Map<String,Object> contextualParameters)
model
- the search model.values
- The submitted valueslanguage
- The query language.contextualParameters
- The contextual parametersQuery
.protected Query getAdvancedCriteriaQuery(SearchUIModel model, Map<String,Object> values, String language, Map<String,Object> contextualParameters)
model
- the search model.values
- The submitted valueslanguage
- The query language.contextualParameters
- The contextual parametersQuery
.protected Query getAdvancedCriterionQuery(SearchUICriterion criterion, String op, Object value, String language, Map<String,Object> contextualParameters)
Query
object corresponding to an advanced criterion value.criterion
- The search criterion.op
- The advanced operator (can be a custom one, such as "contain").value
- The user value.language
- The query language.contextualParameters
- the search contextual parameters.Query
.protected String filterWildcardChars(String string)
string
- The string to filter.