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 StringDEFAULT_SELECT_STATEMENTstatic StringDEFAULT_SPECIAL_CHARACTERS_REGEXPstatic StringIGNORED_CHARS_KEYstatic StringREGEXP_EXCLUDE_DOUBLE_QUOTEstatic StringREGEXP_EXCLUDE_QUOTEstatic StringREGEXP_NAMED_PARAMETERstatic StringSORTED_COLUMN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringappendClause(String query, String clause)static voidappendStringList(StringBuilder queryBuilder, List<?> listParam, boolean quoteParameters, boolean escape)protected static StringatomicQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)static StringbuildPattern(String string, String key, String replacement)static BooleangetBooleanValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)protected static DateFormatgetDateFormat()static StringgetFieldType(DocumentModel model, PredicateFieldDefinition fieldDescriptor)static IntegergetIntValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)static List<String>getListValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)protected static StringgetParameterWithHint(String operator, String parameter, String hint)static StringgetPlainStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)static StringgetQuery(String pattern, Object[] params, boolean quoteParameters, boolean escape, DocumentModel searchDocumentModel, SortInfo... sortInfos)static StringgetQuery(DocumentModel model, WhereClauseDefinition whereClause, Object[] params, SortInfo... sortInfos)static StringgetQuery(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params, SortInfo... sortInfos)static StringgetQueryElement(DocumentModel model, PredicateDefinition predicateDescriptor, Escaper escaper)static StringgetQueryElement(DocumentModel model, WhereClauseDefinition whereClause, Object[] params)static StringgetQueryElement(DocumentModel model, WhereClauseDefinition whereClause, String quickFiltersClause, Object[] params)static ObjectgetRawValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)static StringgetSortClause(SortInfo... sortInfos)static StringgetStringValue(DocumentModel model, PredicateFieldDefinition fieldDescriptor)static StringprepareStringLiteral(String s, boolean quoteParameter, boolean escape)Return the string literal in a form ready to embed in an NXQL statement.static StringreplaceStringList(String pattern, List<?> listParams, boolean quoteParameters, boolean escape, String key)static StringsanitizeFulltextInput(String value)Remove any special character that could be mis-interpreted as a low level full-text query operator.static StringserializeFullText(String value)protected static StringserializeUnary(String parameter, String operator, String rvalue)protected static StringsubClauseQueryElement(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)
-
-