Class TranslationServiceImpl

    • Field Detail

      • mongoTemplate

        @Autowired
        private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate
      • appContext

        @Autowired
        private org.springframework.context.ApplicationContext appContext
      • mapper

        private final com.fasterxml.jackson.databind.ObjectMapper mapper
    • Constructor Detail

      • TranslationServiceImpl

        public TranslationServiceImpl()
    • Method Detail

      • init

        @PostConstruct
        public void init()
      • getPaginationFilter

        public java.util.Deque<java.util.Map<java.lang.String,​java.lang.Object>> getPaginationFilter​(java.lang.String requestJson)
        Description copied from interface: TranslationService
        This method does calculation for a pages based on the request.
        Specified by:
        getPaginationFilter in interface TranslationService
        Parameters:
        requestJson - JSON-object of request contains an instructions for search queries
        Returns:
        map-representation of data
      • searchTranslations

        public java.util.LinkedHashSet<LocalizedText> searchTranslations​(java.lang.String requestJson)
        Description copied from interface: TranslationService
        This method does search requests and returns data as list.
        Specified by:
        searchTranslations in interface TranslationService
        Parameters:
        requestJson - search request
        Returns:
        data transport entities as list
      • searchTranslationsPaged

        public org.springframework.data.domain.Page<LocalizedText> searchTranslationsPaged​(java.lang.String requestJson)
        Description copied from interface: TranslationService
        This method does search requests and returns data as pages.
        Specified by:
        searchTranslationsPaged in interface TranslationService
        Parameters:
        requestJson - JSON-object of request contains an instructions for search queries
        Returns:
        database entities separated to pages
      • searchTranslations

        public java.util.List<LocalizedText> searchTranslations​(java.lang.String query,
                                                                java.lang.String offset,
                                                                java.lang.String limit)
        Description copied from interface: TranslationService
        This method does search requests and returns data as list.
        Specified by:
        searchTranslations in interface TranslationService
        Parameters:
        query - search query
        offset - offset for returned items
        limit - limit for returned items
        Returns:
        database entities as list
      • searchTranslationsById

        public java.util.List<LocalizedText> searchTranslationsById​(java.lang.String regex)
        Description copied from interface: TranslationService
        This method does search requests and returns data as list.
        Specified by:
        searchTranslationsById in interface TranslationService
        Parameters:
        regex - regexp for identifier definition
        Returns:
        database entities as list
      • getTranslationsByLangCode

        public java.util.Map<java.lang.String,​java.lang.String> getTranslationsByLangCode​(java.lang.String lang)
        Description copied from interface: TranslationService
        This method returns data as map.
        Specified by:
        getTranslationsByLangCode in interface TranslationService
        Parameters:
        lang - field for filter and return data
        Returns:
        data as map
      • getTranslatedTimeDuration

        public java.util.Map<java.lang.String,​java.lang.String> getTranslatedTimeDuration​(java.lang.String date)
        Description copied from interface: TranslationService
        This method returns data as map.
        Specified by:
        getTranslatedTimeDuration in interface TranslationService
        Parameters:
        date - field for translated
        Returns:
        data as map
      • getTranslationById

        public LocalizedText getTranslationById​(java.lang.String id)
        Description copied from interface: TranslationService
        This method returns data as map.
        Specified by:
        getTranslationById in interface TranslationService
        Parameters:
        id - identification for database entity, which will be revers on map
        Returns:
        data as entity
      • getTranslation

        public java.util.Map<java.lang.String,​java.lang.String> getTranslation​(java.lang.String id,
                                                                                     java.lang.String repositoryName)
        Description copied from interface: TranslationService
        This method returns data as map.
        Specified by:
        getTranslation in interface TranslationService
        Parameters:
        id - identification for database entity, which will be revers on map
        repositoryName - repository name from where will be returned data
        Returns:
        data as map
      • getTranslation

        public java.util.Map<java.lang.String,​java.lang.String> getTranslation​(java.lang.String id,
                                                                                     java.lang.String lang,
                                                                                     java.lang.String repositoryName)
        Description copied from interface: TranslationService
        This method returns data as map.
        Specified by:
        getTranslation in interface TranslationService
        Parameters:
        id - identification for database entity, which will be revers on map
        lang - the language iso-code for translation
        repositoryName - repository name from where will be returned data
        Returns:
        data as map
      • getTranslationValue

        public java.lang.String getTranslationValue​(java.lang.String id,
                                                    java.lang.String repositoryName)
        Description copied from interface: TranslationService
        This method returns translation for entity.
        Specified by:
        getTranslationValue in interface TranslationService
        Parameters:
        id - identification for database entity, which will be revers on map
        repositoryName - repository name from where will be returned data
        Returns:
        translation
      • getTranslationValue

        public java.lang.String getTranslationValue​(java.lang.String id,
                                                    java.lang.String lang,
                                                    java.lang.String repositoryName)
        Description copied from interface: TranslationService
        This method returns translation for entity.
        Specified by:
        getTranslationValue in interface TranslationService
        Parameters:
        id - identification for database entity, which will be revers on map
        lang - the language iso-code for translation
        repositoryName - repository name from where will be returned data
        Returns:
        translation value
      • searchLanguages

        public java.util.List<Language> searchLanguages​(java.lang.String query,
                                                        java.lang.String offset,
                                                        java.lang.String limit)
        Description copied from interface: TranslationService
        This method does search requests and returns data as list.
        Specified by:
        searchLanguages in interface TranslationService
        Parameters:
        query - search query
        offset - offset for returned items
        limit - limit for returned items
        Returns:
        database entities as list
      • createTranslation

        @Transactional
        public java.util.Optional<LocalizedText> createTranslation​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> translationAsMap)
        Description copied from interface: TranslationService
        This method creates a database entity.
        Specified by:
        createTranslation in interface TranslationService
        Parameters:
        translationAsMap - map-representation of database entity
        Returns:
        optional value to externally interaction
      • createLanguage

        @Transactional
        public java.util.Optional<Language> createLanguage​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> langAsMap)
        Description copied from interface: TranslationService
        This method creates a database entity.
        Specified by:
        createLanguage in interface TranslationService
        Parameters:
        langAsMap - map-representation of database entity
        Returns:
        optional value to externally interaction
      • saveTranslation

        @Transactional
        public java.util.Optional<LocalizedText> saveTranslation​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> translationAsMap)
        Description copied from interface: TranslationService
        This method save an updates of database entity.
        Specified by:
        saveTranslation in interface TranslationService
        Parameters:
        translationAsMap - map-representation of database entity
        Returns:
        optional value to externally interaction
      • saveArticle

        @Transactional
        public java.util.Optional<LocalizedText> saveArticle​(java.lang.String text,
                                                             java.lang.String articleId)
        Description copied from interface: TranslationService
        This method saves a database entity.
        Specified by:
        saveArticle in interface TranslationService
        Parameters:
        text - data which will be added in database entity
        articleId - identification for database entity which will be saved or updated
        Returns:
        optional value to externally interaction
      • saveLanguage

        @Transactional
        public java.util.Optional<Language> saveLanguage​(java.util.LinkedHashMap<java.lang.String,​java.lang.Object> langAsMap)
        Description copied from interface: TranslationService
        This method save an updates of database entity.
        Specified by:
        saveLanguage in interface TranslationService
        Parameters:
        langAsMap - map-representation of database entity
        Returns:
        optional value to externally interaction
      • saveLanguage

        public java.util.Optional<Language> saveLanguage​(Language language)
        Description copied from interface: TranslationService
        This method saves a database entity.
        Specified by:
        saveLanguage in interface TranslationService
        Parameters:
        language - database entity
        Returns:
        optional value to externally interaction
      • removeTranslationAndClean

        @Transactional
        @CacheEvict("translations")
        public void removeTranslationAndClean​(java.lang.String translationId)
        Description copied from interface: TranslationService
        This method removes a database entity and clean all relationships from another entities.
        Specified by:
        removeTranslationAndClean in interface TranslationService
        Parameters:
        translationId - identification for database entity which will be removed
      • removeTranslationsByIds

        @Transactional
        public void removeTranslationsByIds​(java.util.ArrayList<java.lang.String> translationIds)
        Description copied from interface: TranslationService
        This method removes a list of database entities.
        Specified by:
        removeTranslationsByIds in interface TranslationService
        Parameters:
        translationIds - the list of database entities which will be removed
      • removeTranslationsByLanguage

        public void removeTranslationsByLanguage​(java.lang.String langId)
        Description copied from interface: TranslationService
        This method removes a list of database entities.
        Specified by:
        removeTranslationsByLanguage in interface TranslationService
        Parameters:
        langId - language identification
      • removeLanguageAndClean

        @Transactional
        public void removeLanguageAndClean​(java.lang.String langId)
        Description copied from interface: TranslationService
        This method removes a database entity and clean all relationships from another entities.
        Specified by:
        removeLanguageAndClean in interface TranslationService
        Parameters:
        langId - identification for database entity which will be removed
      • removeLanguagesByIds

        @Transactional
        public void removeLanguagesByIds​(java.util.ArrayList<java.lang.String> languageIds)
        Description copied from interface: TranslationService
        This method removes a list of database entities.
        Specified by:
        removeLanguagesByIds in interface TranslationService
        Parameters:
        languageIds - the list of database entities which will be removed
      • getTranslations

        @Transactional
        public java.util.HashSet<LocalizedText> getTranslations​(java.lang.String langEn,
                                                                java.lang.String langDe)
        Description copied from interface: TranslationService
        This method returns data as set.
        Specified by:
        getTranslations in interface TranslationService
        Parameters:
        langEn - the lang of database entities which will be retrieved
        langDe - the lang of database entities which will be retrieved
        Returns:
        database entities as list
      • addTranslation

        @Transactional
        public void addTranslation​(java.lang.String lang,
                                   java.util.HashSet<LocalizedText> translations,
                                   java.util.Optional<Language> languageOptional)
        Description copied from interface: TranslationService
        This method creates all relationships between database entities.
        Specified by:
        addTranslation in interface TranslationService
        Parameters:
        lang - the lang of database entities which will be updated
        translations - the list of database entities where will be added other database entity
        languageOptional - the lang of database entities which will be added in list of other database entities
      • getAlphabetForActiveLanguage

        public java.util.List<java.util.Map<java.lang.String,​java.lang.Object>> getAlphabetForActiveLanguage​(java.lang.String isUpp)
        Description copied from interface: TranslationService
        Return alphabets of active language code
        Specified by:
        getAlphabetForActiveLanguage in interface TranslationService
        Parameters:
        isUpp - flag to convert alphabet to uppercase
        Returns:
        list with characters
      • prepareRelationsForTranslation

        private void prepareRelationsForTranslation​(LocalizedText translationUI)
      • removeRelationsForTranslation

        private void removeRelationsForTranslation​(LocalizedText translationUI,
                                                   LocalizedText translationDB)
      • addRelationsForTranslation

        private void addRelationsForTranslation​(LocalizedText translationUI)