Class StockThresholdPopulator<SOURCE extends ProductModel,TARGET extends StockData>
- java.lang.Object
-
- de.hybris.platform.commercefacades.product.converters.populator.StockPopulator<SOURCE,TARGET>
-
- de.hybris.platform.b2bacceleratorfacades.product.converters.populator.StockThresholdPopulator<SOURCE,TARGET>
-
- All Implemented Interfaces:
Populator<SOURCE,TARGET>
public class StockThresholdPopulator<SOURCE extends ProductModel,TARGET extends StockData> extends StockPopulator<SOURCE,TARGET>
Threshold values are set on categories levels, Stock Threshold Populator populate the value to StockData for a product.
-
-
Constructor Summary
Constructors Constructor Description StockThresholdPopulator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CategoryServicegetCategoryService()protected CMSSiteServicegetCmsSiteService()protected voidgetThresholdfromOneTree(CategoryModel currentCategory, java.util.Set<CategoryModel> processedCategories, java.util.Map<CategoryModel,java.lang.Integer> thresholdOnCategory)The recursive method get the threshold value from a category tree one level up each time, it will exit the recursion when get an value from one level of category and flag all its super categories as processedprotected java.lang.IntegergetThresholdValue(ProductModel productModel)Loop in all the super categories of a product belongs to, if it is a variant product, get all super categories from its base product also, then get the lowest level value from each of the categories tree, then the minimum values from all the categories trees is the threshold will be applied on a product.voidpopulate(SOURCE productModel, TARGET stockData)Populate the target instance with values from the source instance.voidsetCategoryService(CategoryService categoryService)voidsetCmsSiteService(CMSSiteService cmsSiteService)-
Methods inherited from class de.hybris.platform.commercefacades.product.converters.populator.StockPopulator
getBaseStoreService, getCommerceStockService, isStockSystemEnabled, isStockSystemEnabled, setBaseStoreService, setCommerceStockService
-
-
-
-
Method Detail
-
populate
public void populate(SOURCE productModel, TARGET stockData) throws ConversionException
Description copied from interface:PopulatorPopulate the target instance with values from the source instance.- Specified by:
populatein interfacePopulator<SOURCE extends ProductModel,TARGET extends StockData>- Overrides:
populatein classStockPopulator<SOURCE extends ProductModel,TARGET extends StockData>- Parameters:
productModel- the source objectstockData- the target to fill- Throws:
ConversionException- if an error occurs
-
getThresholdValue
protected java.lang.Integer getThresholdValue(ProductModel productModel)
Loop in all the super categories of a product belongs to, if it is a variant product, get all super categories from its base product also, then get the lowest level value from each of the categories tree, then the minimum values from all the categories trees is the threshold will be applied on a product. If no threshold is set on any categories, then apply the default threshold value set at site level.- Parameters:
productModel-- Returns:
- the threshold value to apply on the given product
-
getThresholdfromOneTree
protected void getThresholdfromOneTree(CategoryModel currentCategory, java.util.Set<CategoryModel> processedCategories, java.util.Map<CategoryModel,java.lang.Integer> thresholdOnCategory)
The recursive method get the threshold value from a category tree one level up each time, it will exit the recursion when get an value from one level of category and flag all its super categories as processed- Parameters:
currentCategory-processedCategories-thresholdOnCategory- a map contains the threshold value and the category where it set from
-
getCmsSiteService
protected CMSSiteService getCmsSiteService()
-
setCmsSiteService
public void setCmsSiteService(CMSSiteService cmsSiteService)
-
getCategoryService
protected CategoryService getCategoryService()
-
setCategoryService
public void setCategoryService(CategoryService categoryService)
-
-