public class VitamElasticsearchRepository extends Object implements VitamRepository
Modifier and Type | Field and Description |
---|---|
static String |
IDENTIFIER
Identifier
|
Constructor and Description |
---|
VitamElasticsearchRepository(org.elasticsearch.client.Client client,
String indexName,
boolean indexByTenant)
VitamElasticsearchRepository Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
delete(List<String> ids,
int tenant)
Deleted all documents by ids
|
com.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 fields
|
Optional<org.bson.Document> |
findByIdentifier(String identifier)
Find by identifier for collections cross tenant
|
Optional<org.bson.Document> |
findByIdentifierAndTenant(String identifier,
Integer tenant)
find by identifier for all tenant
|
com.mongodb.client.FindIterable<org.bson.Document> |
findDocuments(org.bson.conversions.Bson query,
int mongoBatchSize)
Return iterable over document for the given collection
|
com.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 fields
|
com.mongodb.client.FindIterable<org.bson.Document> |
findDocuments(int mongoBatchSize)
Return iterable over document for the given collection
|
com.mongodb.client.FindIterable<org.bson.Document> |
findDocuments(int mongoBatchSize,
Integer tenant)
Return iterable over document for the given collection for a specific tenant
|
Optional<org.bson.Document> |
getByID(String id,
Integer tenant)
Get vitam document by id
|
long |
purge()
Be careful when using this method
Remove by tenant for collection cross-tenant
|
long |
purge(Integer tenant)
Be careful when using this method
Remove by tenant for collection multi-tenant
|
long |
remove(org.bson.conversions.Bson query)
Be careful when using this method
Remove by query
|
void |
remove(String id,
Integer tenant)
Remove document by id
|
void |
removeByNameAndTenant(String name,
Integer tenant)
Be careful when using this method
Remove collection by name and tenant
|
void |
save(org.bson.Document document)
Save vitam document
|
void |
save(List<org.bson.Document> documents)
Save a list of vitam documents
|
void |
saveLogbook(List<org.bson.Document> documents)
Reindex Logbook documents
|
VitamRepositoryStatus |
saveOrUpdate(org.bson.Document document)
Save or updatevitam document
|
void |
saveOrUpdate(List<org.bson.Document> documents)
Save or update a list of vitam documents
|
void |
saveUnit(List<org.bson.Document> documents)
Reindex Unit documents
|
void |
update(List<com.mongodb.client.model.WriteModel<org.bson.Document>> updates)
Used 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
|
public static final String IDENTIFIER
public VitamElasticsearchRepository(org.elasticsearch.client.Client client, String indexName, boolean indexByTenant)
client
- the es clientindexName
- the name of the indexindexByTenant
- specifies if the index is for a specific tenant or notpublic void save(org.bson.Document document) throws DatabaseException
VitamRepository
save
in interface VitamRepository
document
- the document to be savedDatabaseException
- in case error with database occurspublic VitamRepositoryStatus saveOrUpdate(org.bson.Document document) throws DatabaseException
VitamRepository
saveOrUpdate
in interface VitamRepository
document
- the document to be savedDatabaseException
- in case error with database occurspublic void save(List<org.bson.Document> documents) throws DatabaseException
VitamRepository
save
in interface VitamRepository
documents
- the list of documents to be savedDatabaseException
- in case error with database occurspublic void saveUnit(List<org.bson.Document> documents) throws DatabaseException
documents
- documents to be reindexedDatabaseException
- if the ES insert was in errorpublic void saveLogbook(List<org.bson.Document> documents) throws DatabaseException
documents
- documents to be reindexedDatabaseException
- if the ES insert was in errorpublic void saveOrUpdate(List<org.bson.Document> documents) throws DatabaseException
VitamRepository
saveOrUpdate
in interface VitamRepository
documents
- the list of document to be saved orupdatedDatabaseException
- in case error with database occurspublic void update(List<com.mongodb.client.model.WriteModel<org.bson.Document>> updates) throws DatabaseException
VitamRepository
update
in interface VitamRepository
DatabaseException
public com.mongodb.client.FindIterable<org.bson.Document> findDocuments(Collection<String> ids, org.bson.conversions.Bson projection)
VitamRepository
findDocuments
in interface VitamRepository
ids
- list of documents idprojection
- the fields wanted in the resultpublic void remove(String id, Integer tenant) throws DatabaseException
VitamRepository
remove
in interface VitamRepository
id
- the id of the document to be removedtenant
- the tenant of the document to be removedDatabaseException
- in case error with database occurspublic long remove(org.bson.conversions.Bson query) throws DatabaseException
VitamRepository
remove
in interface VitamRepository
DatabaseException
public void removeByNameAndTenant(String name, Integer tenant) throws DatabaseException
VitamRepository
removeByNameAndTenant
in interface VitamRepository
name
- the name of the collection to be removedtenant
- the tenant of the collection to be removedDatabaseException
- in case error with database occurspublic long purge(Integer tenant) throws DatabaseException
VitamRepository
purge
in interface VitamRepository
tenant
- the tenantDatabaseException
- in case error with database occurspublic long purge() throws DatabaseException
VitamRepository
purge
in interface VitamRepository
DatabaseException
- in case error with database occurspublic Optional<org.bson.Document> getByID(String id, Integer tenant) throws DatabaseException
VitamRepository
getByID
in interface VitamRepository
id
- the document idtenant
- the tenant of the documentDatabaseException
- in case error with database occurspublic Optional<org.bson.Document> findByIdentifierAndTenant(String identifier, Integer tenant) throws DatabaseException
VitamRepository
findByIdentifierAndTenant
in interface VitamRepository
identifier
- the identifier of the documenttenant
- the tenant of the documentDatabaseException
- in case error with database occurspublic Optional<org.bson.Document> findByIdentifier(String identifier) throws DatabaseException
VitamRepository
findByIdentifier
in interface VitamRepository
identifier
- the identifier of the documentDatabaseException
- in case error with database occurspublic com.mongodb.client.FindIterable<org.bson.Document> findByFieldsDocuments(Map<String,String> fields, int mongoBatchSize, Integer tenant)
VitamRepository
findByFieldsDocuments
in interface VitamRepository
fields
- list of fields for filtermongoBatchSize
- mongoBatchSizetenant
- tenant idpublic com.mongodb.client.FindIterable<org.bson.Document> findDocuments(int mongoBatchSize, Integer tenant)
VitamRepository
findDocuments
in interface VitamRepository
mongoBatchSize
- mongoBatchSizetenant
- tenant idpublic com.mongodb.client.FindIterable<org.bson.Document> findDocuments(int mongoBatchSize)
VitamRepository
findDocuments
in interface VitamRepository
mongoBatchSize
- mongoBatchSizepublic com.mongodb.client.FindIterable<org.bson.Document> findDocuments(org.bson.conversions.Bson query, int mongoBatchSize)
VitamRepository
findDocuments
in interface VitamRepository
query
- the mongo query to be executedmongoBatchSize
- mongoBatchSizepublic void delete(List<String> ids, int tenant) throws DatabaseException
VitamRepository
delete
in interface VitamRepository
DatabaseException
Copyright © 2018 Vitam. All rights reserved.