Class DefaultOptionTemplateGroupHydrationService

java.lang.Object
com.broadleafcommerce.catalog.service.option.DefaultOptionTemplateGroupHydrationService
All Implemented Interfaces:
OptionTemplateGroupHydrationService

public class DefaultOptionTemplateGroupHydrationService extends Object implements OptionTemplateGroupHydrationService
Author:
Samarth Dhruva (samarthd)
  • Constructor Details

  • Method Details

    • hydrate

      public OptionTemplateGroup hydrate(OptionTemplateGroup group, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Gets the IDs of items that are referenced by the group, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.
      Specified by:
      hydrate in interface OptionTemplateGroupHydrationService
      Parameters:
      group - the unhydrated OptionTemplateGroup whose references should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the given group after hydrating its references
    • hydrate

      public org.springframework.data.domain.Page<OptionTemplateGroup> hydrate(org.springframework.data.domain.Page<OptionTemplateGroup> unhydrated, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Gets the IDs of items that are referenced by each group in unhydrated, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.

      A page of those hydrated option template groups is returned.

      Specified by:
      hydrate in interface OptionTemplateGroupHydrationService
      Parameters:
      unhydrated - the page of unhydrated option template groups whose references should be hydrated
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a page of the option template groups after hydrating their references
    • determineReferencedTemplateIds

      protected void determineReferencedTemplateIds(OptionTemplateGroup group, Set<String> templateIds)
    • findTemplatesAndCollectToMap

      protected Map<String,OptionTemplate> findTemplatesAndCollectToMap(Set<String> templateIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • applyHydration

      protected OptionTemplateGroup applyHydration(@NonNull @NonNull OptionTemplateGroup group, @NonNull @NonNull Map<String,OptionTemplate> foundTemplatesById)
    • getHydratedOrLog

      protected OptionTemplate getHydratedOrLog(OptionTemplate unhydrated, Map<String,OptionTemplate> foundTemplatesById)
      Returns the fully-populated instance of unhydrated if it was found, otherwise logs a warning and returns unhydrated as-is.
      Parameters:
      unhydrated - the OptionTemplate instance containing just an ID for which a fully-populated replacement instance should be found
      foundTemplatesById - a map of templates found in the datastore by their ID. This map will be used to source the replacement instance for unhydrated.
      Returns:
      the fully-populated version of unhydrated if it was found in foundTemplatesById, otherwise the given unhydrated instance as-is
    • getTemplateService

      protected OptionTemplateService<OptionTemplate> getTemplateService()