Class VitamMongoRepository
java.lang.Object
fr.gouv.vitam.common.database.api.impl.VitamMongoRepository
- All Implemented Interfaces:
VitamRepository
-
Constructor Summary
ConstructorsConstructorDescriptionVitamMongoRepository(com.mongodb.client.MongoCollection<org.bson.Document> collection) -
Method Summary
Modifier and TypeMethodDescriptionlongcount()Count occurence of documentslongcount(org.bson.conversions.Bson filter) Count occurence of documentsvoidDeleted all documents by idscom.mongodb.client.FindIterable<org.bson.Document>findByFieldsDocuments(Map<String, String> fields, int mongoBatchSize, Integer tenant) Return iterable over document for the given collection for a specific tenant and fieldsOptional<org.bson.Document>findByIdentifier(String identifier) Find by identifier for collections cross tenantOptional<org.bson.Document>findByIdentifierAndTenant(String identifier, Integer tenant) find by identifier for all tenantcom.mongodb.client.FindIterable<org.bson.Document>findDocuments(int mongoBatchSize) Return iterable over document for the given collectioncom.mongodb.client.FindIterable<org.bson.Document>findDocuments(int mongoBatchSize, Integer tenant) Return iterable over document for the given collection for a specific tenantcom.mongodb.client.FindIterable<org.bson.Document>findDocuments(Collection<String> ids, org.bson.conversions.Bson projection) Find collection of document by there id and return only projection fieldscom.mongodb.client.FindIterable<org.bson.Document>findDocuments(org.bson.conversions.Bson query, int mongoBatchSize) Return iterable over document for the given collectionOptional<org.bson.Document>Get vitam document by idlongpurge()Be careful when using this method Remove by tenant for collection cross-tenantlongBe careful when using this method Remove by tenant for collection multi-tenantvoidRemove document by idlongremove(org.bson.conversions.Bson query) Be careful when using this method Remove by queryvoidremoveByNameAndTenant(String name, Integer tenant) Be careful when using this method Remove collection by name and tenantvoidSave a list of vitam documentsvoidsave(org.bson.Document document) Save vitam documentvoidsaveOrUpdate(List<org.bson.Document> documents) Save or update a list of vitam documentssaveOrUpdate(org.bson.Document document) Save or updatevitam documentvoidUsed to execute a bulk update If document exists then update If document do not exists then create document throw Duplicate key exception if document exists by _id but not exists by filter in the update one model
-
Constructor Details
-
VitamMongoRepository
public VitamMongoRepository(com.mongodb.client.MongoCollection<org.bson.Document> collection)
-
-
Method Details
-
save
Description copied from interface:VitamRepositorySave vitam document- Specified by:
savein interfaceVitamRepository- Parameters:
document- the document to be saved- Throws:
DatabaseException- in case error with database occurs
-
saveOrUpdate
Description copied from interface:VitamRepositorySave or updatevitam document- Specified by:
saveOrUpdatein interfaceVitamRepository- Parameters:
document- the document to be saved- Returns:
- status CREATED or UPDATED
- Throws:
DatabaseException- in case error with database occurs
-
save
Description copied from interface:VitamRepositorySave a list of vitam documents- Specified by:
savein interfaceVitamRepository- Parameters:
documents- the list of documents to be saved- Throws:
DatabaseException- in case error with database occurs
-
saveOrUpdate
Description copied from interface:VitamRepositorySave or update a list of vitam documents- Specified by:
saveOrUpdatein interfaceVitamRepository- Parameters:
documents- the list of document to be saved orupdated- Throws:
DatabaseException- in case error with database occurs
-
update
public void update(List<com.mongodb.client.model.WriteModel<org.bson.Document>> queries) throws DatabaseException Description copied from interface:VitamRepositoryUsed to execute a bulk update If document exists then update If document do not exists then create document throw Duplicate key exception if document exists by _id but not exists by filter in the update one model- Specified by:
updatein interfaceVitamRepository- Throws:
DatabaseException
-
remove
Description copied from interface:VitamRepositoryRemove document by id- Specified by:
removein interfaceVitamRepository- Parameters:
id- the id of the document to be removedtenant- the tenant of the document to be removed- Throws:
DatabaseException- in case error with database occurs
-
remove
Description copied from interface:VitamRepositoryBe careful when using this method Remove by query- Specified by:
removein interfaceVitamRepository- Throws:
DatabaseException
-
removeByNameAndTenant
Description copied from interface:VitamRepositoryBe careful when using this method Remove collection by name and tenant- Specified by:
removeByNameAndTenantin interfaceVitamRepository- Parameters:
name- the name of the collection to be removedtenant- the tenant of the collection to be removed- Throws:
DatabaseException- in case error with database occurs
-
purge
Description copied from interface:VitamRepositoryBe careful when using this method Remove by tenant for collection multi-tenant- Specified by:
purgein interfaceVitamRepository- Parameters:
tenant- the tenant- Returns:
- the number of deleted documents
- Throws:
DatabaseException- in case error with database occurs
-
purge
Description copied from interface:VitamRepositoryBe careful when using this method Remove by tenant for collection cross-tenant- Specified by:
purgein interfaceVitamRepository- Returns:
- number of purged documents
- Throws:
DatabaseException- in case error with database occurs
-
getByID
Description copied from interface:VitamRepositoryGet vitam document by id- Specified by:
getByIDin interfaceVitamRepository- Parameters:
id- the document idtenant- the tenant of the document- Returns:
- the document if found
- Throws:
DatabaseException- in case error with database occurs
-
findByIdentifierAndTenant
public Optional<org.bson.Document> findByIdentifierAndTenant(String identifier, Integer tenant) throws DatabaseException Description copied from interface:VitamRepositoryfind by identifier for all tenant- Specified by:
findByIdentifierAndTenantin interfaceVitamRepository- Parameters:
identifier- the identifier of the documenttenant- the tenant of the document- Returns:
- the document if found
- Throws:
DatabaseException- in case error with database occurs
-
findByIdentifier
Description copied from interface:VitamRepositoryFind by identifier for collections cross tenant- Specified by:
findByIdentifierin interfaceVitamRepository- Parameters:
identifier- the identifier of the document- Returns:
- the document if found
- Throws:
DatabaseException- in case error with database occurs
-
findByFieldsDocuments
public com.mongodb.client.FindIterable<org.bson.Document> findByFieldsDocuments(Map<String, String> fields, int mongoBatchSize, Integer tenant) Description copied from interface:VitamRepositoryReturn iterable over document for the given collection for a specific tenant and fields- Specified by:
findByFieldsDocumentsin interfaceVitamRepository- Parameters:
fields- list of fields for filtermongoBatchSize- mongoBatchSizetenant- tenant id- Returns:
- iterable over document for the given collection
-
findDocuments
public com.mongodb.client.FindIterable<org.bson.Document> findDocuments(Collection<String> ids, org.bson.conversions.Bson projection) Description copied from interface:VitamRepositoryFind collection of document by there id and return only projection fields- Specified by:
findDocumentsin interfaceVitamRepository- Parameters:
ids- list of documents idprojection- the fields wanted in the result- Returns:
- An iterable of documents
-
findDocuments
public com.mongodb.client.FindIterable<org.bson.Document> findDocuments(int mongoBatchSize, Integer tenant) Description copied from interface:VitamRepositoryReturn iterable over document for the given collection for a specific tenant- Specified by:
findDocumentsin interfaceVitamRepository- Parameters:
mongoBatchSize- mongoBatchSizetenant- tenant id- Returns:
- iterable over document for the given collection
-
findDocuments
public com.mongodb.client.FindIterable<org.bson.Document> findDocuments(int mongoBatchSize) Description copied from interface:VitamRepositoryReturn iterable over document for the given collection- Specified by:
findDocumentsin interfaceVitamRepository- Parameters:
mongoBatchSize- mongoBatchSize- Returns:
- iterable over document for the given collection
-
findDocuments
public com.mongodb.client.FindIterable<org.bson.Document> findDocuments(org.bson.conversions.Bson query, int mongoBatchSize) Description copied from interface:VitamRepositoryReturn iterable over document for the given collection- Specified by:
findDocumentsin interfaceVitamRepository- Parameters:
query- the mongo query to be executedmongoBatchSize- mongoBatchSize- Returns:
- iterable over document for the given collection
-
delete
Description copied from interface:VitamRepositoryDeleted all documents by ids- Specified by:
deletein interfaceVitamRepository
-
count
public long count()Description copied from interface:VitamRepositoryCount occurence of documents- Specified by:
countin interfaceVitamRepository- Returns:
- the number of documents
-
count
public long count(org.bson.conversions.Bson filter) Description copied from interface:VitamRepositoryCount occurence of documents- Specified by:
countin interfaceVitamRepository- Parameters:
filter- filtre- Returns:
- the number of documents
-