Interface IQueryHelper
public interface IQueryHelper
A helper class for query manipulation. Helps in composing queries in
a correct way.
Note: This class also serves as an 'entry point' to track all usages of such logic, so that the object model for queries can be introduced later. Therefore it is strongly recommended to use this helper for query manipulation.
- Author:
- POLARION SOFTWARE
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Nonempty query matching all objects.static final String
Deprecated.The 2010 Live Documents are deprecated.static final String
Virtual index field for SQL queries.static final String
Search field that contains ids of all object fields that have non-empty value.static final String
Deprecated.The 2010 Live Documents are deprecated.static final String
Deprecated.The 2010 Live Documents are deprecated.static final String
Deprecated.UseHAS_VALUE
. -
Method Summary
Modifier and TypeMethodDescriptionComposes the given queries using AND.escapeQueryForSQL
(String query) Escapes characters in Lucene query so that it can be used in an SQL query as argument of the LUCENE_QUERY function.escapeQueryPart
(String part) Escapes special characters in query part.expandKeywords
(String query) Expands keywords in simple query using asterisks.fieldQuery
(String field, String term) Creates a field query for the specified term that will be enclosed in double quotes and contained special characters will be escaped.formatDate
(Date date) Convert date to string used in queries from...toformatDateOnly
(Date date) Convert date to string used in queries from...tofromToDateOnlyQuery
(Date from, Date to) Compose [from TO to] query fragments using the DATE_NO_TIME_FORMAT format.negateQuery
(String query) Adds NOT to the whole queryComposes the given queries using OR.
-
Field Details
-
FIELD_SQL
Virtual index field for SQL queries. Works only for work items and baseline collections and its parameter must be enclosed in "()" parentheses, e.g. "SQL:(SELECT * FROM WORKITEM WHERE C_TYPE='issue')"- Since:
- 3.8.2
- See Also:
-
HAS_VALUE
Search field that contains ids of all object fields that have non-empty value.- Since:
- 3.7.1
- See Also:
-
UNASSIGNED_VALUE
Deprecated.UseHAS_VALUE
.Constant (######NULL) used for unassigned value queries.- See Also:
-
FIELD_IS_LOCAL
Deprecated.The 2010 Live Documents are deprecated.Search field, which can be used to include or eliminate objects with local id (the ones coming from live-documents) from the query results.By default (if not mentioned), the objects with local id are NOT included in the result.
- See Also:
-
IS_LOCAL_TRUE
Deprecated.The 2010 Live Documents are deprecated.FIELD_IS_LOCAL
value for objects with local id.- See Also:
-
IS_LOCAL_FALSE
Deprecated.The 2010 Live Documents are deprecated.FIELD_IS_LOCAL
value for objects with global id.- See Also:
-
ALL_QUERY
Nonempty query matching all objects. Used when one needs to start query withNOT
condition.- Since:
- 3.1.2
- See Also:
-
-
Method Details
-
andQuery
Composes the given queries using AND. If one of the queries is empty ornull
, the other query is returned. If both queries are empty ornull
, empty string is returned.- Parameters:
firstQuery
-secondQuery
-- Returns:
- new query
-
orQuery
Composes the given queries using OR. If one of the queries is empty ornull
, the other query is returned. If both queries are empty ornull
, empty string is returned.- Parameters:
firstQuery
-secondQuery
-- Returns:
- new query
-
escapeQueryPart
Escapes special characters in query part. See http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters- Parameters:
part
-- Returns:
- the escaped query
-
escapeQueryForSQL
Escapes characters in Lucene query so that it can be used in an SQL query as argument of the LUCENE_QUERY function.- Since:
- 3.9.2
-
fieldQuery
Creates a field query for the specified term that will be enclosed in double quotes and contained special characters will be escaped. If field isnull
, the field part will be omitted, so the query will target the default field.- Parameters:
field
-term
-- Returns:
- the field query
- Since:
- 3.3.1
-
formatDateOnly
Convert date to string used in queries from...to- Parameters:
date
- cannot benull
- Returns:
- the formated Date, only the part indicating time is ignored
-
formatDate
Convert date to string used in queries from...to- Parameters:
date
- cannot benull
- Returns:
- the formated date
-
fromToDateOnlyQuery
Compose [from TO to] query fragments using the DATE_NO_TIME_FORMAT format.- Parameters:
from
- can benull
ifto
is notnull
to
- can benull
iffrom
is notnull
- Returns:
- the query
-
expandKeywords
Expands keywords in simple query using asterisks.- Parameters:
query
-- Returns:
- query with expanded keywords
- Since:
- 3.5.2
-
negateQuery
Adds NOT to the whole query- Returns:
- the given query with a leading NOT and brackets (e.g. negateQuery(a or b) => NOT (a or b)). Will return empty String if given query is empty
- Since:
- 3.10.1
-