Interface TranslationEntityService<P extends Translation>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
- All Known Implementing Classes:
DefaultTranslationEntityService
- Author:
- Nathan Moore (nathandmoore), Samarth Dhruva (samarthd), Phillip Verheyden (phillipuniverse)
-
Method Summary
Modifier and TypeMethodDescriptionbulkReplaceTranslationsForEntityInLocale(String entityType, Object entity, String entityId, Locale locale, List<P> fieldTranslations, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates/updates/deletesTranslationrecords for the givenentityType/entityId/localecombination using the givenfieldTranslationslist of translations.bulkReplaceTranslationsForEntityInLocale(String entityType, String entityId, Locale locale, List<P> fieldTranslations, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.longcountNonProductionRecordsByEntityInTenant(String entityType, String entityId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the given entity info and the given tenant context.findAllByEntities(String entityType, List<String> entityIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.findAllByEntitiesAndLocales(String entityType, List<String> entities, List<Locale> locales, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for multiple entities.findAllByEntity(String entityType, String entityId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.findAllByEntityAndLocale(String entityType, String entityId, Locale locale, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.findByFieldAndLocale(String entityType, String entityId, String entityField, Locale locale, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translation for the given entity field.org.springframework.data.domain.Page<P>findPageByEntityAndLocale(String entityType, String entityId, Locale locale, org.springframework.data.domain.Pageable pageInfo, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Method Details
-
findPageByEntityAndLocale
org.springframework.data.domain.Page<P> findPageByEntityAndLocale(String entityType, String entityId, Locale locale, @Nullable org.springframework.data.domain.Pageable pageInfo, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- The context ID of the entity.locale- The translation's locale.pageInfo-Pagingation inforegarding the current page of data to retrieve.context-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translations for the given entity.
-
findAllByEntityAndLocale
List<P> findAllByEntityAndLocale(String entityType, String entityId, Locale locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- The context ID of the entity.locale- The translation's locale.context-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translations for the given entity.
-
findAllByEntitiesAndLocales
List<P> findAllByEntitiesAndLocales(String entityType, List<String> entities, List<Locale> locales, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for multiple entities.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entities- The context IDs of multiple entities to check.locales- The translation's locale(s).context-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translations for the requested entities.
-
findByFieldAndLocale
P findByFieldAndLocale(String entityType, String entityId, String entityField, Locale locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translation for the given entity field.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- The context ID of the entity.entityField- The name of the field on the entity to which the translation applies.locale- The translation's locale.context-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translation for the given entity field.
-
findAllByEntity
List<P> findAllByEntity(String entityType, String entityId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- The context ID of the entity.context-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translations for the given entity.
-
countNonProductionRecordsByEntityInTenant
long countNonProductionRecordsByEntityInTenant(String entityType, String entityId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the given entity info and the given tenant context.This is useful to determine if there are outstanding sandbox changes before an entity can be deleted. For example, this is used for checking if any outstanding sandbox changes exist for Product translations before the Product can be deleted.
- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- The context ID of the entity.context-context informationrelated to multitenancy.- Returns:
- the count of non-production records that match the given entity info and the given tenant context.
-
findAllByEntities
List<P> findAllByEntities(String entityType, List<String> entityIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds the translations for the given entity info.- Parameters:
entityType- The type of the entity such as PRODUCT, CATEGORY, or OFFER.entityIds- The context IDs of the entitiescontext-context informationrelated to multitenancy. Often used to validate visibility and mutability of persistence operations for a catalog.- Returns:
- the translations for the given entities
-
bulkReplaceTranslationsForEntityInLocale
@Deprecated List<P> bulkReplaceTranslationsForEntityInLocale(String entityType, String entityId, Locale locale, List<P> fieldTranslations, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Deprecated.UsebulkReplaceTranslationsForEntityInLocale(String, Object, String, Locale, List, ContextInfo)instead to include better coverage for embedded collection translations.Creates/updates/deletesTranslationrecords for the givenentityType/entityId/localecombination using the givenfieldTranslationslist of translations.The result of this operation should be that the only
Translationrecords for the givenentityType/entityId/localecombination should be those supplied in thefieldTranslationslist. There will be exactly oneTranslationrecord for eachTranslationin thefieldTranslationslist.This means that:
- If a field translation in the given
fieldTranslationsis not already present in the data store, a newTranslationrecord will be created for it - If a field in the given
fieldTranslationsalready has a translation in the data store, the existingTranslationrecord is updated to have the new translation value - If there is a
Translationrecord in the data store (for theentityType/entityId/localecombination) that is not found in the givenfieldTranslationslist, the record is deleted
Note, if the entity whose fields and subordinate objects are being translated contains embedded collections that are translatable, thenbulkReplaceTranslationsForEntityInLocale(String, Object, String, Locale, List, ContextInfo)is more appropriate for that case.- Parameters:
entityType- the type of the entity such as PRODUCT, CATEGORY, or OFFER.entityId- the context ID of the entity.locale- the locale for which this operation should be performedfieldTranslations- a list ofTranslations, with only theirTranslation.entityFieldandTranslation.valueproperties populated. Both of those properties must be supplied for eachTranslationin the list. All other properties of the translations are ignored, as they will be automatically overridden by the other arguments provided to this method.contextInfo- the context surrounding sandboxing and multitenant state- Returns:
- the new list of all translations for the given
entityType/entityId/localecombination after performing the necessary updates - Throws:
InvalidTranslationRequestException- if the suppliedfieldTranslationslist was null, or any of the translations did not have theirTranslation.entityFieldandTranslation.valuesupplied
- If a field translation in the given
-
bulkReplaceTranslationsForEntityInLocale
List<P> bulkReplaceTranslationsForEntityInLocale(String entityType, Object entity, String entityId, Locale locale, List<P> fieldTranslations, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates/updates/deletesTranslationrecords for the givenentityType/entityId/localecombination using the givenfieldTranslationslist of translations.The result of this operation should be that the only
Translationrecords for the givenentityType/entityId/localecombination should be those supplied in thefieldTranslationslist. There will be exactly oneTranslationrecord for eachTranslationin thefieldTranslationslist.This means that:
- If a field translation in the given
fieldTranslationsis not already present in the data store, a newTranslationrecord will be created for it - If a field in the given
fieldTranslationsalready has a translation in the data store, the existingTranslationrecord is updated to have the new translation value - If there is a
Translationrecord in the data store (for theentityType/entityId/localecombination) that is not found in the givenfieldTranslationslist, the record is deleted
This version differs frombulkReplaceTranslationsForEntityInLocale(String, String, Locale, List, ContextInfo)in that this version will inspect embedded collections (if applicable) whose members implementSubIdentifiableand are translatable. It will setup the persisted field path for the translation to include the identifier (rather than rely on position alone). This facilitates accurate translation matching for embedded collection members, regardless of collection member ordering mutation.- Parameters:
entityType- the type of the entity such as PRODUCT, CATEGORY, or OFFER.entity- the projection instance of the entity.entityId- the context ID of the entity.locale- the locale for which this operation should be performedfieldTranslations- a list ofTranslations, with only theirTranslation.entityFieldandTranslation.valueproperties populated. Both of those properties must be supplied for eachTranslationin the list. All other properties of the translations are ignored, as they will be automatically overridden by the other arguments provided to this method.contextInfo- the context surrounding sandboxing and multitenant state- Returns:
- the new list of all translations for the given
entityType/entityId/localecombination after performing the necessary updates - Throws:
InvalidTranslationRequestException- if the suppliedfieldTranslationslist was null, or any of the translations did not have theirTranslation.entityFieldandTranslation.valuesupplied
- If a field translation in the given
-
bulkReplaceTranslationsForEntityInLocale(String, Object, String, Locale, List, ContextInfo)instead to include better coverage for embedded collection translations.