Class DefaultStockService

    • Constructor Detail

      • DefaultStockService

        public DefaultStockService()
    • Method Detail

      • getProductStatus

        public StockLevelStatus getProductStatus​(ProductModel product,
                                                 java.util.Collection<WarehouseModel> warehouses)
        Description copied from interface: StockService
        Checks the stock level status of the product in all specified warehouses.
        Specified by:
        getProductStatus in interface StockService
        Parameters:
        product - the product
        warehouses - warehouses of the product
        Returns:
        stock level status
      • 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 created StockLevelModel is saved.
        Parameters:
        product - the product
        warehouse - warehouse of the product
        available - amount of available products
        overSelling - amount of over-selling products
        reserved - amount of reserved products
        status - tag of in stock, out of stock, or not specified
        maxStockLevelHistoryCount - max count of StockLevelHistoryEntryModel, negative value for unlimited
        treatNegativeAsZero - true if negative stock level is treated as zero
        Returns:
        the created StockLevelModel
      • getStockLevelAmount

        public int getStockLevelAmount​(ProductModel product,
                                       WarehouseModel warehouse)
        Description copied from interface: StockService
        Finds the stock level of the specified product in the specified warehouse, and calculates the actual available amount.
        Specified by:
        getStockLevelAmount in interface StockService
        Parameters:
        product - the product
        warehouse - warehouse of the product
        Returns:
        actual available amount for the specific product
      • getTotalStockLevelAmount

        public int getTotalStockLevelAmount​(ProductModel product)
        Description copied from interface: StockService
        Finds the stock levels of the specified product from all warehouses, and calculates the total actual amount.
        Specified by:
        getTotalStockLevelAmount in interface StockService
        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: StockService
        Finds all stock levels of the specified product in the specified warehouses, and calculates the total actual amount.
        Specified by:
        getTotalStockLevelAmount in interface StockService
        Parameters:
        product - the product
        warehouses - 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: StockService
        Sets the in stock status of all stock levels of the product in the specified warehouses.
        Specified by:
        setInStockStatus in interface StockService
        Parameters:
        product - the product
        warehouses - the warehouses
        status - the in stock status
      • release

        public void release​(ProductModel product,
                            WarehouseModel warehouse,
                            int amount,
                            java.lang.String comment)
        Description copied from interface: StockService
        Release the product in the specified warehouse.
        Specified by:
        release in interface StockService
        Parameters:
        product - the product
        warehouse - the warehouse where product is 'stored'
        amount - the amount of the release
        comment - the comment for the release
      • updateActualStockLevel

        public void updateActualStockLevel​(ProductModel product,
                                           WarehouseModel warehouse,
                                           int actualAmount,
                                           java.lang.String comment)
        Description copied from interface: StockService
        Updates the actual stock level of the specified product in the specified warehouse.
        Specified by:
        updateActualStockLevel in interface StockService
        Parameters:
        product - the product
        warehouse - the warehouse where product is 'stored'
        actualAmount - the actual amount of the product
        comment - 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:
        getAvailability in interface StockService
        Parameters:
        warehouses - the warehouses
        product - the product
        date - 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:
        getAvailability in interface StockService
        Parameters:
        product - the product
        warehouses - the warehouses
        quantity - 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: StockService
        Gets the available quantity of the product for the specified warehouse.
        Specified by:
        getAvailability in interface StockService
        Parameters:
        product - the product
        warehouse - the warehouse
        date - 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:
        getAvailability in interface StockService
        Parameters:
        product - the product
        warehouses - the warehouses
        date - 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: StockService
        Gets availability date by invoking strategy for calculating product availability, passing product, quantity and warehouse as parameters.
        Specified by:
        getAvailability in interface StockService
        Parameters:
        product - the product
        warehouse - the warehouse
        quantity - the asked quantity
        language - 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:
        getAvailability in interface StockService
        Parameters:
        product - the product
        warehouses - the warehouses
        quantity - the asked quantity
        language - 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:
        getBestMatchOfQuantity in interface StockService
        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:
        getBestMatchOfAvailability in interface StockService
        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: StockService
        Finds the stock level of the specified product at the specified warehouse.
        Specified by:
        getStockLevel in interface StockService
        Parameters:
        product - the product
        warehouse - 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: StockService
        Finds the stock levels of the specified product from all warehouses.
        Specified by:
        getAllStockLevels in interface StockService
        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: StockService
        Finds all stock levels of the specified product in the specified warehouses.
        Specified by:
        getStockLevels in interface StockService
        Parameters:
        product - the product
        warehouses - the warehouses
        Returns:
        found stock levels of the product
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • setStockLevelDao

        public void setStockLevelDao​(StockLevelDao stockLevelDao)
      • setStockLevelStatusStrategy

        public void setStockLevelStatusStrategy​(StockLevelStatusStrategy stockLevelStatusStrategy)
      • 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
      • setStockLevelProductStrategy

        public void setStockLevelProductStrategy​(StockLevelProductStrategy stockLevelProductStrategy)