public class MongoDBQueryModelDAO<T,ID> extends java.lang.Object implements QueryModelDAO<T,ID>, AccessControlDAO<T,ID>
This QueryModelDAO implementation for MongoDB provides bi-directional ODM (Object to Document Mapping) as well
as the rich query capabilities found in the core org.iternine.jeppetto.dao package.
Instantiation requires a daoProperties Map<String, Object> that will look for the following keys (and expected
values):
| Key | Required? | Description |
| db | Yes | Instance of a configured com.mongodb.DB |
| collection | No | Name of the backing collection for this object. Defaults to the name of the entity class. |
| viewOf | No | Name of the a class of which this DAO's entity class is a view. |
| uniqueIndexes | No | List<String> of various MongoDB index values that will be ensured to exist and must be unique. |
| nonUniqueIndexes | No | List<String> of various MongoDB index values that will be ensured to exist and need not be unique. |
| optimisticLockEnabled | No | Boolean to indicate if instances of the tracked type should be protected by a Jeppetto-managed lock version field. |
| shardKeyPattern | No | A comma-separated string of fields that are used to determine the shard key(s) for the collection. |
| saveNulls | No | Boolean to indicate whether null fields should be included in MongoDB documents. |
| writeConcern | No | String, one of the values as indicated at http://www.mongodb.org/display/DOCS/Replica+Set+Semantics. If not specified, the DAO defaults to "SAFE". |
| showQueries | No | Boolean to indicate if executed queries should be logged. Note that logging will need to be enabled for the DAO's package as well. |
| Modifier | Constructor and Description |
|---|---|
protected |
MongoDBQueryModelDAO(java.lang.Class<T> entityClass,
java.util.Map<java.lang.String,java.lang.Object> daoProperties) |
protected |
MongoDBQueryModelDAO(java.lang.Class<T> entityClass,
java.util.Map<java.lang.String,java.lang.Object> daoProperties,
AccessControlContextProvider accessControlContextProvider) |
| Modifier and Type | Method and Description |
|---|---|
protected com.mongodb.DBObject |
augmentObjectCacheKey(com.mongodb.DBObject key)
This method allows subclasses an opportunity to add any important data to a cache key, such
as the __acl from the AccessControlMongoDAO.
|
Condition |
buildCondition(java.lang.String conditionField,
ConditionType conditionType,
java.util.Iterator argsIterator) |
protected com.mongodb.DBObject |
buildIdentifyingQuery(com.mongodb.DBObject dbo) |
protected com.mongodb.DBObject |
buildIdentifyingQuery(ID... ids) |
Projection |
buildProjection(java.lang.String projectionField,
ProjectionType projectionType,
java.util.Iterator argsIterator) |
protected com.mongodb.DBObject[] |
createIdentifyingQueries(com.mongodb.DBObject dbo) |
void |
delete(T entity) |
void |
deleteById(ID id) |
protected void |
deleteByIdentifyingQuery(com.mongodb.DBObject identifyingQuery) |
void |
deleteByIds(ID... ids) |
void |
deleteUsingQueryModel(QueryModel queryModel) |
java.lang.Iterable<T> |
findAll() |
T |
findById(ID id) |
java.lang.Iterable<T> |
findByIds(ID... ids) |
T |
findUniqueUsingQueryModel(QueryModel queryModel) |
java.lang.Iterable<T> |
findUsingQueryModel(QueryModel queryModel) |
void |
flush() |
AccessControlContextProvider |
getAccessControlContextProvider() |
protected java.lang.Class<T> |
getCollectionClass() |
protected com.mongodb.DBCollection |
getDbCollection() |
java.util.Map<java.lang.String,AccessType> |
getGrantedAccesses(ID id) |
java.util.Map<java.lang.String,AccessType> |
getGrantedAccesses(ID id,
AccessControlContext accessControlContext) |
<U extends T> |
getUpdateObject() |
void |
grantAccess(ID id,
java.lang.String accessId,
AccessType accessType) |
void |
grantAccess(ID id,
java.lang.String accessId,
AccessType accessType,
AccessControlContext accessControlContext) |
java.lang.Object |
projectUsingQueryModel(QueryModel queryModel) |
void |
revokeAccess(ID id,
java.lang.String accessId) |
void |
revokeAccess(ID id,
java.lang.String accessId,
AccessControlContext accessControlContext) |
void |
save(T entity) |
void |
save(T object,
AccessControlContext accessControlContext) |
protected void |
trueRemove(com.mongodb.DBObject identifyingQuery) |
protected void |
trueSave(com.mongodb.DBObject identifyingQuery,
DirtyableDBObject dbo) |
<U extends T> |
updateById(U updateObject,
ID id) |
<U extends T> |
updateByIds(U updateObject,
ID... ids) |
<U extends T> |
updateUniqueUsingQueryModel(U updateObject,
QueryModel queryModel) |
<U extends T> |
updateUsingQueryModel(U updateObject,
QueryModel queryModel) |
protected MongoDBQueryModelDAO(java.lang.Class<T> entityClass, java.util.Map<java.lang.String,java.lang.Object> daoProperties)
protected MongoDBQueryModelDAO(java.lang.Class<T> entityClass, java.util.Map<java.lang.String,java.lang.Object> daoProperties, AccessControlContextProvider accessControlContextProvider)
public T findById(ID id) throws NoSuchItemException, JeppettoException
findById in interface GenericDAO<T,ID>NoSuchItemExceptionJeppettoExceptionpublic java.lang.Iterable<T> findByIds(ID... ids) throws JeppettoException
findByIds in interface GenericDAO<T,ID>JeppettoExceptionpublic java.lang.Iterable<T> findAll() throws JeppettoException
findAll in interface GenericDAO<T,ID>JeppettoExceptionpublic void save(T entity) throws OptimisticLockException, JeppettoException
save in interface GenericDAO<T,ID>OptimisticLockExceptionJeppettoExceptionpublic void delete(T entity) throws JeppettoException
delete in interface GenericDAO<T,ID>JeppettoExceptionpublic void deleteById(ID id) throws JeppettoException
deleteById in interface GenericDAO<T,ID>JeppettoExceptionpublic void deleteByIds(ID... ids) throws FailedBatchException, JeppettoException
deleteByIds in interface GenericDAO<T,ID>FailedBatchExceptionJeppettoExceptionpublic <U extends T> U getUpdateObject()
getUpdateObject in interface GenericDAO<T,ID>public <U extends T> T updateById(U updateObject, ID id) throws JeppettoException
updateById in interface GenericDAO<T,ID>JeppettoExceptionpublic <U extends T> java.lang.Iterable<T> updateByIds(U updateObject, ID... ids) throws FailedBatchException, JeppettoException
updateByIds in interface GenericDAO<T,ID>FailedBatchExceptionJeppettoExceptionpublic void flush()
throws JeppettoException
flush in interface GenericDAO<T,ID>JeppettoExceptionpublic T findUniqueUsingQueryModel(QueryModel queryModel) throws NoSuchItemException, TooManyItemsException, JeppettoException
findUniqueUsingQueryModel in interface QueryModelDAO<T,ID>NoSuchItemExceptionTooManyItemsExceptionJeppettoExceptionpublic java.lang.Iterable<T> findUsingQueryModel(QueryModel queryModel) throws JeppettoException
findUsingQueryModel in interface QueryModelDAO<T,ID>JeppettoExceptionpublic java.lang.Object projectUsingQueryModel(QueryModel queryModel) throws JeppettoException
projectUsingQueryModel in interface QueryModelDAO<T,ID>JeppettoExceptionpublic void deleteUsingQueryModel(QueryModel queryModel) throws JeppettoException
deleteUsingQueryModel in interface QueryModelDAO<T,ID>JeppettoExceptionpublic <U extends T> T updateUniqueUsingQueryModel(U updateObject, QueryModel queryModel) throws JeppettoException
updateUniqueUsingQueryModel in interface QueryModelDAO<T,ID>JeppettoExceptionpublic <U extends T> java.lang.Iterable<T> updateUsingQueryModel(U updateObject, QueryModel queryModel) throws JeppettoException
updateUsingQueryModel in interface QueryModelDAO<T,ID>JeppettoExceptionpublic Condition buildCondition(java.lang.String conditionField, ConditionType conditionType, java.util.Iterator argsIterator)
buildCondition in interface QueryModelDAO<T,ID>public Projection buildProjection(java.lang.String projectionField, ProjectionType projectionType, java.util.Iterator argsIterator)
buildProjection in interface QueryModelDAO<T,ID>public void save(T object, AccessControlContext accessControlContext) throws OptimisticLockException, AccessControlException, JeppettoException
save in interface AccessControlDAO<T,ID>OptimisticLockExceptionAccessControlExceptionJeppettoExceptionpublic void grantAccess(ID id, java.lang.String accessId, AccessType accessType) throws NoSuchItemException, AccessControlException
grantAccess in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic void grantAccess(ID id, java.lang.String accessId, AccessType accessType, AccessControlContext accessControlContext) throws NoSuchItemException, AccessControlException
grantAccess in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic void revokeAccess(ID id, java.lang.String accessId) throws NoSuchItemException, AccessControlException
revokeAccess in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic void revokeAccess(ID id, java.lang.String accessId, AccessControlContext accessControlContext) throws NoSuchItemException, AccessControlException
revokeAccess in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic java.util.Map<java.lang.String,AccessType> getGrantedAccesses(ID id) throws NoSuchItemException, AccessControlException
getGrantedAccesses in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic java.util.Map<java.lang.String,AccessType> getGrantedAccesses(ID id, AccessControlContext accessControlContext) throws NoSuchItemException, AccessControlException
getGrantedAccesses in interface AccessControlDAO<T,ID>NoSuchItemExceptionAccessControlExceptionpublic AccessControlContextProvider getAccessControlContextProvider()
getAccessControlContextProvider in interface AccessControlDAO<T,ID>protected com.mongodb.DBObject augmentObjectCacheKey(com.mongodb.DBObject key)
key - key to augmentprotected com.mongodb.DBObject[] createIdentifyingQueries(com.mongodb.DBObject dbo)
protected final com.mongodb.DBObject buildIdentifyingQuery(com.mongodb.DBObject dbo)
protected final com.mongodb.DBObject buildIdentifyingQuery(ID... ids)
protected final void deleteByIdentifyingQuery(com.mongodb.DBObject identifyingQuery)
protected final void trueSave(com.mongodb.DBObject identifyingQuery,
DirtyableDBObject dbo)
protected final void trueRemove(com.mongodb.DBObject identifyingQuery)
protected final com.mongodb.DBCollection getDbCollection()
protected final java.lang.Class<T> getCollectionClass()
Copyright © 2017. All Rights Reserved.