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
ConstructorDescriptionDefaultOptionTemplateGroupHydrationService
(OptionTemplateService<OptionTemplate> templateService) -
Method Summary
Modifier and TypeMethodDescriptionprotected OptionTemplateGroup
applyHydration
(@NonNull OptionTemplateGroup group, @NonNull Map<String, OptionTemplate> foundTemplatesById) protected void
determineReferencedTemplateIds
(OptionTemplateGroup group, Set<String> templateIds) protected Map<String,
OptionTemplate> findTemplatesAndCollectToMap
(Set<String> templateIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected OptionTemplate
getHydratedOrLog
(OptionTemplate unhydrated, Map<String, OptionTemplate> foundTemplatesById) Returns the fully-populated instance ofunhydrated
if it was found, otherwise logs a warning and returnsunhydrated
as-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:
hydrate
in interfaceOptionTemplateGroupHydrationService
- Parameters:
group
- the unhydratedOptionTemplateGroup
whose references should be hydratedcontextInfo
- 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 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:
hydrate
in 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 ofunhydrated
if it was found, otherwise logs a warning and returnsunhydrated
as-is.- Parameters:
unhydrated
- theOptionTemplate
instance 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
unhydrated
if it was found infoundTemplatesById
, otherwise the givenunhydrated
instance as-is
-
getTemplateService
-