Package de.hybris.platform.stock.impl
Class DefaultStockService
- java.lang.Object
-
- de.hybris.platform.stock.impl.DefaultStockService
-
- All Implemented Interfaces:
StockService
public class DefaultStockService extends java.lang.Object implements StockService
Default implementation ofStockService.
-
-
Field Summary
-
Fields inherited from interface de.hybris.platform.stock.StockService
BEAN_NAME
-
-
Constructor Summary
Constructors Constructor Description DefaultStockService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StockLevelModelcreateStockLevel(ProductModel product, WarehouseModel warehouse, int available)Creates a new stock level.protected StockLevelModelcreateStockLevel(ProductModel product, WarehouseModel warehouse, int available, int overSelling, int reserved, InStockStatus status, int maxStockLevelHistoryCount, boolean treatNegativeAsZero)Creates a new stock level.protected StockLevelHistoryEntryModelcreateStockLevelHistoryEntry(StockLevelModel stockLevel, int actual, int reserved, StockLevelUpdateType updateType, java.lang.String comment)Creates a new stock level history entry.java.util.Collection<StockLevelModel>getAllStockLevels(ProductModel product)Finds the stock levels of the specified product from all warehouses.java.lang.StringgetAvailability(ProductModel product, WarehouseModel warehouse, int quantity, LanguageModel language)Gets availability date by invoking strategy for calculating product availability, passing product, quantity and warehouse as parameters.java.lang.StringgetAvailability(ProductModel product, WarehouseModel warehouse, java.util.Date date, LanguageModel language)Gets the available quantity of the product for the specified warehouse.java.lang.StringgetAvailability(ProductModel product, java.util.List<WarehouseModel> warehouses, int quantity, LanguageModel language)Gets availability date by invoking strategy for calculating product availability, passing product, quantity and warehouses as parameters by invoking injected strategy.java.lang.StringgetAvailability(ProductModel product, java.util.List<WarehouseModel> warehouses, java.util.Date date, LanguageModel language)Gets the available quantity of the product for the specified warehouses by invoking injected strategy.java.util.Map<WarehouseModel,java.util.Date>getAvailability(java.util.List<WarehouseModel> warehouses, ProductModel product, int quantity)Returns product availability, passing product, and quantity as parametersjava.util.Map<WarehouseModel,java.lang.Integer>getAvailability(java.util.List<WarehouseModel> warehouses, ProductModel product, java.util.Date date)Gets the product quantity for the specified product, warehouses and date.WarehouseModelgetBestMatchOfAvailability(java.util.Map<WarehouseModel,java.util.Date> map)Returns the warehouse which offers the "best" product "availability" by invoking injected strategy.
Configuration:WarehouseModelgetBestMatchOfQuantity(java.util.Map<WarehouseModel,java.lang.Integer> map)Returns the warehouse which offers the "best" product "quantity" by invoking injected strategy.
Configuration:InStockStatusgetInStockStatus(ProductModel product, WarehouseModel warehouse)Checks the stock level status of the product in the specified warehouses.protected ModelServicegetModelService()protected ProductAvailabilityStrategygetProductAvailabilityStrategy()StockLevelStatusgetProductStatus(ProductModel product, WarehouseModel warehouse)Checks the stock level status of the product in the specified warehouse.StockLevelStatusgetProductStatus(ProductModel product, java.util.Collection<WarehouseModel> warehouses)Checks the stock level status of the product in all specified warehouses.StockLevelModelgetStockLevel(ProductModel product, WarehouseModel warehouse)Finds the stock level of the specified product at the specified warehouse.intgetStockLevelAmount(ProductModel product, WarehouseModel warehouse)Finds the stock level of the specified product in the specified warehouse, and calculates the actual available amount.protected StockLevelDaogetStockLevelDao()protected StockLevelProductStrategygetStockLevelProductStrategy()java.util.Collection<StockLevelModel>getStockLevels(ProductModel product, java.util.Collection<WarehouseModel> warehouses)Finds all stock levels of the specified product in the specified warehouses.protected StockLevelStatusStrategygetStockLevelStatusStrategy()intgetTotalStockLevelAmount(ProductModel product)Finds the stock levels of the specified product from all warehouses, and calculates the total actual amount.intgetTotalStockLevelAmount(ProductModel product, java.util.Collection<WarehouseModel> warehouses)Finds all stock levels of the specified product in the specified warehouses, and calculates the total actual amount.voidrelease(ProductModel product, WarehouseModel warehouse, int amount, java.lang.String comment)Release the product in the specified warehouse.voidreserve(ProductModel product, WarehouseModel warehouse, int amount, java.lang.String comment)Reserves the product in the specified warehouse.voidsetInStockStatus(ProductModel product, java.util.Collection<WarehouseModel> warehouses, InStockStatus status)Sets the in stock status of all stock levels of the product in the specified warehouses.voidsetModelService(ModelService modelService)voidsetProductAvailabilityStrategy(ProductAvailabilityStrategy productAvailabilityStrategy)The injected strategy will be used for calculating the availability of the specified product.voidsetStockLevelDao(StockLevelDao stockLevelDao)voidsetStockLevelProductStrategy(StockLevelProductStrategy stockLevelProductStrategy)voidsetStockLevelStatusStrategy(StockLevelStatusStrategy stockLevelStatusStrategy)voidupdateActualStockLevel(ProductModel product, WarehouseModel warehouse, int actualAmount, java.lang.String comment)Updates the actual stock level of the specified product in the specified warehouse.
-
-
-
Method Detail
-
getProductStatus
public StockLevelStatus getProductStatus(ProductModel product, WarehouseModel warehouse)
Description copied from interface:StockServiceChecks the stock level status of the product in the specified warehouse.- Specified by:
getProductStatusin interfaceStockService- Parameters:
product- the productwarehouse- warehouse of the product- Returns:
- stock level status
-
getProductStatus
public StockLevelStatus getProductStatus(ProductModel product, java.util.Collection<WarehouseModel> warehouses)
Description copied from interface:StockServiceChecks the stock level status of the product in all specified warehouses.- Specified by:
getProductStatusin interfaceStockService- Parameters:
product- the productwarehouses- warehouses of the product- Returns:
- stock level status
-
createStockLevel
protected StockLevelModel createStockLevel(ProductModel product, WarehouseModel warehouse, int available)
Creates a new stock level. The createdStockLevelModelis saved.- Parameters:
product- the productwarehouse- warehouse of the productavailable- amount of available products- Returns:
- the created
StockLevelModel
-
createStockLevel
protected StockLevelModel createStockLevel(ProductModel product, WarehouseModel warehouse, int available, int overSelling, int reserved, InStockStatus status, int maxStockLevelHistoryCount, boolean treatNegativeAsZero)
Creates a new stock level. The createdStockLevelModelis saved.- Parameters:
product- the productwarehouse- warehouse of the productavailable- amount of available productsoverSelling- amount of over-selling productsreserved- amount of reserved productsstatus- tag of in stock, out of stock, or not specifiedmaxStockLevelHistoryCount- max count ofStockLevelHistoryEntryModel, negative value for unlimitedtreatNegativeAsZero- true if negative stock level is treated as zero- Returns:
- the created
StockLevelModel
-
createStockLevelHistoryEntry
protected StockLevelHistoryEntryModel createStockLevelHistoryEntry(StockLevelModel stockLevel, int actual, int reserved, StockLevelUpdateType updateType, java.lang.String comment)
Creates a new stock level history entry. The createdStockLevelHistoryEntryModelis saved.- Parameters:
stockLevel- the stock level whose history entry should be createdactual- the actual amountreserved- the reserved amountupdateType- the update typecomment- the comment- Returns:
- the created
StockLevelHistoryEntryModel
-
getStockLevelAmount
public int getStockLevelAmount(ProductModel product, WarehouseModel warehouse)
Description copied from interface:StockServiceFinds the stock level of the specified product in the specified warehouse, and calculates the actual available amount.- Specified by:
getStockLevelAmountin interfaceStockService- Parameters:
product- the productwarehouse- warehouse of the product- Returns:
- actual available amount for the specific product
-
getTotalStockLevelAmount
public int getTotalStockLevelAmount(ProductModel product)
Description copied from interface:StockServiceFinds the stock levels of the specified product from all warehouses, and calculates the total actual amount.- Specified by:
getTotalStockLevelAmountin interfaceStockService- Parameters:
product- the product- Returns:
- calculated actual amount of the specified product
-
getTotalStockLevelAmount
public int getTotalStockLevelAmount(ProductModel product, java.util.Collection<WarehouseModel> warehouses)
Description copied from interface:StockServiceFinds all stock levels of the specified product in the specified warehouses, and calculates the total actual amount.- Specified by:
getTotalStockLevelAmountin interfaceStockService- Parameters:
product- the productwarehouses- the warehouses- Returns:
- calculated actual amount of the specified product in the warehouses
-
setInStockStatus
public void setInStockStatus(ProductModel product, java.util.Collection<WarehouseModel> warehouses, InStockStatus status)
Description copied from interface:StockServiceSets the in stock status of all stock levels of the product in the specified warehouses.- Specified by:
setInStockStatusin interfaceStockService- Parameters:
product- the productwarehouses- the warehousesstatus- the in stock status
-
getInStockStatus
public InStockStatus getInStockStatus(ProductModel product, WarehouseModel warehouse)
Description copied from interface:StockServiceChecks the stock level status of the product in the specified warehouses.- Specified by:
getInStockStatusin interfaceStockService- Parameters:
product- the productwarehouse- the warehouse- Returns:
- the in stock status
-
reserve
public void reserve(ProductModel product, WarehouseModel warehouse, int amount, java.lang.String comment) throws InsufficientStockLevelException
Description copied from interface:StockServiceReserves the product in the specified warehouse.- Specified by:
reservein interfaceStockService- Parameters:
product- the productwarehouse- the warehouse where product is 'stored'amount- the amount of the reservationcomment- the comment for the reservation- Throws:
InsufficientStockLevelException- if not enough products are available in the stock
-
release
public void release(ProductModel product, WarehouseModel warehouse, int amount, java.lang.String comment)
Description copied from interface:StockServiceRelease the product in the specified warehouse.- Specified by:
releasein interfaceStockService- Parameters:
product- the productwarehouse- the warehouse where product is 'stored'amount- the amount of the releasecomment- the comment for the release
-
updateActualStockLevel
public void updateActualStockLevel(ProductModel product, WarehouseModel warehouse, int actualAmount, java.lang.String comment)
Description copied from interface:StockServiceUpdates the actual stock level of the specified product in the specified warehouse.- Specified by:
updateActualStockLevelin interfaceStockService- Parameters:
product- the productwarehouse- the warehouse where product is 'stored'actualAmount- the actual amount of the productcomment- the comment for the update operation
-
getAvailability
public java.util.Map<WarehouseModel,java.lang.Integer> getAvailability(java.util.List<WarehouseModel> warehouses, ProductModel product, java.util.Date date)
Gets the product quantity for the specified product, warehouses and date.- Specified by:
getAvailabilityin interfaceStockService- Parameters:
warehouses- the warehousesproduct- the productdate- the date the specified quantity has to be available at least.- Returns:
- Returns the mapped quantity
-
getAvailability
public java.util.Map<WarehouseModel,java.util.Date> getAvailability(java.util.List<WarehouseModel> warehouses, ProductModel product, int quantity)
Returns product availability, passing product, and quantity as parameters- Specified by:
getAvailabilityin interfaceStockService- Parameters:
product- the productwarehouses- the warehousesquantity- the asked quantity- Returns:
- Returns the mapped availability date
-
getAvailability
public java.lang.String getAvailability(ProductModel product, WarehouseModel warehouse, java.util.Date date, LanguageModel language)
Description copied from interface:StockServiceGets the available quantity of the product for the specified warehouse.- Specified by:
getAvailabilityin interfaceStockService- Parameters:
product- the productwarehouse- the warehousedate- the date the specified quantity has to be available at least (could be null).language- language for which the text should be localized- Returns:
- the configured availability text message
-
getAvailability
public java.lang.String getAvailability(ProductModel product, java.util.List<WarehouseModel> warehouses, java.util.Date date, LanguageModel language)
Gets the available quantity of the product for the specified warehouses by invoking injected strategy. Configuration:- Specified by:
getAvailabilityin interfaceStockService- Parameters:
product- the productwarehouses- the warehousesdate- the date the specified quantity has to be available at least (could be null).language- language for which the text should be localized- Returns:
- Returns a configured availability text message
-
getAvailability
public java.lang.String getAvailability(ProductModel product, WarehouseModel warehouse, int quantity, LanguageModel language)
Description copied from interface:StockServiceGets availability date by invoking strategy for calculating product availability, passing product, quantity and warehouse as parameters.- Specified by:
getAvailabilityin interfaceStockService- Parameters:
product- the productwarehouse- the warehousequantity- the asked quantitylanguage- language for which the text should be localized- Returns:
- String the configured availability text message
-
getAvailability
public java.lang.String getAvailability(ProductModel product, java.util.List<WarehouseModel> warehouses, int quantity, LanguageModel language)
Gets availability date by invoking strategy for calculating product availability, passing product, quantity and warehouses as parameters by invoking injected strategy. Configuration:- Specified by:
getAvailabilityin interfaceStockService- Parameters:
product- the productwarehouses- the warehousesquantity- the asked quantitylanguage- language for which the text should be localized- Returns:
- Returns a configured availability text message
-
getBestMatchOfQuantity
public WarehouseModel getBestMatchOfQuantity(java.util.Map<WarehouseModel,java.lang.Integer> map)
Returns the warehouse which offers the "best" product "quantity" by invoking injected strategy.
Configuration:- Specified by:
getBestMatchOfQuantityin interfaceStockService- Parameters:
map- the mapped quantities of a certain product- Returns:
- WarehouseModel best match
-
getBestMatchOfAvailability
public WarehouseModel getBestMatchOfAvailability(java.util.Map<WarehouseModel,java.util.Date> map)
Returns the warehouse which offers the "best" product "availability" by invoking injected strategy.
Configuration:- Specified by:
getBestMatchOfAvailabilityin interfaceStockService- Parameters:
map- the mapped available dates of a certain product- Returns:
- WarehouseModel best match
-
getStockLevel
public StockLevelModel getStockLevel(ProductModel product, WarehouseModel warehouse)
Description copied from interface:StockServiceFinds the stock level of the specified product at the specified warehouse.- Specified by:
getStockLevelin interfaceStockService- Parameters:
product- the productwarehouse- warehouse of the product- Returns:
- found stock level, and null if no such stock level can be found.
-
getAllStockLevels
public java.util.Collection<StockLevelModel> getAllStockLevels(ProductModel product)
Description copied from interface:StockServiceFinds the stock levels of the specified product from all warehouses.- Specified by:
getAllStockLevelsin interfaceStockService- Parameters:
product- the product- Returns:
- all found stock levels of product
-
getStockLevels
public java.util.Collection<StockLevelModel> getStockLevels(ProductModel product, java.util.Collection<WarehouseModel> warehouses)
Description copied from interface:StockServiceFinds all stock levels of the specified product in the specified warehouses.- Specified by:
getStockLevelsin interfaceStockService- Parameters:
product- the productwarehouses- the warehouses- Returns:
- found stock levels of the product
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getStockLevelDao
protected StockLevelDao getStockLevelDao()
-
setStockLevelDao
public void setStockLevelDao(StockLevelDao stockLevelDao)
-
getStockLevelStatusStrategy
protected StockLevelStatusStrategy getStockLevelStatusStrategy()
-
setStockLevelStatusStrategy
public void setStockLevelStatusStrategy(StockLevelStatusStrategy stockLevelStatusStrategy)
-
getProductAvailabilityStrategy
protected ProductAvailabilityStrategy getProductAvailabilityStrategy()
-
setProductAvailabilityStrategy
public void setProductAvailabilityStrategy(ProductAvailabilityStrategy productAvailabilityStrategy)
The injected strategy will be used for calculating the availability of the specified product.- Parameters:
productAvailabilityStrategy- the productAvailabilityStrategy to set
-
getStockLevelProductStrategy
protected StockLevelProductStrategy getStockLevelProductStrategy()
-
setStockLevelProductStrategy
public void setStockLevelProductStrategy(StockLevelProductStrategy stockLevelProductStrategy)
-
-