Class NXQLQueryBuilder
- java.lang.Object
-
- org.nuxeo.ecm.platform.query.nxql.NXQLQueryBuilder
-
public class NXQLQueryBuilder extends Object
Helper to generate NXQL queries from XMap descriptors- Since:
- 5.4
- Author:
- Anahide Tchertchian
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_SELECT_STATEMENT
static String
DEFAULT_SPECIAL_CHARACTERS_REGEXP
static String
IGNORED_CHARS_KEY
static String
REGEXP_EXCLUDE_DOUBLE_QUOTE
static String
REGEXP_EXCLUDE_QUOTE
static String
REGEXP_NAMED_PARAMETER
static String
SORTED_COLUMN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
appendClause(String query, String clause)
static void
appendStringList(StringBuilder queryBuilder, List<?> listParam, boolean quoteParameters, boolean escape)
protected static String
atomicQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)
static String
buildPattern(String string, String key, String replacement)
static Boolean
getBooleanValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
protected static DateFormat
getDateFormat()
static String
getFieldType(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
static Integer
getIntValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
static List<String>
getListValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
protected static String
getParameterWithHint(String operator, String parameter, String hint)
static String
getPlainStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
static String
getQuery(String pattern, Object[] params, boolean quoteParameters, boolean escape, DocumentModel searchDocumentModel, SortInfo... sortInfos)
static String
getQuery(DocumentModel model, WhereClauseDefinition whereClause, Object[] params, SortInfo... sortInfos)
static String
getQuery(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params, SortInfo... sortInfos)
static String
getQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)
static String
getQueryElement(DocumentModel model, WhereClauseDefinition whereClause, Object[] params)
static String
getQueryElement(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params)
static Object
getRawValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
static String
getSortClause(SortInfo... sortInfos)
static String
getStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
static String
prepareStringLiteral(String s, boolean quoteParameter, boolean escape)
Return the string literal in a form ready to embed in an NXQL statement.static String
replaceStringList(String pattern, List<?> listParams, boolean quoteParameters, boolean escape, String key)
static String
sanitizeFulltextInput(String value)
Remove any special character that could be mis-interpreted as a low level full-text query operator.static String
serializeFullText(String value)
protected static String
serializeUnary(String parameter, String operator, String rvalue)
protected static String
subClauseQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor)
-
-
-
Field Detail
-
DEFAULT_SELECT_STATEMENT
public static final String DEFAULT_SELECT_STATEMENT
- See Also:
- Constant Field Values
-
SORTED_COLUMN
public static final String SORTED_COLUMN
- See Also:
- Constant Field Values
-
REGEXP_NAMED_PARAMETER
public static final String REGEXP_NAMED_PARAMETER
- See Also:
- Constant Field Values
-
REGEXP_EXCLUDE_QUOTE
public static final String REGEXP_EXCLUDE_QUOTE
- See Also:
- Constant Field Values
-
REGEXP_EXCLUDE_DOUBLE_QUOTE
public static final String REGEXP_EXCLUDE_DOUBLE_QUOTE
- See Also:
- Constant Field Values
-
DEFAULT_SPECIAL_CHARACTERS_REGEXP
public static final String DEFAULT_SPECIAL_CHARACTERS_REGEXP
- See Also:
- Constant Field Values
-
IGNORED_CHARS_KEY
public static final String IGNORED_CHARS_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSortClause
public static String getSortClause(SortInfo... sortInfos)
- Returns:
- the built sort clause from input parameters, always non null
-
getQuery
public static String getQuery(DocumentModel model, WhereClauseDefinition whereClause, Object[] params, SortInfo... sortInfos)
-
getQuery
public static String getQuery(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params, SortInfo... sortInfos)
- Since:
- 8.4
-
getQueryElement
public static String getQueryElement(DocumentModel model, WhereClauseDefinition whereClause, Object[] params)
-
getQueryElement
public static String getQueryElement(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params)
- Since:
- 8.4
-
getQuery
public static String getQuery(String pattern, Object[] params, boolean quoteParameters, boolean escape, DocumentModel searchDocumentModel, SortInfo... sortInfos)
-
appendStringList
public static void appendStringList(StringBuilder queryBuilder, List<?> listParam, boolean quoteParameters, boolean escape)
-
replaceStringList
public static String replaceStringList(String pattern, List<?> listParams, boolean quoteParameters, boolean escape, String key)
-
prepareStringLiteral
public static String prepareStringLiteral(String s, boolean quoteParameter, boolean escape)
Return the string literal in a form ready to embed in an NXQL statement.
-
getQueryElement
public static String getQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)
-
subClauseQueryElement
protected static String subClauseQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor)
-
atomicQueryElement
protected static String atomicQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)
-
getParameterWithHint
protected static String getParameterWithHint(String operator, String parameter, String hint)
-
sanitizeFulltextInput
public static String sanitizeFulltextInput(String value)
Remove any special character that could be mis-interpreted as a low level full-text query operator. This method should be used by user facing callers of CoreQuery*PageProviders that use a fixed part or a pattern query. Fields in where clause already dealt with.- Returns:
- sanitized text value
- Since:
- 5.6
-
serializeUnary
protected static String serializeUnary(String parameter, String operator, String rvalue)
-
getPlainStringValue
public static String getPlainStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getIntValue
public static Integer getIntValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getFieldType
public static String getFieldType(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getRawValue
public static Object getRawValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getStringValue
public static String getStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getDateFormat
protected static DateFormat getDateFormat()
-
getListValue
public static List<String> getListValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
getBooleanValue
public static Boolean getBooleanValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)
-
-