public abstract class QueryParameters extends Object
Abstract implementation for query parameters. Can be used to configure Communote queries.
Note: QueryParameters should not be reused for multiple queries, as they can create query parameters on the fly. This could result in wrong queries.Modifier and Type | Class and Description |
---|---|
static class |
QueryParameters.OrderDirection
Enum for possible orderings in "ORDER BY" clauses.
|
Modifier and Type | Field and Description |
---|---|
static String |
SORT_ASCENDING
sort constant for ascending
|
static String |
SORT_DESCENDING
sort constant for descending
|
Constructor and Description |
---|
QueryParameters() |
Modifier and Type | Method and Description |
---|---|
String |
addParameter(String value)
Adds a named query parameter that can be referenced when rendering the query.
|
void |
addParameter(String name,
Object value)
Adds a named query parameter that can be referenced when rendering the query.
|
protected void |
addSortField(String resultObjectPrefix,
String fieldName,
String sortDirection)
Deprecated.
Use a sort field in the parameters and do the rendering of the sortfield in the
associated query
|
protected void |
addSortField(String resultObjectPrefix,
String fieldName,
String sortDirection,
String aggregateFunction)
Deprecated.
Use a sort field in the parameters and do the rendering of the sortfield in the
associated query
|
protected String[] |
createParameterNamesForSearch(String paramPrefix,
String[] searchValues)
Creates an array of parameter names to be used in a query that searches for the provided
searchValues.
|
DatabaseConfiguration |
getDatabaseConfiguration() |
String |
getLanguageCode() |
PageInformation |
getPageInformation(PageableList<?> resultList,
int pagingInterval)
Get the page information about the current page in relation to the overall count
|
static PageInformation |
getPageInformation(PageableList<?> resultList,
ResultSpecification resultSpecification,
int pagingInterval)
Get the page information about the current page in relation to the overall count
|
Map<String,Object> |
getParameters()
Get the parameters of this instances, the names are the keys
|
ResultSpecification |
getResultSpecification()
Get the result specification to be used
|
String |
getSortString()
get the sort string for the order by clause
|
boolean |
isLimitResultSet() |
boolean |
isLimitResultSetAvodingDuplicates() |
boolean |
needTransformListItem()
Deprecated.
Use
Converter instead. |
protected void |
putParameter(Map<String,Object> params,
String paramName,
Object paramValue)
Put a parameter, if set, in the map
|
protected void |
putParametersForSearch(Map<String,Object> paramMap,
String[] paramNames,
String[] searchValues,
org.hibernate.criterion.MatchMode matchMode)
Put the parameter names and values for a search into the parameter map.
|
protected void |
putParametersForSearch(Map<String,Object> paramMap,
String[] paramNames,
String[] searchValues,
org.hibernate.criterion.MatchMode matchMode,
boolean doNotUseFulltext)
Put the parameter names and values for a search into the parameter map.
|
void |
setLanguageCode(String languageCode) |
void |
setLimitResultSet(boolean limitResultSet) |
void |
setLimitResultSetAvodingDuplicates(boolean limitResultSetAvodingDuplicates) |
void |
setResultSpecification(ResultSpecification resultSpecification)
Set the result specification
|
IdentifiableEntityData |
transformResultItem(Object resultItem)
Deprecated.
Use
Converter instead. |
boolean |
validateLong(String value)
Validates the given String, if this is not null or 0.
|
public static final String SORT_DESCENDING
public static final String SORT_ASCENDING
public static PageInformation getPageInformation(PageableList<?> resultList, ResultSpecification resultSpecification, int pagingInterval)
resultList
- the result list with the countsresultSpecification
- the result specificationpagingInterval
- the interval of how many pages to show at one timepublic String addParameter(String value)
value
- The value of the parameter.public void addParameter(String name, Object value)
name
- The name of the parameter.value
- The value of the parameter.@Deprecated protected void addSortField(String resultObjectPrefix, String fieldName, String sortDirection)
resultObjectPrefix
- the result prefixfieldName
- the name of the field to sortsortDirection
- the sort direction@Deprecated protected void addSortField(String resultObjectPrefix, String fieldName, String sortDirection, String aggregateFunction)
resultObjectPrefix
- the result prefixfieldName
- the name of the field to sortsortDirection
- the sort directionaggregateFunction
- the aggregate function to be performed on the sort fieldprotected String[] createParameterNamesForSearch(String paramPrefix, String[] searchValues)
paramPrefix
- a prefix to be used for building the parameter names. Callers should assure that
the prefix is unique within the query.searchValues
- the search values for which the parameter names should be created. Blank values
will result in adding null to the parameter names at the index position of that
search valuepublic DatabaseConfiguration getDatabaseConfiguration()
public String getLanguageCode()
public PageInformation getPageInformation(PageableList<?> resultList, int pagingInterval)
resultList
- the result list with the countspagingInterval
- the interval of how many pages to show at one timepublic Map<String,Object> getParameters()
public ResultSpecification getResultSpecification()
ResultSpecification
public String getSortString()
public boolean isLimitResultSet()
public boolean isLimitResultSetAvodingDuplicates()
@Deprecated public boolean needTransformListItem()
Converter
instead.protected void putParameter(Map<String,Object> params, String paramName, Object paramValue)
params
- the map with the parametersparamName
- the parameter nameparamValue
- the parameter valueprotected void putParametersForSearch(Map<String,Object> paramMap, String[] paramNames, String[] searchValues, org.hibernate.criterion.MatchMode matchMode)
paramMap
- the parameter map to extendparamNames
- the names of the parameters to be added to the map. Blank names will be ignored.
It is expected that the names and the values array are consistent with respect to
size and blank values. So if for instance a value is blank the name at the same
array position must also be blank or null. To achieve this the
createParameterNamesForSearch(String, String[])
can be invoked on the
values array.searchValues
- an array of values to be passed the parameterized querymatchMode
- the mode for matching against the valuesprotected void putParametersForSearch(Map<String,Object> paramMap, String[] paramNames, String[] searchValues, org.hibernate.criterion.MatchMode matchMode, boolean doNotUseFulltext)
paramMap
- the parameter map to extendparamNames
- the names of the parameters to be added to the map. Blank names will be ignored.
It is expected that the names and the values array are consistent with respect to
size and blank values. So if for instance a value is blank the name at the same
array position must also be blank or null. To achieve this the
createParameterNamesForSearch(String, String[])
can be invoked on the
values array.searchValues
- an array of values to be passed the parameterized querymatchMode
- the mode for matching against the valuesdoNotUseFulltext
- true if like wildcard syntax should be used even if fulltext would be availablepublic void setLanguageCode(String languageCode)
languageCode
- the languageCode to setpublic void setLimitResultSet(boolean limitResultSet)
limitResultSet
- the limitResultSet to setpublic void setLimitResultSetAvodingDuplicates(boolean limitResultSetAvodingDuplicates)
limitResultSetAvodingDuplicates
- If true the computation of the limitation based on the note list will avoid
duplicates by using distinct. If false distinct will not be used, being somewhat
faster. Default is true.public void setResultSpecification(ResultSpecification resultSpecification)
resultSpecification
- the result specification@Deprecated public IdentifiableEntityData transformResultItem(Object resultItem)
Converter
instead.resultItem
- the item to transformpublic boolean validateLong(String value)
value
- Value to check.Copyright © 2019 Communote team. All rights reserved.