Class KeyService

java.lang.Object
com.eurodyn.qlack.fuse.lexicon.service.KeyService

@Service @Validated public class KeyService extends Object
A Service class for Key that contains the implementations of crud methods .
Author:
European Dynamics SA
  • Constructor Details

  • Method Details

    • createKey

      public String createKey(KeyDTO key, boolean createDefaultTranslations)
      Creates a translation Key and it's translations. Translations are created if they are provided, or if default creation is wanted.
      Parameters:
      key - a DTO containing the data of the Key
      createDefaultTranslations - a flag defining whether default translations should be created
      Returns:
      the id of the created Key
    • createKeys

      public List<String> createKeys(List<KeyDTO> keys, boolean createDefaultTranslations)
      Creates a translation for each item of the given list.
      Parameters:
      keys - a list of DTO, each containing the data of a Key
      createDefaultTranslations - a flag defining whether default translations should be created
      Returns:
      a list containing the ids of the created Keys
    • deleteKey

      public void deleteKey(String keyId)
      Deletes a key and its values for the lexicon.
      Parameters:
      keyId - the id of the key to be deleted
    • deleteKeys

      public void deleteKeys(Collection<String> keyIds)
      Deletes multiple Keys.
      Parameters:
      keyIds - a collection of Key ids to delete
    • deleteKeysByGroupId

      public void deleteKeysByGroupId(String groupId)
      Deletes all Keys of a group.
      Parameters:
      groupId - the id of the group
    • renameKey

      public void renameKey(String keyId, String newName)
      Renames an existing Key.
      Parameters:
      keyId - the id o the Key to rename
      newName - the new name of the Key
    • moveKey

      public void moveKey(String keyId, String newGroupId)
      Moves a Key to another group.
      Parameters:
      keyId - the id of the Key to move
      newGroupId - the id of the destination group
    • moveKeys

      public void moveKeys(Collection<String> keyIds, String newGroupId)
      Moves multiple Keys to a new Group.
      Parameters:
      keyIds - a Collection containing the ids of the keys to be moved.
      newGroupId - the id of group which will inherit the keys
    • getKeyById

      public KeyDTO getKeyById(String keyId, boolean includeTranslations)
      Fetches a persisted Key based on its id. Key translations can be included.
      Parameters:
      keyId - the id of the persisted Key
      includeTranslations - a flag to determine if Key translations should be included in the returned DTO
      Returns:
      the persisted Key
    • getKeyByName

      public KeyDTO getKeyByName(String keyName, String groupId, boolean includeTranslations)
      Fetches a persisted Key based on its name and group. Key translations can be included.
      Parameters:
      keyName - the name of the persisted Key
      groupId - the id of the persisted Group
      includeTranslations - a flag to determine if Key translations should be included in the returned DTO
      Returns:
      the persisted Key
    • findKeys

      public List<KeyDTO> findKeys(KeySearchCriteria criteria, boolean includeTranslations)
      Finds all keys that match given criteria.
      Parameters:
      criteria - the criteria used to search the keys
      includeTranslations - flag to determine whether translations should be included in the returned DTO
      Returns:
      a list of persisted Keys matching the given criteria
    • findTotalKeys

      public Long findTotalKeys(KeySearchCriteria criteria)
      Finds the total number of keys that match given criteria.
      Parameters:
      criteria - the criteria used to search the keys
      Returns:
      a Long type of the total number of Keys matching the given criteria
    • updateTranslation

      public void updateTranslation(String keyId, String languageId, String value)
      Updates a translation based on it's Key and language ids.
      Parameters:
      keyId - the id of the Key that will be updated
      languageId - the id of the translation's language
      value - the updated value of the translation
    • updateTranslationByLocale

      public void updateTranslationByLocale(String keyId, String locale, String value)
      Updates a translation based on it's Key id and locale.
      Parameters:
      keyId - the id of the Key that will be updated
      locale - the locale of the translation's language
      value - the updated value of the translation
    • updateTranslationByGroupId

      public void updateTranslationByGroupId(String keyName, String groupId, String languageId, String value)
      Updates a translation based on it's key name, language and group ids.
      Parameters:
      keyName - the name of the Key that will be updated
      groupId - the id of the group the Key is part of
      languageId - the id of the translation's language
      value - the updated value of the translation
    • updateTranslationByKeyName

      public void updateTranslationByKeyName(String keyName, String groupId, String languageId, String value)
      Updates a translation based on it's key name and language id.
      Parameters:
      keyName - the name of the Key that will be updated
      groupId - the id of the group the Key is part of
      languageId - the id of the translations's language
      value - the updated value of the translation
    • updateTranslationsByGroupId

      public void updateTranslationsByGroupId(Map<String,String> keys, String groupId, String languageId)
      Updates multiple translations based on their key, group and language id.
      Parameters:
      keys - a map containing the keys that will be updated and the new values
      groupId - the id of the group the keys are part of
      languageId - the id of the translation's id
    • updateTranslationsForKey

      public void updateTranslationsForKey(String keyId, Map<String,String> translations)
      Updates multiple translations of a Key.
      Parameters:
      keyId - the id of the Key that will be updated
      translations - a map containing pairs of languageId/value that will be updated
    • updateTranslationsForKeyByLocale

      public void updateTranslationsForKeyByLocale(String keyId, Map<String,String> translations)
      Updates multiple translations of a Key.
      Parameters:
      keyId - the id of the Key that will be updated
      translations - a map containing pairs of locale/value that will be updated
    • updateTranslationsForLanguage

      public void updateTranslationsForLanguage(String languageId, Map<String,String> translations)
      Updates translations of a language by given key ids.
      Parameters:
      languageId - the id of the language that will be updated
      translations - a map containing pairs of translation key id /value that will be updated
    • updateTranslationsForLanguageByKeyName

      public void updateTranslationsForLanguageByKeyName(String languageId, String groupId, Map<String,String> translations)
      Updates translations of a language by given key names.
      Parameters:
      languageId - the id of the language that will be updated
      groupId - the id of the group that the keys are part of
      translations - a map containing pairs of translation key names/values that will be updated
    • getTranslation

      public String getTranslation(String keyName, String locale)
      Fetches a translation based on the Key name and the locale.
      Parameters:
      keyName - the name of the key to fetch
      locale - the locale of the translation
      Returns:
      the translation of given key in the given locale
    • getTranslationsForKeyName

      public Map<String,String> getTranslationsForKeyName(String keyName, String groupId)
      Fetching all translations of a key in a given group.
      Parameters:
      keyName - the name of the translation Key
      groupId - the id of the group that the Key is part of
      Returns:
      a map containing pairs of locale/value translations
    • getTranslationForKeyGroupLocale

      public String getTranslationForKeyGroupLocale(String keyName, String groupName, String locale)
      Finds the translated value of a key in given group name and locale
      Parameters:
      keyName - the name of the translation Key
      groupName - the name of the group that the key is part of
      locale - the locale of the translation
      Returns:
      the translated value
    • getTranslationsForLocale

      public Map<String,String> getTranslationsForLocale(String locale)
      Fetches all translations for a locale.
      Parameters:
      locale - the locale whose translations will be returned
      Returns:
      a map containing pairs of key name/locale translations for the given locale
    • getTranslationsForGroupAndLocale

      public Map<String,String> getTranslationsForGroupAndLocale(String groupId, String locale)
      Fetches all translations of given group for given locale.
      Parameters:
      groupId - the id of the group
      locale - the locale whose translations will be returned
      Returns:
      a map containing pairs of key name/locale translations for given group and locale
    • getTranslationsForGroupNameAndLocale

      public Map<String,String> getTranslationsForGroupNameAndLocale(String groupName, String locale)
      Fetches all translations of given group and given locale.
      Parameters:
      groupName - the name of the group
      locale - the locale whose translations will be returned
      Returns:
      a map containing pairs of key name/locale translations for given group and locale
    • getTranslationsForGroupNameAndLocaleSorted

      public Map<String,String> getTranslationsForGroupNameAndLocaleSorted(String groupName, String locale, KeySearchCriteria.SortType sortType)
      Fetches sorted translations for given group name and locale.
      Parameters:
      groupName - the name of the group the translations are part of
      locale - the locale of the translations
      sortType - the type of sorting (ascending/descending)
      Returns:
      a map containing sorted pairs of translation key/value
    • getTranslationsForLocaleGroupByGroupTitle

      public Map<String,Map<String,String>> getTranslationsForLocaleGroupByGroupTitle(String locale)
      Fetches all translations from all groups for a specific locale,groupby group title.
      Parameters:
      locale - the language locale
      Returns:
      a list of translations from all groups for a specific locale
    • getKeysSortedByTranslation

      public List<String> getKeysSortedByTranslation(String groupName, String locale, KeySearchCriteria.SortType sortType)
      Fetches sorted Keys for given group name and locale.
      Parameters:
      groupName - the name of the group that the Keys are part of
      locale - the locale of the translations
      sortType - the type of sorting (ascending/descending)
      Returns:
      a list containing the translation Keys sorted