Class MongoStorageServiceImpl

    • Method Summary

      All 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.GridFSBucket getBinaryStorage​(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.MongoDatabase getDatabase​(java.lang.String dbName)
      This method does return database.
      org.bson.Document getDocument​(java.lang.String dbName, java.lang.String collectionName, java.lang.Object id)
      This method does return database document.
      <T> T insert​(T item)
      This method does insert database entity.
      java.lang.Object insertDocument​(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> void remove​(T item)
      This method does remove database entity.
      void removeBinary​(java.lang.String id)
      This method does remove database binary.
      void removeBinary​(java.lang.String dbName, java.lang.String binStorageName, java.lang.String json)
      This method does remove database binary.
      void removeDocument​(java.lang.String dbName, java.lang.String collectionName, java.lang.String id)
      This method does remove database document.
      <T> T save​(T item)
      This method does save database entity.
      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)
      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.String uploadBinary​(java.util.Map<java.lang.String,​java.lang.Object> metadata, org.springframework.web.multipart.MultipartFile file)
      This method does upload database bean.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MongoStorageServiceImpl

        public MongoStorageServiceImpl()
    • Method Detail

      • getDocument

        public org.bson.Document getDocument​(java.lang.String dbName,
                                             java.lang.String collectionName,
                                             java.lang.Object id)
        Description copied from interface: MongoStorageService
        This method does return database document.
        Specified by:
        getDocument in 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
      • getCollection

        public com.mongodb.client.MongoCollection<org.bson.Document> getCollection​(java.lang.String dbName,
                                                                                   java.lang.String collectionName)
        Description copied from interface: MongoStorageService
        This method does return database collection.
        Specified by:
        getCollection in interface MongoStorageService
        Parameters:
        dbName - database, from which will be returned
        collectionName - database collection, which will be returned
        Returns:
        database collection
      • getCollections

        public java.util.List<java.util.Map<java.lang.String,​java.lang.String>> getCollections​(java.lang.String dbName)
        Description copied from interface: MongoStorageService
        This method retrieves a map, which can be processed in a database.
        Specified by:
        getCollections in interface MongoStorageService
        Parameters:
        dbName - identification for database collection which will be retrieved
        Returns:
        map-representation of data
      • getDatabase

        public com.mongodb.client.MongoDatabase getDatabase​(java.lang.String dbName)
        Description copied from interface: MongoStorageService
        This method does return database.
        Specified by:
        getDatabase in interface MongoStorageService
        Parameters:
        dbName - database, where will be returned
        Returns:
        database
      • insertDocument

        public 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: MongoStorageService
        This method does insert database document.
        Specified by:
        insertDocument in 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
      • insert

        public <T> T insert​(T item)
        Description copied from interface: MongoStorageService
        This method does insert database entity.
        Specified by:
        insert in interface MongoStorageService
        Type Parameters:
        T - class type of entity
        Parameters:
        item - database entity, which will be saved
        Returns:
        inserted database entity
      • saveDocument

        public 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: MongoStorageService
        This method does save database document.
        Specified by:
        saveDocument in 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
      • save

        public <T> T save​(T item)
        Description copied from interface: MongoStorageService
        This method does save database entity.
        Specified by:
        save in interface MongoStorageService
        Type Parameters:
        T - class type of entity
        Parameters:
        item - database entity, which will be saved
        Returns:
        saved database entity
      • removeDocument

        public void removeDocument​(java.lang.String dbName,
                                   java.lang.String collectionName,
                                   java.lang.String id)
        Description copied from interface: MongoStorageService
        This method does remove database document.
        Specified by:
        removeDocument in 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
      • remove

        public <T> void remove​(T item)
        Description copied from interface: MongoStorageService
        This method does remove database entity.
        Specified by:
        remove in interface MongoStorageService
        Type Parameters:
        T - class type of entity
        Parameters:
        item - database entity, which will be removed
      • findDocuments

        public 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: MongoStorageService
        This method does find documents and returns data as map.
        Specified by:
        findDocuments in 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
      • findToStream

        public <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: MongoStorageService
        This method does find requests and returns data as stream.
        Specified by:
        findToStream in 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
      • find

        public <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: MongoStorageService
        This method does find requests and returns data as page.
        Specified by:
        find in 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
      • search

        public <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: MongoStorageService
        This method does search requests and returns data as page.
        Specified by:
        search in 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
      • textSearch

        public <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: MongoStorageService
        This method does search requests and returns data as page.
        Specified by:
        textSearch in 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
      • textSearchUnpaged

        public <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: MongoStorageService
        This method does search requests and returns data as page.
        Specified by:
        textSearchUnpaged in 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
      • textSearchAsList

        public <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: MongoStorageService
        This method does search requests and returns data as list.
        Specified by:
        textSearchAsList in 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
      • downloadBinary

        public byte[] downloadBinary​(java.lang.String dbName,
                                     java.lang.String collectionName,
                                     java.lang.Object doc)
        Description copied from interface: MongoStorageService
        This method does download data in database.
        Specified by:
        downloadBinary in 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
      • downloadBinary

        public byte[] downloadBinary​(java.lang.String id)
        Description copied from interface: MongoStorageService
        This method does download data in database.
        Specified by:
        downloadBinary in interface MongoStorageService
        Parameters:
        id - unique id from file in storage
        Returns:
        data as byte list
      • getBinaryStorage

        public com.mongodb.client.gridfs.GridFSBucket getBinaryStorage​(java.lang.String dbName,
                                                                       java.lang.String binaryCollection)
        Description copied from interface: MongoStorageService
        This method does return database system.
        Specified by:
        getBinaryStorage in interface MongoStorageService
        Parameters:
        dbName - database, from which it will be returned
        binaryCollection - collection, from which it will be returned
        Returns:
        database system
      • uploadBinary

        public java.lang.String uploadBinary​(java.util.Map<java.lang.String,​java.lang.Object> metadata,
                                             org.springframework.web.multipart.MultipartFile file)
        Description copied from interface: MongoStorageService
        This method does upload database bean.
        Specified by:
        uploadBinary in interface MongoStorageService
        Parameters:
        metadata - meta information for uploaded document
        file - file data, which will be uploaded
        Returns:
        unique id from uploaded file
      • removeBinary

        public void removeBinary​(java.lang.String dbName,
                                 java.lang.String binStorageName,
                                 java.lang.String json)
        Description copied from interface: MongoStorageService
        This method does remove database binary.
        Specified by:
        removeBinary in 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
      • removeBinary

        public void removeBinary​(java.lang.String id)
        Description copied from interface: MongoStorageService
        This method does remove database binary.
        Specified by:
        removeBinary in interface MongoStorageService
        Parameters:
        id - unique id, which it will be removed