Class ProductBaseCharacteristicTranslationPostMapperMember

java.lang.Object
com.broadleafcommerce.catalog.mapping.ProductBaseCharacteristicTranslationPostMapperMember
All Implemented Interfaces:
com.broadleafcommerce.common.extension.data.DataRoutePartitionAware, com.broadleafcommerce.data.tracking.core.mapping.PostMapper, com.broadleafcommerce.data.tracking.core.mapping.PostMapperMember, org.springframework.core.Ordered

public class ProductBaseCharacteristicTranslationPostMapperMember extends Object implements com.broadleafcommerce.data.tracking.core.mapping.PostMapperMember
A PostMapperMember that is intended to run BEFORE TranslationPostMapperMember. See getOrder(). This component will handle adding translations for any ProductCharacteristic.getValue() where the ProductCharacteristicValue.getSourceCharacteristicValueId() is present. The expectation is that this runs in an early pass to pre-set anything from the base translations, and then the normal TranslationPostMapperMember will be able to run on top of this to apply any translations from the specific ProductCharacteristic/ ProductCharacteristicValue defined at the override level. This ensures the overrides always win, but also ensures the base translations do come through if there are no overrides
Since:
Catalog Service 2.2.0, Release Train 2.2.0
  • Constructor Details

    • ProductBaseCharacteristicTranslationPostMapperMember

      public ProductBaseCharacteristicTranslationPostMapperMember(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.translation.mapping.ContextLocaleHelper contextLocaleHelper)
  • Method Details

    • getDataRoutePartition

      public String getDataRoutePartition()
      Specified by:
      getDataRoutePartition in interface com.broadleafcommerce.common.extension.data.DataRoutePartitionAware
    • getOrder

      public int getOrder()
      This component is intended to run BEFORE TranslationPostMapperMember
      Specified by:
      getOrder in interface org.springframework.core.Ordered
      Specified by:
      getOrder in interface com.broadleafcommerce.data.tracking.core.mapping.PostMapperMember
      Returns:
      a higher precedence than TranslationPostMapperMember
    • transform

      public <P, D> void transform(@NonNull @NonNull List<P> projections, @Nullable List<D> entities, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Default any on with any translations that are defined on the associated CharacteristicValue if there is ProductCharacteristicValue.getSourceCharacteristicValueId() present. If any translations are found for the given locale on the source characteristic value, then it will set that as a base, with the expectation that the TranslationPostMapperMember can override the value if there is a translation specifically associated with the ProductCharacteristicValue
      Specified by:
      transform in interface com.broadleafcommerce.data.tracking.core.mapping.PostMapper
      Parameters:
      projections - - list of business domain classes
      entities - - list of repository domain classes
      contextInfo - - the context
    • buildCharacteristicIdToValueIdsMap

      protected <P> Map<String,List<String>> buildCharacteristicIdToValueIdsMap(@NonNull @NonNull List<P> projections)
    • applyCharacteristicValueTranslations

      protected <P> void applyCharacteristicValueTranslations(@NonNull @NonNull List<P> projections, Map<String,List<org.apache.commons.lang3.tuple.Pair<String,com.broadleafcommerce.translation.domain.Translation>>> matchedTranslations, Locale locale)
    • getCharacteristicTranslations

      protected List<com.broadleafcommerce.translation.domain.Translation> getCharacteristicTranslations(List<String> sourceCharacteristicIds, List<Locale> locales, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getBehaviorUtil

      protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil getBehaviorUtil()
    • getContextLocaleHelper

      protected com.broadleafcommerce.translation.mapping.ContextLocaleHelper getContextLocaleHelper()
    • getTranslationService

      protected com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> getTranslationService()
    • setTranslationService

      @Autowired @Lazy public void setTranslationService(com.broadleafcommerce.translation.service.TranslationEntityService<com.broadleafcommerce.translation.domain.Translation> translationService)
    • getCharacteristicService

      protected CharacteristicService<Characteristic> getCharacteristicService()
    • setCharacteristicService

      @Autowired @Lazy public void setCharacteristicService(CharacteristicService<Characteristic> characteristicService)