Class MongoStorageServiceImpl
- java.lang.Object
- 
- co.mastermindcms.modules.services.MongoStorageServiceImpl
 
- 
- All Implemented Interfaces:
- MongoStorageService,- java.io.Serializable
 
 @Service public class MongoStorageServiceImpl extends java.lang.Object implements MongoStorageService - See Also:
- Serialized Form
 
- 
- 
Field SummaryFields Modifier and Type Field Description private org.springframework.data.mongodb.gridfs.GridFsOperationsgridFsOperationsprivate org.springframework.data.mongodb.gridfs.GridFsTemplategridFsTemplateprivate static org.slf4j.Loggerloggerprivate org.springframework.data.mongodb.core.MongoTemplatemongoTemplate
 - 
Constructor SummaryConstructors Constructor Description MongoStorageServiceImpl()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]downloadBinary(java.lang.String id)This method does download data in database.byte[]downloadBinary(java.lang.String dbName, java.lang.String collectionName, java.lang.Object doc)This method does download data in database.<T> org.springframework.data.domain.Page<T>find(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)This method does find requests and returns data as page.java.util.Map<java.lang.String,java.lang.Object>findDocuments(java.lang.String dbName, java.lang.String collectionName, java.util.Map<java.lang.String,java.lang.Object> filter)This method does find documents and returns data as map.<T> java.util.stream.Stream<T>findToStream(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)This method does find requests and returns data as stream.com.mongodb.client.gridfs.GridFSBucketgetBinaryStorage(java.lang.String dbName, java.lang.String binaryCollection)This method does return database system.com.mongodb.client.MongoCollection<org.bson.Document>getCollection(java.lang.String dbName, java.lang.String collectionName)This method does return database collection.java.util.List<java.util.Map<java.lang.String,java.lang.String>>getCollections(java.lang.String dbName)This method retrieves a map, which can be processed in a database.com.mongodb.client.MongoDatabasegetDatabase(java.lang.String dbName)This method does return database.org.bson.DocumentgetDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.Object id)This method does return database document.<T> Tinsert(T item)This method does insert database entity.java.lang.ObjectinsertDocument(java.lang.String dbName, java.lang.String collectionName, java.util.Map<java.lang.String,java.lang.Object> mapObject)This method does insert database document.<T> voidremove(T item)This method does remove database entity.voidremoveBinary(java.lang.String id)This method does remove database binary.voidremoveBinary(java.lang.String dbName, java.lang.String binStorageName, java.lang.String json)This method does remove database binary.voidremoveDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.String id)This method does remove database document.<T> Tsave(T item)This method does save database entity.java.lang.ObjectsaveDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.String id, java.util.Map<java.lang.String,java.lang.Object> mapObject)This method does save database document.<T> org.springframework.data.domain.Page<T>search(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort, int skip, int limit)This method does search requests and returns data as page.<T> org.springframework.data.domain.Page<T>textSearch(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort, int skip, int limit)This method does search requests and returns data as page.<T> java.util.List<T>textSearchAsList(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)This method does search requests and returns data as list.<T> org.springframework.data.domain.Page<T>textSearchUnpaged(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)This method does search requests and returns data as page.java.lang.StringuploadBinary(java.util.Map<java.lang.String,java.lang.Object> metadata, org.springframework.web.multipart.MultipartFile file)This method does upload database bean.
 
- 
- 
- 
Field Detail- 
loggerprivate static final org.slf4j.Logger logger 
 - 
mongoTemplate@Autowired private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate 
 - 
gridFsTemplate@Autowired private org.springframework.data.mongodb.gridfs.GridFsTemplate gridFsTemplate 
 - 
gridFsOperations@Autowired private org.springframework.data.mongodb.gridfs.GridFsOperations gridFsOperations 
 
- 
 - 
Method Detail- 
getDocumentpublic org.bson.Document getDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.Object id)Description copied from interface:MongoStorageServiceThis method does return database document.- Specified by:
- getDocumentin interface- MongoStorageService
- Parameters:
- dbName- database, from which will be returned
- collectionName- database collection, from which will be returned
- id- database document, which will be returned
- Returns:
- database document
 
 - 
getCollectionpublic com.mongodb.client.MongoCollection<org.bson.Document> getCollection(java.lang.String dbName, java.lang.String collectionName)Description copied from interface:MongoStorageServiceThis method does return database collection.- Specified by:
- getCollectionin interface- MongoStorageService
- Parameters:
- dbName- database, from which will be returned
- collectionName- database collection, which will be returned
- Returns:
- database collection
 
 - 
getCollectionspublic java.util.List<java.util.Map<java.lang.String,java.lang.String>> getCollections(java.lang.String dbName) Description copied from interface:MongoStorageServiceThis method retrieves a map, which can be processed in a database.- Specified by:
- getCollectionsin interface- MongoStorageService
- Parameters:
- dbName- identification for database collection which will be retrieved
- Returns:
- map-representation of data
 
 - 
getDatabasepublic com.mongodb.client.MongoDatabase getDatabase(java.lang.String dbName) Description copied from interface:MongoStorageServiceThis method does return database.- Specified by:
- getDatabasein interface- MongoStorageService
- Parameters:
- dbName- database, where will be returned
- Returns:
- database
 
 - 
insertDocumentpublic java.lang.Object insertDocument(java.lang.String dbName, java.lang.String collectionName, java.util.Map<java.lang.String,java.lang.Object> mapObject)Description copied from interface:MongoStorageServiceThis method does insert database document.- Specified by:
- insertDocumentin interface- MongoStorageService
- Parameters:
- dbName- database, where will be saved
- collectionName- collection, where will be saved
- mapObject- map-representation which converted in json object and inserted in database
- Returns:
- inserted database document
 
 - 
insertpublic <T> T insert(T item) Description copied from interface:MongoStorageServiceThis method does insert database entity.- Specified by:
- insertin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- item- database entity, which will be saved
- Returns:
- inserted database entity
 
 - 
saveDocumentpublic java.lang.Object saveDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.String id, java.util.Map<java.lang.String,java.lang.Object> mapObject)Description copied from interface:MongoStorageServiceThis method does save database document.- Specified by:
- saveDocumentin interface- MongoStorageService
- Parameters:
- dbName- database, where will be saved
- collectionName- collection, where will be saved
- id- database document, which will be saved
- mapObject- map-representation which converted in json object and inserted in database
- Returns:
- saved database document
 
 - 
savepublic <T> T save(T item) Description copied from interface:MongoStorageServiceThis method does save database entity.- Specified by:
- savein interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- item- database entity, which will be saved
- Returns:
- saved database entity
 
 - 
removeDocumentpublic void removeDocument(java.lang.String dbName, java.lang.String collectionName, java.lang.String id)Description copied from interface:MongoStorageServiceThis method does remove database document.- Specified by:
- removeDocumentin interface- MongoStorageService
- Parameters:
- dbName- database, from which it will be removed
- collectionName- collection, from which it will be removed
- id- database document, which will be removed
 
 - 
removepublic <T> void remove(T item) Description copied from interface:MongoStorageServiceThis method does remove database entity.- Specified by:
- removein interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- item- database entity, which will be removed
 
 - 
findDocumentspublic java.util.Map<java.lang.String,java.lang.Object> findDocuments(java.lang.String dbName, java.lang.String collectionName, java.util.Map<java.lang.String,java.lang.Object> filter)Description copied from interface:MongoStorageServiceThis method does find documents and returns data as map.- Specified by:
- findDocumentsin interface- MongoStorageService
- Parameters:
- dbName- search query
- collectionName- field which sort and returned items
- filter- database entity class type which will be returned
- Returns:
- database entities as map
 
 - 
findToStreampublic <T> java.util.stream.Stream<T> findToStream(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)Description copied from interface:MongoStorageServiceThis method does find requests and returns data as stream.- Specified by:
- findToStreamin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- Returns:
- database entities as stream
 
 - 
findpublic <T> org.springframework.data.domain.Page<T> find(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)Description copied from interface:MongoStorageServiceThis method does find requests and returns data as page.- Specified by:
- findin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- Returns:
- database entities as page
 
 - 
searchpublic <T> org.springframework.data.domain.Page<T> search(org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort, int skip, int limit)Description copied from interface:MongoStorageServiceThis method does search requests and returns data as page.- Specified by:
- searchin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- skip- skip for returned items
- limit- limit for returned items
- Returns:
- database entities as page
 
 - 
textSearchpublic <T> org.springframework.data.domain.Page<T> textSearch(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort, int skip, int limit)Description copied from interface:MongoStorageServiceThis method does search requests and returns data as page.- Specified by:
- textSearchin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- searchTerms- fields list which filter and returned items
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- skip- skip for returned items
- limit- limit for returned items
- Returns:
- database entities as page
 
 - 
textSearchUnpagedpublic <T> org.springframework.data.domain.Page<T> textSearchUnpaged(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)Description copied from interface:MongoStorageServiceThis method does search requests and returns data as page.- Specified by:
- textSearchUnpagedin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- searchTerms- fields list which filter and returned items
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- Returns:
- database entities as page
 
 - 
textSearchAsListpublic <T> java.util.List<T> textSearchAsList(java.lang.String[] searchTerms, org.springframework.data.mongodb.core.query.Query query, java.lang.Class<T> clazz, java.lang.String sort)Description copied from interface:MongoStorageServiceThis method does search requests and returns data as list.- Specified by:
- textSearchAsListin interface- MongoStorageService
- Type Parameters:
- T- class type of entity
- Parameters:
- searchTerms- fields list which filter and returned items
- query- search query
- clazz- database entity class type which will be returned
- sort- field which sort and returned items
- Returns:
- database entities as list
 
 - 
downloadBinarypublic byte[] downloadBinary(java.lang.String dbName, java.lang.String collectionName, java.lang.Object doc)Description copied from interface:MongoStorageServiceThis method does download data in database.- Specified by:
- downloadBinaryin interface- MongoStorageService
- Parameters:
- dbName- database, from which it will be downloaded
- collectionName- collection, from which it will be downloaded
- doc- database document, which will be downloaded
- Returns:
- data as byte list
 
 - 
downloadBinarypublic byte[] downloadBinary(java.lang.String id) Description copied from interface:MongoStorageServiceThis method does download data in database.- Specified by:
- downloadBinaryin interface- MongoStorageService
- Parameters:
- id- unique id from file in storage
- Returns:
- data as byte list
 
 - 
getBinaryStoragepublic com.mongodb.client.gridfs.GridFSBucket getBinaryStorage(java.lang.String dbName, java.lang.String binaryCollection)Description copied from interface:MongoStorageServiceThis method does return database system.- Specified by:
- getBinaryStoragein interface- MongoStorageService
- Parameters:
- dbName- database, from which it will be returned
- binaryCollection- collection, from which it will be returned
- Returns:
- database system
 
 - 
uploadBinarypublic java.lang.String uploadBinary(java.util.Map<java.lang.String,java.lang.Object> metadata, org.springframework.web.multipart.MultipartFile file)Description copied from interface:MongoStorageServiceThis method does upload database bean.- Specified by:
- uploadBinaryin interface- MongoStorageService
- Parameters:
- metadata- meta information for uploaded document
- file- file data, which will be uploaded
- Returns:
- unique id from uploaded file
 
 - 
removeBinarypublic void removeBinary(java.lang.String dbName, java.lang.String binStorageName, java.lang.String json)Description copied from interface:MongoStorageServiceThis method does remove database binary.- Specified by:
- removeBinaryin interface- MongoStorageService
- Parameters:
- dbName- database, from which it will be returned
- binStorageName- database bean storage name, which it will be removed
- json- JSON-object of request contains an instructions for search binary
 
 - 
removeBinarypublic void removeBinary(java.lang.String id) Description copied from interface:MongoStorageServiceThis method does remove database binary.- Specified by:
- removeBinaryin interface- MongoStorageService
- Parameters:
- id- unique id, which it will be removed
 
 
- 
 
-