Class KeyService
java.lang.Object
com.eurodyn.qlack.fuse.lexicon.service.KeyService
A Service class for Key that contains the implementations of crud methods .
- Author:
- European Dynamics SA
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionKeyService
(KeyRepository keyRepository, GroupRepository groupRepository, KeyMapper keyMapper, DataRepository dataRepository, LanguageRepository languageRepository, GroupService groupService) -
Method Summary
Modifier and TypeMethodDescriptionCreates a translation Key and it's translations.createKeys
(List<KeyDTO> keys, boolean createDefaultTranslations) Creates a translation for each item of the given list.void
Deletes a key and its values for the lexicon.void
deleteKeys
(Collection<String> keyIds) Deletes multiple Keys.void
deleteKeysByGroupId
(String groupId) Deletes all Keys of a group.findKeys
(KeySearchCriteria criteria, boolean includeTranslations) Finds all keys that match given criteria.findTotalKeys
(KeySearchCriteria criteria) Finds the total number of keys that match given criteria.getKeyById
(String keyId, boolean includeTranslations) Fetches a persisted Key based on its id.getKeyByName
(String keyName, String groupId, boolean includeTranslations) Fetches a persisted Key based on its name and group.getKeysSortedByTranslation
(String groupName, String locale, KeySearchCriteria.SortType sortType) Fetches sorted Keys for given group name and locale.getTranslation
(String keyName, String locale) Fetches a translation based on the Key name and the locale.getTranslationForKeyGroupLocale
(String keyName, String groupName, String locale) Finds the translated value of a key in given group name and localegetTranslationsForGroupAndLocale
(String groupId, String locale) Fetches all translations of given group for given locale.getTranslationsForGroupNameAndLocale
(String groupName, String locale) Fetches all translations of given group and given locale.getTranslationsForGroupNameAndLocaleSorted
(String groupName, String locale, KeySearchCriteria.SortType sortType) Fetches sorted translations for given group name and locale.getTranslationsForKeyName
(String keyName, String groupId) Fetching all translations of a key in a given group.getTranslationsForLocale
(String locale) Fetches all translations for a locale.Fetches all translations from all groups for a specific locale,groupby group title.void
Moves a Key to another group.void
moveKeys
(Collection<String> keyIds, String newGroupId) Moves multiple Keys to a new Group.void
Renames an existing Key.void
updateTranslation
(String keyId, String languageId, String value) Updates a translation based on it's Key and language ids.void
updateTranslationByGroupId
(String keyName, String groupId, String languageId, String value) Updates a translation based on it's key name, language and group ids.void
updateTranslationByKeyName
(String keyName, String groupId, String languageId, String value) Updates a translation based on it's key name and language id.void
updateTranslationByLocale
(String keyId, String locale, String value) Updates a translation based on it's Key id and locale.void
Updates multiple translations based on their key, group and language id.void
updateTranslationsForKey
(String keyId, Map<String, String> translations) Updates multiple translations of a Key.void
updateTranslationsForKeyByLocale
(String keyId, Map<String, String> translations) Updates multiple translations of a Key.void
updateTranslationsForLanguage
(String languageId, Map<String, String> translations) Updates translations of a language by given key ids.void
updateTranslationsForLanguageByKeyName
(String languageId, String groupId, Map<String, String> translations) Updates translations of a language by given key names.
-
Constructor Details
-
KeyService
@Autowired public KeyService(KeyRepository keyRepository, GroupRepository groupRepository, KeyMapper keyMapper, DataRepository dataRepository, LanguageRepository languageRepository, GroupService groupService)
-
-
Method Details
-
createKey
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 KeycreateDefaultTranslations
- a flag defining whether default translations should be created- Returns:
- the id of the created Key
-
createKeys
Creates a translation for each item of the given list.- Parameters:
keys
- a list of DTO, each containing the data of a KeycreateDefaultTranslations
- a flag defining whether default translations should be created- Returns:
- a list containing the ids of the created Keys
-
deleteKey
Deletes a key and its values for the lexicon.- Parameters:
keyId
- the id of the key to be deleted
-
deleteKeys
Deletes multiple Keys.- Parameters:
keyIds
- a collection of Key ids to delete
-
deleteKeysByGroupId
Deletes all Keys of a group.- Parameters:
groupId
- the id of the group
-
renameKey
Renames an existing Key.- Parameters:
keyId
- the id o the Key to renamenewName
- the new name of the Key
-
moveKey
Moves a Key to another group.- Parameters:
keyId
- the id of the Key to movenewGroupId
- the id of the destination group
-
moveKeys
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
Fetches a persisted Key based on its id. Key translations can be included.- Parameters:
keyId
- the id of the persisted KeyincludeTranslations
- a flag to determine if Key translations should be included in the returned DTO- Returns:
- the persisted Key
-
getKeyByName
Fetches a persisted Key based on its name and group. Key translations can be included.- Parameters:
keyName
- the name of the persisted KeygroupId
- the id of the persisted GroupincludeTranslations
- a flag to determine if Key translations should be included in the returned DTO- Returns:
- the persisted Key
-
findKeys
Finds all keys that match given criteria.- Parameters:
criteria
- the criteria used to search the keysincludeTranslations
- flag to determine whether translations should be included in the returned DTO- Returns:
- a list of persisted Keys matching the given criteria
-
findTotalKeys
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
Updates a translation based on it's Key and language ids.- Parameters:
keyId
- the id of the Key that will be updatedlanguageId
- the id of the translation's languagevalue
- the updated value of the translation
-
updateTranslationByLocale
Updates a translation based on it's Key id and locale.- Parameters:
keyId
- the id of the Key that will be updatedlocale
- the locale of the translation's languagevalue
- 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 updatedgroupId
- the id of the group the Key is part oflanguageId
- the id of the translation's languagevalue
- 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 updatedgroupId
- the id of the group the Key is part oflanguageId
- the id of the translations's languagevalue
- the updated value of the translation
-
updateTranslationsByGroupId
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 valuesgroupId
- the id of the group the keys are part oflanguageId
- the id of the translation's id
-
updateTranslationsForKey
Updates multiple translations of a Key.- Parameters:
keyId
- the id of the Key that will be updatedtranslations
- a map containing pairs of languageId/value that will be updated
-
updateTranslationsForKeyByLocale
Updates multiple translations of a Key.- Parameters:
keyId
- the id of the Key that will be updatedtranslations
- a map containing pairs of locale/value that will be updated
-
updateTranslationsForLanguage
Updates translations of a language by given key ids.- Parameters:
languageId
- the id of the language that will be updatedtranslations
- 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 updatedgroupId
- the id of the group that the keys are part oftranslations
- a map containing pairs of translation key names/values that will be updated
-
getTranslation
Fetches a translation based on the Key name and the locale.- Parameters:
keyName
- the name of the key to fetchlocale
- the locale of the translation- Returns:
- the translation of given key in the given locale
-
getTranslationsForKeyName
Fetching all translations of a key in a given group.- Parameters:
keyName
- the name of the translation KeygroupId
- the id of the group that the Key is part of- Returns:
- a map containing pairs of locale/value translations
-
getTranslationForKeyGroupLocale
Finds the translated value of a key in given group name and locale- Parameters:
keyName
- the name of the translation KeygroupName
- the name of the group that the key is part oflocale
- the locale of the translation- Returns:
- the translated value
-
getTranslationsForLocale
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
Fetches all translations of given group for given locale.- Parameters:
groupId
- the id of the grouplocale
- the locale whose translations will be returned- Returns:
- a map containing pairs of key name/locale translations for given group and locale
-
getTranslationsForGroupNameAndLocale
Fetches all translations of given group and given locale.- Parameters:
groupName
- the name of the grouplocale
- 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 oflocale
- the locale of the translationssortType
- the type of sorting (ascending/descending)- Returns:
- a map containing sorted pairs of translation key/value
-
getTranslationsForLocaleGroupByGroupTitle
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 oflocale
- the locale of the translationssortType
- the type of sorting (ascending/descending)- Returns:
- a list containing the translation Keys sorted
-