Package org.nuxeo.ecm.core.storage.dbs
Interface DBSConnection
- All Superinterfaces:
AutoCloseable
,LockManager
- All Known Implementing Classes:
DBSCachingConnection
,DBSConnectionBase
,MemConnection
,MongoDBConnection
Interface for a connection to a
DBSRepository
. The connection maintains state when it is transactional.- Since:
- 11.1 (introduced in 5.9.4 as DBSRepository)
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Abstracts queries with operators. -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin()
Starts a new transaction.void
close()
Closes this connection.void
commit()
Commits the current transaction.void
createState
(State state) Creates a document.default void
createStates
(List<State> states) Creates documents.void
deleteStates
(Set<String> ids) Deletes a set of document.Generates a new id for a document.getDescendants
(String id, Set<String> keys) Returns a stream of descendants from a given root document, in no particular order.getDescendants
(String id, Set<String> keys, int limit) Returns a stream of descendants from a given root document, in no particular order.Gets the root id.boolean
Checks if a document has a child with the given namequeryAndFetch
(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) Queries the repository for documents matching a NXQL query, and returns a projection of the documents.Queries the repository for documents having key1 = value1 and key2 = value2.queryKeyValue
(String key, Object value, Set<String> ignored) Queries the repository for documents having key = value.boolean
queryKeyValuePresence
(String key, String value, Set<String> ignored) Queries the repository to check if there are documents having key = value.queryKeyValueWithOperator
(String key1, Object value1, String key2, DBSConnection.DBSQueryOperator operator, Object value2, Set<String> ignored) Queries the repository for documents having key1 = value1 and key2 ${operator} value2.readChildState
(String parentId, String name, Set<String> ignored) Reads the state of a child document.default State
readPartialState
(String id, Collection<String> keys) Reads the partial state of a document.Reads the state of a document.readStates
(List<String> ids) Reads the states of several documents.void
rollback()
Rolls back the current transaction.Get the next batch of results containing id of documents, thescrollId
is part of the previousScrollResult
response.scroll
(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay.void
updateState
(String id, State.StateDiff diff, DBSTransactionState.ConditionalUpdates conditionalUpdates) Updates a document.Methods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager, getLock, removeLock, setLock
-
Method Details
-
close
void close()Closes this connection.- Specified by:
close
in interfaceAutoCloseable
-
getRootId
String getRootId()Gets the root id.- Returns:
- the root id.
-
generateNewId
String generateNewId()Generates a new id for a document.- Returns:
- the new id
-
readState
Reads the state of a document.- Parameters:
id
- the document id- Returns:
- the document state, or
null
if not found
-
readPartialState
Reads the partial state of a document.- Parameters:
id
- the document idkeys
- the keys to read- Returns:
- the document partial state, or
null
if not found - Since:
- 9.10
-
readStates
Reads the states of several documents.The returned states may be in a different order than the ids.
- Parameters:
ids
- the document ids- Returns:
- the document states, an element by be
null
if not found
-
createState
Creates a document.- Parameters:
state
- the document state
-
createStates
Creates documents.- Parameters:
states
- the document states
-
updateState
void updateState(String id, State.StateDiff diff, DBSTransactionState.ConditionalUpdates conditionalUpdates) Updates a document.- Parameters:
id
- the document iddiff
- the diff to applyconditionalUpdates
- the conditional updates, ornull
-
deleteStates
Deletes a set of document.- Parameters:
ids
- the document ids
-
readChildState
Reads the state of a child document.- Parameters:
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be considered- Returns:
- the state of the child document, or
null
if not found
-
hasChild
Checks if a document has a child with the given name- Parameters:
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be considered- Returns:
true
if the child exists,false
if not
-
queryKeyValue
Queries the repository for documents having key = value.- Parameters:
key
- the keyvalue
- the valueignored
- a set of document ids that should not be considered- Returns:
- the document states matching the query
-
queryKeyValue
List<State> queryKeyValue(String key1, Object value1, String key2, Object value2, Set<String> ignored) Queries the repository for documents having key1 = value1 and key2 = value2.- Parameters:
key1
- the first keyvalue1
- the first valuekey2
- the second keyvalue2
- the second valueignored
- a set of document ids that should not be considered- Returns:
- the document states matching the query
-
queryKeyValueWithOperator
List<State> queryKeyValueWithOperator(String key1, Object value1, String key2, DBSConnection.DBSQueryOperator operator, Object value2, Set<String> ignored) Queries the repository for documents having key1 = value1 and key2 ${operator} value2.- Parameters:
key1
- the first keyvalue1
- the first valuekey2
- the second keyoperator
- the operator to apply between key2 and value2value2
- the second valueignored
- a set of document ids that should not be considered- Returns:
- the document states matching the query
- Since:
- 11.1
-
getDescendants
Returns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.THE STREAM MUST BE CLOSED WHEN DONE to release resources.
- Parameters:
id
- the root document idkeys
- what to collect about the descendants in addition to their ids- Returns:
- a stream of
State
s; THE STREAM MUST BE CLOSED WHEN DONE - Since:
- 9.3
-
getDescendants
Returns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.THE STREAM MUST BE CLOSED WHEN DONE to release resources.
- Parameters:
id
- the root document idkeys
- what to collect about the descendants in addition to their idslimit
- the maximum number of descendants to return- Returns:
- a stream of
State
s; THE STREAM MUST BE CLOSED WHEN DONE - Since:
- 9.10
-
queryKeyValuePresence
Queries the repository to check if there are documents having key = value.- Parameters:
key
- the keyvalue
- the valueignored
- a set of document ids that should not be considered- Returns:
true
if the query matches at least one document,false
if the query matches nothing
-
queryAndFetch
PartialList<Map<String,Serializable>> queryAndFetch(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) Queries the repository for documents matching a NXQL query, and returns a projection of the documents.- Parameters:
evaluator
- the map-based evaluator for the queryorderByClause
- an ORDER BY clausedistinctDocuments
-true
if the projection should return a maximum of one row per documentlimit
- the limit on the number of documents to returnoffset
- the offset in the list of documents to returncountUpTo
- if-1
, count the total size without offset/limit.
If0
, don't count the total size, set it to-1
.
Ifn
, count the total number if there are less than n documents otherwise set the total size to-2
.- Returns:
- a partial list of maps containing the NXQL projections requested, and the total size according to countUpTo
-
scroll
Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSeconds
delay.- Since:
- 8.4
-
scroll
Get the next batch of results containing id of documents, thescrollId
is part of the previousScrollResult
response.- Since:
- 8.4
-
begin
void begin()Starts a new transaction.- Since:
- 8.10
- See Also:
-
commit
void commit()Commits the current transaction.- Since:
- 8.10
- See Also:
-
rollback
void rollback()Rolls back the current transaction.- Since:
- 8.10
- See Also:
-