public class MongoDBRepository extends DBSRepositoryBase
Repository
.Modifier and Type | Class and Description |
---|---|
static class |
MongoDBRepository.Updates |
DBSRepositoryBase.DBSSessionInvoker, DBSRepositoryBase.TransactionContext
Modifier and Type | Field and Description |
---|---|
static String |
DB_DEFAULT |
static String |
MONGODB_EACH |
static String |
MONGODB_ID |
static String |
MONGODB_INC |
static String |
MONGODB_META |
static String |
MONGODB_PUSH |
static String |
MONGODB_SET |
static String |
MONGODB_TEXT_SCORE |
static String |
MONGODB_UNSET |
transactionContexts, TYPE_ROOT
Constructor and Description |
---|
MongoDBRepository(MongoDBRepositoryDescriptor descriptor) |
Modifier and Type | Method and Description |
---|---|
void |
createState(State state)
Creates a document.
|
void |
deleteStates(Set<String> ids)
Deletes a set of document.
|
String |
generateNewId()
Generates a new id for a document.
|
static com.mongodb.DBCollection |
getCollection(MongoDBRepositoryDescriptor descriptor,
com.mongodb.MongoClient mongoClient) |
static com.mongodb.DBCollection |
getCountersCollection(MongoDBRepositoryDescriptor descriptor,
com.mongodb.MongoClient mongoClient) |
boolean |
hasChild(String parentId,
String name,
Set<String> ignored)
Checks if a document has a child with the given name
|
static com.mongodb.MongoClient |
newMongoClient(MongoDBRepositoryDescriptor descriptor) |
PartialList<State> |
queryAndFetch(Expression expression,
DBSExpressionEvaluator evaluator,
OrderByClause orderByClause,
int limit,
int offset,
int countUpTo,
boolean deepCopy,
boolean fulltextScore)
Queries the repository for documents matching a query.
|
List<State> |
queryKeyValue(String key,
String value,
Set<String> ignored)
Queries the repository for documents having key = value.
|
void |
queryKeyValueArray(String key,
Object value,
Set<String> ids,
Map<String,String> proxyTargets,
Map<String,Object[]> targetProxies)
Queries the repository for document ids having value in key (an array).
|
boolean |
queryKeyValuePresence(String key,
String value,
Set<String> ignored)
Queries the repository to check if there are documents having key = value.
|
State |
readChildState(String parentId,
String name,
Set<String> ignored)
Reads the state of a child document.
|
State |
readState(String id)
Reads the state of a document.
|
List<State> |
readStates(List<String> ids)
Reads the states of several documents.
|
void |
shutdown() |
void |
updateState(String id,
State.StateDiff diff)
Updates a document.
|
getActiveSessionsCount, getBlobManager, getName, getRootId, getSession, initRoot, isFulltextDisabled, newBinaryManager
public static final String DB_DEFAULT
public static final String MONGODB_ID
public static final String MONGODB_INC
public static final String MONGODB_SET
public static final String MONGODB_UNSET
public static final String MONGODB_PUSH
public static final String MONGODB_EACH
public static final String MONGODB_META
public static final String MONGODB_TEXT_SCORE
public MongoDBRepository(MongoDBRepositoryDescriptor descriptor)
public void shutdown()
shutdown
in interface Repository
shutdown
in class DBSRepositoryBase
public static com.mongodb.MongoClient newMongoClient(MongoDBRepositoryDescriptor descriptor) throws UnknownHostException
UnknownHostException
public static com.mongodb.DBCollection getCollection(MongoDBRepositoryDescriptor descriptor, com.mongodb.MongoClient mongoClient)
public static com.mongodb.DBCollection getCountersCollection(MongoDBRepositoryDescriptor descriptor, com.mongodb.MongoClient mongoClient)
public String generateNewId()
DBSRepository
public void createState(State state) throws DocumentException
DBSRepository
state
- the document stateDocumentException
- if the document already existspublic State readState(String id)
DBSRepository
id
- the document idnull
if not foundpublic List<State> readStates(List<String> ids)
DBSRepository
The returned states may be in a different order than the ids.
ids
- the document idsnull
if not foundpublic void updateState(String id, State.StateDiff diff) throws DocumentException
DBSRepository
id
- the document iddiff
- the diff to applyDocumentException
- if the document does not existpublic void deleteStates(Set<String> ids) throws DocumentException
DBSRepository
ids
- the document idsDocumentException
public State readChildState(String parentId, String name, Set<String> ignored)
DBSRepository
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be considerednull
if not foundpublic boolean hasChild(String parentId, String name, Set<String> ignored)
DBSRepository
parentId
- the parent document idname
- the name of the childignored
- a set of document ids that should not be consideredtrue
if the child exists, false
if notpublic List<State> queryKeyValue(String key, String value, Set<String> ignored)
DBSRepository
key
- the keyvalue
- the valueignored
- a set of document ids that should not be consideredpublic void queryKeyValueArray(String key, Object value, Set<String> ids, Map<String,String> proxyTargets, Map<String,Object[]> targetProxies)
DBSRepository
key
- the keyvalue
- the valueids
- the set which receives the documents idsproxyTargets
- returns a map of proxy to target among the documents foundtargetProxies
- returns a map of target to proxies among the document foundpublic boolean queryKeyValuePresence(String key, String value, Set<String> ignored)
DBSRepository
key
- the keyvalue
- the valueignored
- a set of document ids that should not be consideredtrue
if the query matches at least one document, false
if the query matches nothingpublic PartialList<State> queryAndFetch(Expression expression, DBSExpressionEvaluator evaluator, OrderByClause orderByClause, int limit, int offset, int countUpTo, boolean deepCopy, boolean fulltextScore)
DBSRepository
expression
- the query expressionevaluator
- the map-based evaluator for the queryorderByClause
- an ORDER BY clauselimit
- 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.0
, don't count the total size, set it to -1
.n
, count the total number if there are less than n documents otherwise set the total size
to -2
.deepCopy
- whether returned state should be a copyfulltextScore
- whether returned state should include the fulltext scoreCopyright © 2015 Nuxeo SA. All rights reserved.