com.elasticpath.service.catalog.impl
Class TopSellerServiceImpl

java.lang.Object
  extended by com.elasticpath.service.impl.AbstractEpServiceImpl
      extended by com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
          extended by com.elasticpath.service.catalog.impl.TopSellerServiceImpl
All Implemented Interfaces:
TopSellerService, EpPersistenceService, EpService

public class TopSellerServiceImpl
extends AbstractEpPersistenceServiceImpl
implements TopSellerService

The default implementation of TopSellerService.


Constructor Summary
TopSellerServiceImpl()
           
 
Method Summary
 boolean calculateSalesCount()
          Calculate the number of sales for a product and update its sales count based on the number of items ordered in the order.
 TopSeller findTopSellerByCategoryUid(long categoryUid)
          Find top sellers of the given category uid.
 java.lang.Object getObject(long uid)
          Get a persistent instance with the given id.
 TimeService getTimeService()
          Returns the time service.
 org.apache.commons.collections.map.ListOrderedMap getTopCategoriesFromDate(java.util.Date startDate, int numResults)
          Get map of leaf Categories and number of sales since a specific date.
 org.apache.commons.collections.map.ListOrderedMap getTopProductsFromDate(java.util.Date startDate, int numResults)
          Get map of Products and number of sales since a specific date.
 void saveOrUpdate(TopSeller topSeller)
          Save or update the given top seller.
 void setCategoryService(CategoryService categoryService)
          Set the category service.
 void setOrderService(OrderService orderService)
          Set the order service.
 void setProductService(ProductService productService)
          Set the product service.
 void setPropertiesDao(PropertiesDao propertiesDao)
          Sets the DAO used to load properties.
 void setTimeService(TimeService timeService)
          Sets the time service.
 void setUtility(Utility utility)
          Set the utility class.
 void updateTopSellers()
          Calculate the number of sales for a particular product and update its sales count.
 void updateTopSellersForCategories()
          Populate top sellers for each categories.
 void updateTopSellersForTheStore()
          Populate top sellers for the store.
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpServiceImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.service.EpPersistenceService
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from interface com.elasticpath.service.EpService
getElasticPath, setElasticPath
 

Constructor Detail

TopSellerServiceImpl

public TopSellerServiceImpl()
Method Detail

calculateSalesCount

public boolean calculateSalesCount()
Calculate the number of sales for a product and update its sales count based on the number of items ordered in the order.

Specified by:
calculateSalesCount in interface TopSellerService
Returns:
true if has updates

findTopSellerByCategoryUid

public TopSeller findTopSellerByCategoryUid(long categoryUid)
Find top sellers of the given category uid. Give 0 to find top sellers for the whole store.

Specified by:
findTopSellerByCategoryUid in interface TopSellerService
Parameters:
categoryUid - the category uid, give 0 to find top sellers for the whole store
Returns:
a TopSeller if found, otherwise null

getObject

public java.lang.Object getObject(long uid)
                           throws EpServiceException
Get a persistent instance with the given id.

Specified by:
getObject in interface EpPersistenceService
Parameters:
uid - the persistent instance uid
Returns:
the persistent instance if exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getTimeService

public TimeService getTimeService()
Returns the time service.

Returns:
the time service.

getTopCategoriesFromDate

public org.apache.commons.collections.map.ListOrderedMap getTopCategoriesFromDate(java.util.Date startDate,
                                                                                  int numResults)
Get map of leaf Categories and number of sales since a specific date.

Specified by:
getTopCategoriesFromDate in interface TopSellerService
Parameters:
startDate - Date to start calculation from
numResults - The maximum number of products to return
Returns:
map of categories and associated number of sales in an array, sorted by sale numbers

getTopProductsFromDate

public org.apache.commons.collections.map.ListOrderedMap getTopProductsFromDate(java.util.Date startDate,
                                                                                int numResults)
Get map of Products and number of sales since a specific date.

Specified by:
getTopProductsFromDate in interface TopSellerService
Parameters:
startDate - Date to start calculation from
numResults - The maximum number of products to return
Returns:
map of product and associated number of sales, sorted by sale numbers

saveOrUpdate

public void saveOrUpdate(TopSeller topSeller)
                  throws EpServiceException
Save or update the given top seller.

Parameters:
topSeller - the category to save or update
Throws:
EpServiceException - - in case of any errors

setCategoryService

public void setCategoryService(CategoryService categoryService)
Set the category service.

Specified by:
setCategoryService in interface TopSellerService
Parameters:
categoryService - the category service

setOrderService

public void setOrderService(OrderService orderService)
Set the order service.

Specified by:
setOrderService in interface TopSellerService
Parameters:
orderService - the order service

setProductService

public void setProductService(ProductService productService)
Set the product service.

Specified by:
setProductService in interface TopSellerService
Parameters:
productService - the product service

setPropertiesDao

public void setPropertiesDao(PropertiesDao propertiesDao)
Sets the DAO used to load properties.

Specified by:
setPropertiesDao in interface TopSellerService
Parameters:
propertiesDao - the properties DAO used to retrieve properties information

setTimeService

public void setTimeService(TimeService timeService)
Sets the time service.

Parameters:
timeService - the time service

setUtility

public void setUtility(Utility utility)
Set the utility class.

Specified by:
setUtility in interface TopSellerService
Parameters:
utility - the utility class

updateTopSellers

public void updateTopSellers()
Calculate the number of sales for a particular product and update its sales count. Also populate top sellers for each category and the whole store.

Specified by:
updateTopSellers in interface TopSellerService

updateTopSellersForCategories

public void updateTopSellersForCategories()
Populate top sellers for each categories.

Specified by:
updateTopSellersForCategories in interface TopSellerService

updateTopSellersForTheStore

public void updateTopSellersForTheStore()
Populate top sellers for the store.

Specified by:
updateTopSellersForTheStore in interface TopSellerService