Class ProductInitializer
java.lang.Object
com.softslate.commerce.customer.product.ProductInitializer
Initializes singleton objects related to products, in the application scope.
Called by
BaseRequestProcessor
at the beginning of a request, if the singletons are found to be
missing.- Author:
- David Tobey
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.struts.action.ActionServletvoidinitializeBuiltInCategories(BusinessObjectFactory businessObjectFactory) Creates aCollectioncontaining each of the built-in categories in the system.voidinitializeCategoryTree(BusinessObjectFactory businessObjectFactory) Creates aCollectionrepresenting the tree of categories in the system.voidinitializeManufacturers(BusinessObjectFactory businessObjectFactory) Creates aCollectioncontaining each of the manufacturers in the system.voidinitializeStoreDiscounts(BusinessObjectFactory businessObjectFactory) Creates aCollectioncontaining discounts for display within the store.voidsetServlet(org.apache.struts.action.ActionServlet servlet)
-
Field Details
-
log
static org.apache.commons.logging.Log log -
servlet
private org.apache.struts.action.ActionServlet servlet
-
-
Constructor Details
-
ProductInitializer
public ProductInitializer() -
ProductInitializer
public ProductInitializer(org.apache.struts.action.ActionServlet servlet)
-
-
Method Details
-
getServlet
public org.apache.struts.action.ActionServlet getServlet() -
setServlet
public void setServlet(org.apache.struts.action.ActionServlet servlet) -
initializeCategoryTree
Creates aCollectionrepresenting the tree of categories in the system. Places theCollectionin the application scope as an attribute with the name "categoryTree" so it can be referenced on any store screen. (Useapplication.categoryTreeto reference theCollectionfrom within a JSP template.) Each item in theCollectionis an instance ofCategory, which corresponds to each one of the "top level" categories defined in the store (i.e., categories whoseparentCategoryproperty isnull). To render the tree, iterate through the top level categories and recursively navigate through each of theirsubcategoryCollections in turn.This method invokes
ProductProcessor.loadCategoryTree()to load the category information from the database.- Parameters:
businessObjectFactory- An initializedBusinessObjectFactoryused to create theProductProcessorimplementer that loads the category information from the database.
-
initializeBuiltInCategories
Creates aCollectioncontaining each of the built-in categories in the system. Built-in categories are typically composed of specials or other featured products that need to displayed on arbitrary pages thoughout the store. This method places theCollectionin the application scope as an attribute with the name "builtInCategories" so it can be referenced on any store screen. Each item in theCollectionis an instance ofCategory. (Useapplication.builtInCategoriesto reference theCollectionfrom within a JSP template.)Built-in categories are definined by the "builtInCategories" setting in the
sscSettingdatabase table, a comma-separated list of category codes.This method invokes
ProductProcessor.loadBuiltInCategories()to load the category information from the database.- Parameters:
businessObjectFactory- An initializedBusinessObjectFactoryused to create theProductProcessorimplementer that loads the category information from the database.
-
initializeManufacturers
Creates aCollectioncontaining each of the manufacturers in the system. This method places theCollectionin the application scope as an attribute with the name "manufacturers" so it can be referenced on any store screen. Each item in theCollectionis an instance ofManufacturer. (Useapplication.manufacturersto reference theCollectionfrom within a JSP template.)This method invokes
ManufacturerProcessor.loadActiveManufacturers()to load the manufacturers' information from the database.- Parameters:
businessObjectFactory- An initializedBusinessObjectFactoryused to create theManufacturerProcessorimplementer that loads the manufacturers' information from the database.
-
initializeStoreDiscounts
Creates aCollectioncontaining discounts for display within the store. The discounts include any global discount (which apply to the user's cart as a whole rather than to particular line items), or discounts where a condition of the discount is that a given product is in the user's cart (querying for these discounts here allows us to display them alongside the required products, as a method of upselling). This method places theCollectionin the application scope as an attribute with the name "storeDiscounts" so it can be referenced on any store screen. Each item in theCollectionis an instance ofDiscount. (Useapplication.storeDiscountsto reference theCollectionfrom within a JSP template.)This method invokes
DiscountProcessor.loadStoreDiscounts()to load the discounts' information from the database.- Parameters:
businessObjectFactory- An initializedBusinessObjectFactoryused to create theDiscountProcessorimplementer that loads the discounts' information from the database.
-