Class CMISQLQueryMaker
- java.lang.Object
-
- org.nuxeo.ecm.core.opencmis.impl.server.CMISQLQueryMaker
-
- All Implemented Interfaces:
QueryMaker
public class CMISQLQueryMaker extends Object implements QueryMaker
Transformer of CMISQL queries into real SQL queries for the actual database.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CMISQLQueryMaker.AnalyzingWalker
Walker of the WHERE clause to gather fulltext info.static class
CMISQLQueryMaker.ClauseType
static class
CMISQLQueryMaker.CMISQLMapMaker
Map maker that can deal with aliased column names and computed values.class
CMISQLQueryMaker.GeneratingWalker
Walker of the WHERE clause that generates final SQL.static class
CMISQLQueryMaker.SqlColumn
Column corresponding to a returned value computed from an actual SQL expression.-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.jdbc.QueryMaker
QueryMaker.Query, QueryMaker.QueryCannotMatchException
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<String>
allQualifiers
All qualifiers used (includes virtual columns)protected Map<String,Map<String,Table>>
allTables
Map of qualifier -> fragment -> tableprotected Map<String,String>
canonicalQualifier
Qualifier to canonical qualifier (correlation name).static String
CMIS_PREFIX
protected Database
database
static String
DC_CREATED_KEY
static String
DC_CREATOR_KEY
static String
DC_DESCRIPTION_KEY
static String
DC_FRAGMENT_NAME
static String
DC_LAST_CONTRIBUTOR_KEY
static String
DC_MODIFIED_KEY
static String
DC_TITLE_KEY
protected Dialect
dialect
protected Dialect.FulltextMatchInfo
fulltextMatchInfo
protected Table
hierTable
protected Set<String>
lifecycleWhereClauseQualifiers
protected static Set<String>
MIXINS_NOT_PER_INSTANCE
These mixins never match an instance mixin when used in a clause nuxeo:secondaryObjectTypeIds = 'foo'protected Set<String>
mixinTypeWhereClauseQualifiers
protected Model
model
static Set<String>
NULL_IS_FALSE_COLUMNS
static String
NX_PREFIX
protected Map<String,String>
qualifierToType
Qualifier to type.protected org.apache.chemistry.opencmis.server.support.query.QueryObject
query
protected org.apache.chemistry.opencmis.server.support.query.QueryUtilStrict
queryUtil
protected List<CMISQLQueryMaker.SqlColumn>
realColumns
The columns we'll actually request from the database.protected List<String>
realColumnsParams
Parameters for above (for SCORE expressions on some databases)static String
REL_FRAGMENT_NAME
static String
REL_SOURCE_KEY
static String
REL_TARGET_KEY
protected boolean
searchLatestVersion
Search only latest version = !searchAllVersions.boolean
skipDeleted
static String
TYPE
protected Map<String,org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition<?>>
typeInfo
Type info returned to caller.protected Set<String>
versionableQualifiers
The qualifiers which correspond to versionable types.protected List<String>
virtualColumnNames
used for diagnostic when using DISTINCTprotected Map<String,org.apache.chemistry.opencmis.server.support.query.ColumnReference>
virtualColumns
The non-real-columns we'll return as well.
-
Constructor Summary
Constructors Constructor Description CMISQLQueryMaker()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accepts(String queryType)
Checks if this query maker accepts a given query.protected void
addSystemColumns(boolean addSystemColumns, boolean distinct)
protected String
applySecurityPolicyQueryTransformers(NuxeoCmisService service, NuxeoPrincipal principal, String statement)
Applies security policies query transformers to the statement, if possible.QueryMaker.Query
buildQuery(SQLInfo sqlInfo, Model model, Session.PathResolver pathResolver, String statement, QueryFilter queryFilter, Object... params)
Builds the query.protected static String
cmisToFulltextQuery(String statement)
protected void
findVersionableQualifiers()
protected Column
getColumn(org.apache.chemistry.opencmis.server.support.query.ColumnReference col)
Finds a database column from a CMIS reference.protected static String
getColumnKey(org.apache.chemistry.opencmis.server.support.query.ColumnReference col)
Get key to use in data returned to high-level caller.String
getName()
Gets the name for this query maker.protected static String
getPropertyKey(String qual, String id)
protected Column
getSystemColumn(String id)
protected Column
getSystemColumn(String qual, String id)
protected Table
getTable(Table table, String qual)
protected String
getTableAlias(Table table, String qual)
protected org.apache.chemistry.opencmis.commons.definitions.TypeDefinition
getTypeForQualifier(String qual)
protected boolean
isFacetsColumn(String name)
protected void
recordColumnFragment(String qual, Column column)
Records a database column's fragment (to know what to join).protected void
recordFragment(String qual, Table table)
Records a database table and qualifier (to know what to join).protected void
recordSelector(org.apache.chemistry.opencmis.server.support.query.CmisSelector sel, CMISQLQueryMaker.ClauseType clauseType)
Records a JOIN / WHERE / ORDER BY selector, and associates it to a database column.protected void
recordSelectSelector(org.apache.chemistry.opencmis.server.support.query.CmisSelector sel)
Records a SELECT selector, and associates it to a database column.protected void
resolveQualifiers()
Finds what qualifiers are allowed and to what correlation name they are mapped.
-
-
-
Field Detail
-
TYPE
public static final String TYPE
- See Also:
- Constant Field Values
-
CMIS_PREFIX
public static final String CMIS_PREFIX
- See Also:
- Constant Field Values
-
NX_PREFIX
public static final String NX_PREFIX
- See Also:
- Constant Field Values
-
DC_FRAGMENT_NAME
public static final String DC_FRAGMENT_NAME
- See Also:
- Constant Field Values
-
DC_TITLE_KEY
public static final String DC_TITLE_KEY
- See Also:
- Constant Field Values
-
DC_DESCRIPTION_KEY
public static final String DC_DESCRIPTION_KEY
- See Also:
- Constant Field Values
-
DC_CREATOR_KEY
public static final String DC_CREATOR_KEY
- See Also:
- Constant Field Values
-
DC_CREATED_KEY
public static final String DC_CREATED_KEY
- See Also:
- Constant Field Values
-
DC_MODIFIED_KEY
public static final String DC_MODIFIED_KEY
- See Also:
- Constant Field Values
-
DC_LAST_CONTRIBUTOR_KEY
public static final String DC_LAST_CONTRIBUTOR_KEY
- See Also:
- Constant Field Values
-
REL_FRAGMENT_NAME
public static final String REL_FRAGMENT_NAME
- See Also:
- Constant Field Values
-
REL_SOURCE_KEY
public static final String REL_SOURCE_KEY
- See Also:
- Constant Field Values
-
REL_TARGET_KEY
public static final String REL_TARGET_KEY
- See Also:
- Constant Field Values
-
MIXINS_NOT_PER_INSTANCE
protected static final Set<String> MIXINS_NOT_PER_INSTANCE
These mixins never match an instance mixin when used in a clause nuxeo:secondaryObjectTypeIds = 'foo'
-
database
protected Database database
-
dialect
protected Dialect dialect
-
model
protected Model model
-
hierTable
protected Table hierTable
-
skipDeleted
public boolean skipDeleted
-
queryUtil
protected org.apache.chemistry.opencmis.server.support.query.QueryUtilStrict queryUtil
-
query
protected org.apache.chemistry.opencmis.server.support.query.QueryObject query
-
fulltextMatchInfo
protected Dialect.FulltextMatchInfo fulltextMatchInfo
-
canonicalQualifier
protected Map<String,String> canonicalQualifier
Qualifier to canonical qualifier (correlation name).
-
versionableQualifiers
protected Set<String> versionableQualifiers
The qualifiers which correspond to versionable types.
-
realColumns
protected List<CMISQLQueryMaker.SqlColumn> realColumns
The columns we'll actually request from the database.
-
realColumnsParams
protected List<String> realColumnsParams
Parameters for above (for SCORE expressions on some databases)
-
virtualColumns
protected Map<String,org.apache.chemistry.opencmis.server.support.query.ColumnReference> virtualColumns
The non-real-columns we'll return as well.
-
typeInfo
protected Map<String,org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition<?>> typeInfo
Type info returned to caller.
-
searchLatestVersion
protected boolean searchLatestVersion
Search only latest version = !searchAllVersions.
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:QueryMaker
Gets the name for this query maker.- Specified by:
getName
in interfaceQueryMaker
-
accepts
public boolean accepts(String queryType)
Description copied from interface:QueryMaker
Checks if this query maker accepts a given query.Called first.
- Specified by:
accepts
in interfaceQueryMaker
- Parameters:
queryType
- the query- Returns:
true
if the query is accepted
-
buildQuery
public QueryMaker.Query buildQuery(SQLInfo sqlInfo, Model model, Session.PathResolver pathResolver, String statement, QueryFilter queryFilter, Object... params)
Builds the query.The optional parameters must be passed:
params[0]
is theNuxeoCmisService
, optionalparams[1]
is a type info map, optionalparams[2]
is searchAllVersions (defaultBoolean.TRUE
for this method).- Specified by:
buildQuery
in interfaceQueryMaker
- Parameters:
sqlInfo
- the sql infomodel
- the modelpathResolver
- the path resolverstatement
- the queryqueryFilter
- the query filterparams
- additional parameters, maker-specific
-
applySecurityPolicyQueryTransformers
protected String applySecurityPolicyQueryTransformers(NuxeoCmisService service, NuxeoPrincipal principal, String statement)
Applies security policies query transformers to the statement, if possible. Otherwise raises an exception.- Throws:
org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException
- If a security policy prevents doing CMIS queries.- Since:
- 5.7.2
-
findVersionableQualifiers
protected void findVersionableQualifiers()
-
isFacetsColumn
protected boolean isFacetsColumn(String name)
-
addSystemColumns
protected void addSystemColumns(boolean addSystemColumns, boolean distinct)
-
recordSelectSelector
protected void recordSelectSelector(org.apache.chemistry.opencmis.server.support.query.CmisSelector sel)
Records a SELECT selector, and associates it to a database column.
-
recordSelector
protected void recordSelector(org.apache.chemistry.opencmis.server.support.query.CmisSelector sel, CMISQLQueryMaker.ClauseType clauseType)
Records a JOIN / WHERE / ORDER BY selector, and associates it to a database column.
-
recordColumnFragment
protected void recordColumnFragment(String qual, Column column)
Records a database column's fragment (to know what to join).
-
recordFragment
protected void recordFragment(String qual, Table table)
Records a database table and qualifier (to know what to join).
-
resolveQualifiers
protected void resolveQualifiers()
Finds what qualifiers are allowed and to what correlation name they are mapped.
-
getColumn
protected Column getColumn(org.apache.chemistry.opencmis.server.support.query.ColumnReference col)
Finds a database column from a CMIS reference.
-
getColumnKey
protected static String getColumnKey(org.apache.chemistry.opencmis.server.support.query.ColumnReference col)
Get key to use in data returned to high-level caller.
-
getTypeForQualifier
protected org.apache.chemistry.opencmis.commons.definitions.TypeDefinition getTypeForQualifier(String qual)
-
-