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 Summary
ConstructorsConstructorDescriptionDefaultOptionTemplateGroupHydrationService(OptionTemplateService<OptionTemplate> templateService) -
Method Summary
Modifier and TypeMethodDescriptionprotected OptionTemplateGroupapplyHydration(@NonNull OptionTemplateGroup group, @NonNull Map<String, OptionTemplate> foundTemplatesById) protected voiddetermineReferencedTemplateIds(OptionTemplateGroup group, Set<String> templateIds) protected Map<String,OptionTemplate> findTemplatesAndCollectToMap(Set<String> templateIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected OptionTemplategetHydratedOrLog(OptionTemplate unhydrated, Map<String, OptionTemplate> foundTemplatesById) Returns the fully-populated instance ofunhydratedif it was found, otherwise logs a warning and returnsunhydratedas-is.protected OptionTemplateService<OptionTemplate>hydrate(OptionTemplateGroup group, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the IDs of items that are referenced by thegroup, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.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 inunhydrated, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.
-
Constructor Details
-
DefaultOptionTemplateGroupHydrationService
public DefaultOptionTemplateGroupHydrationService(OptionTemplateService<OptionTemplate> templateService)
-
-
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 thegroup, finds the corresponding items in the data store, and then replaces each reference with the fully populated representation of the item.- Specified by:
hydratein interfaceOptionTemplateGroupHydrationService- Parameters:
group- the unhydratedOptionTemplateGroupwhose references should be hydratedcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- the given
groupafter 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 inunhydrated, 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:
hydratein interfaceOptionTemplateGroupHydrationService- Parameters:
unhydrated- the page of unhydrated option template groups whose references should be hydratedcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a page of the option template groups after hydrating their references
-
determineReferencedTemplateIds
-
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 ofunhydratedif it was found, otherwise logs a warning and returnsunhydratedas-is.- Parameters:
unhydrated- theOptionTemplateinstance containing just an ID for which a fully-populated replacement instance should be foundfoundTemplatesById- a map of templates found in the datastore by their ID. This map will be used to source the replacement instance forunhydrated.- Returns:
- the fully-populated version of
unhydratedif it was found infoundTemplatesById, otherwise the givenunhydratedinstance as-is
-
getTemplateService
-