public class CategoryMgr extends BaseMgr implements CategoryMgrIf
Modifier and Type | Class and Description |
---|---|
protected class |
CategoryMgr.StaticData
Used to store the static data of this manager
|
Modifier and Type | Field and Description |
---|---|
protected static org.apache.commons.logging.Log |
log
the log
|
protected static java.lang.String |
mutex |
protected static java.util.Map<java.lang.String,CategoryMgr.StaticData> |
staticDataHM
Hash Map that contains the static data
|
templateBaseDir
Constructor and Description |
---|
CategoryMgr(KKEngIf eng)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected Category[] |
cloneTree(Category[] tree) |
protected Category[] |
createCategoryTree(int languageId)
Creates a category tree with a single query
|
protected void |
fillCatTreeWithProductNumbers(Category[] catTree,
CategoryTreeOptionsIf options)
Receives an array of Categories as input and compiles the numberOfProducts field for each
Category
|
Category[] |
getCategoriesForCatalogId(java.lang.String catalogId,
int languageId)
Return an array of categories for the catalogId passed.
|
Category[] |
getCategoriesFromIds(java.util.ArrayList<java.lang.Integer> catIdList,
int languageId)
Return an array of categories for the ids passed in through the catIdList parameter.
|
Category[] |
getCategoriesPerManufacturer(int manufacturerId,
int languageId)
Returns an array of leaf Category objects for the given manufacturer.
|
Category[] |
getCategoriesPerProduct(int productId,
int languageId)
Returns an array of Category objects that the product belongs to.
|
Category |
getCategory(int categoryId,
int languageId) |
protected Category[] |
getCategoryTree(int languageId)
Calls getCategoryTree(int languageId, boolean getNumProducts)
|
Category[] |
getCategoryTree(int languageId,
boolean getNumProducts)
Returns an array of top level categories each of which includes an array of child categories
etc.
|
Category[] |
getCategoryTreeWithOptions(CategoryTreeOptionsIf options)
Returns a category tree structure consisting of an array of top level categories, each of
which may contain an array of child categories.
|
int[] |
getChildren(int categoryId)
Returns an array of categoryId describing the children of the given category.
|
CategoryStats |
getLastModifiedData()
Retrieves the date of the last modified category and the number of categories in the
database.
|
protected int |
getNumProductsPerCategory(int categoryId)
Returns the number of products for a leaf category by doing a direct query on the database.
|
int[] |
getParents(int categoryId)
Returns an array of categoryId describing the given category and its parents.
|
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> |
getProductsPerCategory(CategoryTreeOptionsIf options)
Returns a HashMap with CategoryId as the key and Number of Products for that category as the
value.
|
protected void |
initStaticVariables(CategoryStats catStats)
A synchronized method to initialise the static variables
|
void |
setCategoryLevel(Category cat,
int level)
Recursive method to set the category level
|
protected void |
setChildrenProductNumbers(Category parent,
java.util.HashMap<java.lang.Integer,java.lang.Integer> hm)
Recurses through all of the category tree setting the
numberOfProducts
attribute. |
protected void |
setCriteriaWithStandardAttributes(KKCriteria c,
int languageId)
Sets the criteria with the standard attributes so as not to have to repeat this code many
times.
|
protected void |
setCriteriaWithStandardAttributes(KKCriteria c,
int languageId,
boolean addDescription)
Sets the criteria with the standard attributes so as not to have to repeat this code many
times.
|
acquireLock, addInsertAttr, addInsertAttr, addStringRuleConstraint, addStringRuleConstraint, checkRequired, escapeHTML, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCacheMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getEventMgr, getExportMgr, getHTMLEscaper, getKonaKartConfig, getKonaKartConfig, getKonaKartConfig, getLangMgr, getManuMgr, getMiscItemMgr, getMiscPriceMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderIntegrationMgr, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getProductsToCategoresCriteria, getPromMgr, getPunchOutMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getStoreMgr, getStoreTime, getSuggestionMgr, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, insertKKEvent, insertKKEvent, isBusiness, isBusinessOrEnterprise, isClassPresent, isCommunity, isDeadlockException, isEnterprise, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareCustomersOrProducts, isMultiStoreSharedDb, isMultiStoreShareProducts, isMultiVendor, isUnix, manageThrowable, releaseLock, updateStaticVariablesNow
protected static org.apache.commons.logging.Log log
protected static java.lang.String mutex
protected static java.util.Map<java.lang.String,CategoryMgr.StaticData> staticDataHM
public CategoryMgr(KKEngIf eng) throws java.lang.Exception
eng
- the engjava.lang.Exception
- an unexpected exceptionprotected Category[] getCategoryTree(int languageId) throws java.lang.Exception
languageId
- the languageIdorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)java.lang.Exception
- an unexpected exceptionpublic Category[] getCategoryTree(int languageId, boolean getNumProducts) throws java.lang.Exception
Each Category class contains a field that describes how many products exist for that
category. This field is not set in the static tree and we calculate it each time on demand
since it only involves one database query and the product information is a lot more dynamic
than that of the categories. We only calculate it if getNumProducts
is set.
getCategoryTree
in interface CategoryMgrIf
languageId
- the languageIdgetNumProducts
- the getNumProductsjava.lang.Exception
- an unexpected exceptionpublic Category[] getCategoryTreeWithOptions(CategoryTreeOptionsIf options) throws java.lang.Exception
The name of the category is language dependent and will be returned in the language defined
by the languageId
parameter of the CategoryTreeObject.
Each Category class contains a numberOfProducts
field that describes how many
products exist for that category. It is only calculated if the getNumProducts
input parameter of the CategoryTreeOptions object is set to true. For performance reasons
this parameter should be set to false if numberOfProducts
is not required.
If the CategoryTreeOptions object has its returnClonedTree attribute set to true a cloned version of the category tree will be returned.
getCategoryTreeWithOptions
in interface CategoryMgrIf
options
- Category tree options object.java.lang.Exception
- an unexpected exceptionprotected Category[] cloneTree(Category[] tree) throws java.lang.Exception
java.lang.Exception
protected void initStaticVariables(CategoryStats catStats) throws com.konakart.app.KKException
catStats
- the catStatscom.konakart.app.KKException
- an unexpected KKException exceptionprotected Category[] createCategoryTree(int languageId) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, com.konakart.app.KKException
languageId
- the languageIdorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)com.konakart.app.KKException
- an unexpected KKException exceptionpublic void setCategoryLevel(Category cat, int level)
cat
- the catlevel
- the levelpublic Category[] getCategoriesPerManufacturer(int manufacturerId, int languageId) throws java.lang.Exception
getCategoriesPerManufacturer
in interface CategoryMgrIf
manufacturerId
- the manufacturerIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic Category[] getCategoriesPerProduct(int productId, int languageId) throws java.lang.Exception
getCategoriesPerProduct
in interface CategoryMgrIf
productId
- the productIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionprotected java.util.HashMap<java.lang.Integer,java.lang.Integer> getProductsPerCategory(CategoryTreeOptionsIf options) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, com.konakart.app.KKException
options
- Category tree options object.org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)com.konakart.app.KKException
- an unexpected KKException exceptionprotected int getNumProductsPerCategory(int categoryId) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, com.konakart.app.KKException
categoryId
- the categoryIdorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)com.konakart.app.KKException
- an unexpected KKException exceptionpublic CategoryStats getLastModifiedData() throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, com.konakart.app.KKException
last_modified
column doesn't contain any valid dates, then we return the current
date since we have to assume worst case that some category has been modified.org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)com.konakart.app.KKException
- an unexpected KKException exceptionprotected void fillCatTreeWithProductNumbers(Category[] catTree, CategoryTreeOptionsIf options) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, com.konakart.app.KKException
catTree
- the catTreeoptions
- Category tree options object.com.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)org.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)com.konakart.app.KKException
- an unexpected KKException exceptionprotected void setChildrenProductNumbers(Category parent, java.util.HashMap<java.lang.Integer,java.lang.Integer> hm) throws com.workingdogs.village.DataSetException
numberOfProducts
attribute.parent
- The parent category.hm
- the hmcom.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)public int[] getChildren(int categoryId) throws java.lang.Exception
getChildren
in interface CategoryMgrIf
categoryId
- the categoryIdjava.lang.Exception
- an unexpected exceptionpublic int[] getParents(int categoryId) throws java.lang.Exception
getParents
in interface CategoryMgrIf
categoryId
- the categoryIdjava.lang.Exception
- an unexpected exceptionpublic Category getCategory(int categoryId, int languageId) throws java.lang.Exception
getCategory
in interface CategoryMgrIf
categoryId
- the categoryIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionprotected void setCriteriaWithStandardAttributes(KKCriteria c, int languageId)
c
- the clanguageId
- the languageIdprotected void setCriteriaWithStandardAttributes(KKCriteria c, int languageId, boolean addDescription)
c
- the clanguageId
- the languageIdaddDescription
- the addDescriptionpublic Category[] getCategoriesFromIds(java.util.ArrayList<java.lang.Integer> catIdList, int languageId) throws java.lang.Exception
getCategoriesFromIds
in interface CategoryMgrIf
catIdList
- An array list containing ids of categorieslanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic Category[] getCategoriesForCatalogId(java.lang.String catalogId, int languageId) throws java.lang.Exception
getCategoriesForCatalogId
in interface CategoryMgrIf
catalogId
- catalog IdlanguageId
- language Idjava.lang.Exception
- an unexpected exceptionCopyright © 2018 DS Data Systems UK Ltd.