public class AdminCategoryMgr extends AdminBaseMgr implements AdminCategoryMgrIf
Modifier and Type | Class and Description |
---|---|
protected class |
AdminCategoryMgr.CategoryStats
Used to contain the number of categories and last modified category in order to determine
whether the category tree has been modified.
|
protected class |
AdminCategoryMgr.StaticData
Used to store the static data of this manager
|
Modifier and Type | Field and Description |
---|---|
static int |
ATTACH_CHILDREN_TO_PARENT
Used by deleteCategoryTree
|
static int |
DELETE_CHILDREN
Used by deleteCategoryTree
|
protected static org.apache.commons.logging.Log |
log
the log
|
protected static java.lang.String |
mutex |
protected static java.util.Map<java.lang.String,AdminCategoryMgr.StaticData> |
staticDataHM
Hash Map that contains the static data
|
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, debugStackTraceExclusions, kkAdminPropsFilePath, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
Constructor and Description |
---|
AdminCategoryMgr(KKAdminIf eng)
Constructor
|
Modifier and Type | Method and Description |
---|---|
private void |
addCatsToList(AdminCategory[] cats,
java.util.List<AdminCategory> flatCatList)
Recursive method to add all categories to the list
|
private void |
addCatsToMap(AdminCategory[] cats,
java.util.HashMap<java.lang.Integer,AdminCategory> hm)
Recursive method to add all categories to the map
|
protected AdminCategory[] |
cloneTree(AdminCategory[] tree) |
protected AdminCategory[] |
createCategoryTree(int languageId)
Creates a category tree with a single query
|
protected void |
deleteCatAndChildren(int categoryId)
Deletes this category plus all of the child categories plus any products that exist.
|
void |
deleteCategoryTree(int categoryId,
int options)
Delete the category referenced to by categoryId.
|
void |
deleteSingleCategory(int categoryId)
Delete a single category.
|
boolean |
doesCategoryExist(int categoryId)
Return true if the category exists.
|
boolean |
doesCategoryExist(int categoryId,
java.sql.Connection con)
Return true if the category exists.
|
void |
editCategory(AdminCategory cat)
Edit the category.
|
protected void |
fillCatTreeWithProductNumbers(AdminCategory[] catTree)
Receives an array of Categories as input and compiles the numberOfProducts field for each
Category
|
AdminCategory[] |
getAllCategories(int languageId)
Returns an array of all categories sparsely-populated with Id and name (in the specified
language) only.
|
AdminCategory[] |
getAllCategoryImages()
Returns an array of all categories sparsely-populated with Id and image name only.
|
AdminCategory[] |
getCategoriesPerProduct(int productId,
int languageId)
Returns all of the categories for the product
|
AdminCategory[] |
getCategoriesPerPromotion(int promotionId,
int languageId)
Returns all of the categories for the promotion
|
int[] |
getCategoriesPerTagGroup(int tagGroupId)
Return an array of Category Ids linked to the specified tag group.
|
AdminCategoryToTagGroup[] |
getCategoriesToTagGroups()
Return an array of all of the AdminCategoryToTagGroup records.
|
AdminCategory |
getCategory(int categoryId,
boolean getChildren,
int languageId) |
AdminCategory |
getCategory(int categoryId,
boolean getChildren,
int languageId,
java.sql.Connection con) |
AdminCategory |
getCategory(int categoryId,
boolean getChildren,
int languageId,
java.lang.String storeId) |
AdminCategory |
getCategory(int categoryId,
boolean getChildren,
int languageId,
java.lang.String storeId,
java.sql.Connection con) |
AdminCategory |
getCategoryFromCache(int catId,
int languageId)
It returns the category from a hash map created when building the category tree.
|
int |
getCategoryLevel(AdminCategory cat)
Method that calculates the level of the category where 0 is the top level, 1 is the first
child level etc.
|
AdminCategory[] |
getCategoryTree(int languageId,
boolean getNumProducts)
Returns an array of top level categories each of which includes an array of child categories
etc.
|
AdminCategory[] |
getCategoryTreeFlattenedList(AdminCategory[] catTree)
Creates an array of all categories from the Category Tree specified.
|
AdminCategory[] |
getCategoryTreeFromCache(int languageId)
It returns the category tree from the cache.
|
int[] |
getChildren(int categoryId)
Returns an array of categoryId describing the children of the given category.
|
protected AdminCategory[] |
getChildren(int parentId,
int languageId)
Returns an array of child categories, children of the input parameter, parent.
|
AdminCategoryMgr.CategoryStats |
getLastModifiedData()
Retrieves the date of the last modified category and the number of categories in the
database.
|
AdminMiscItem[] |
getMiscItems(AdminSearch search)
Get the MiscItems associated with the specified search criteria
|
AdminMiscItem[] |
getMiscItems(int catgeoryId)
Get the MiscItems associated with the specified catgeoryId
|
protected int |
getNumProductsPerCategory(int categoryId)
Returns the number of products for a leaf category by doing a direct query on the database.
|
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> |
getProductIdsPerCategory()
Returns a HashMap with CategoryId as the key and Number of Products for that category as the
value.
|
AdminCategory[] |
getTopLevelCategories(int languageId,
AdminDataDescriptor dataDesc)
Returns all of the top level categories which are those that have a parentId = 0.
|
protected void |
initStaticVariables(AdminCategoryMgr.CategoryStats catStats)
A synchronized method to initialise the static variables
|
int |
insertCategory(AdminCategory cat)
Insert a category as a child of the parent category.
|
protected void |
manageDataDescriptor(AdminDataDescriptor dataDesc,
com.konakart.db.KKCriteria c)
Provides common code to deal with the management of the DataDescriptor.
|
void |
moveCategory(int categoryId,
int newParentId)
Move this category to make it a child of the category identified by newParentId
|
protected com.konakart.db.KKCriteria |
setAllCategoryAttrs(com.konakart.db.KKCriteria c) |
protected com.konakart.db.KKCriteria |
setAllCategoryAttrs(com.konakart.db.KKCriteria c,
int languageId) |
protected void |
setChildrenProductNumbers(AdminCategory parent,
java.util.HashMap<java.lang.Integer,java.lang.Integer> hm)
Recurses through all of the category tree setting the
numberOfProducts
attribute. |
protected void |
validateCategory(AdminCategory cat)
Used to validate a category before editing or inserting
|
addInsertAttr, addInsertAttr, addStringRuleConstraint, addStringRuleConstraint, checkAPICallEnabled, checkIntInRange, checkIntIsSet, checkRequired, executeQuery, executeQuery, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminContentMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustPwdHistMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminEngineCacheMgr, getAdminEventMgr, getAdminExecuteMgr, getAdminFileMgr, getAdminFilterMgr, getAdminHtmlMgr, getAdminImportMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminMiscPriceMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminServletMgr, getAdminShipmentMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminSuggestionMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getDebugStackTraceExclusions, getEmailThreadGracefulShutdownTimeout, getExportMgr, getExportMgr, getExportXMLData, getIntFromString, getKkAdminPropsFilePath, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getNewCriteria, getNewCriteria, getOtherModuleByName, getPostSearchText, getPreSearchText, getProductsToCategoresCriteria, getPropertyValue, getPropertyValue, getPropertyValueAsBool, getPropertyValueAsInt, getPropertyValueAsLong, getRecordCount, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, insertKKEvent, insertKKEvent, isBusiness, isBusinessOrEnterprise, isCommunity, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareCustomersOrProducts, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, isUnix, isWindows, manageException, manageThrowable, refreshConfigs, removeCData, sendMQMessages, setAdminEng, setDebugStackTraceExclusions, setKkAdminPropsFilePath, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr, updateStaticVariablesNow
protected static org.apache.commons.logging.Log log
public static final int DELETE_CHILDREN
public static final int ATTACH_CHILDREN_TO_PARENT
protected static java.lang.String mutex
protected static java.util.Map<java.lang.String,AdminCategoryMgr.StaticData> staticDataHM
public AdminCategoryMgr(KKAdminIf eng) throws java.lang.Exception
eng
- KKAdmin enginejava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] 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 calculated if getNumProducts
is set to true.
getCategoryTree
in interface AdminCategoryMgrIf
languageId
- the languageIdgetNumProducts
- the getNumProductsjava.lang.Exception
- an unexpected exceptionprivate void addCatsToMap(AdminCategory[] cats, java.util.HashMap<java.lang.Integer,AdminCategory> hm)
cats
- the catshm
- the hmpublic AdminCategory[] getCategoryTreeFlattenedList(AdminCategory[] catTree)
AdminCategoryMgrIf
getCategoryTreeFlattenedList
in interface AdminCategoryMgrIf
catTree
- the catTreeprivate void addCatsToList(AdminCategory[] cats, java.util.List<AdminCategory> flatCatList)
cats
- the categories / child categoriesflatCatList
- a flattened list of categoriespublic AdminCategory getCategoryFromCache(int catId, int languageId) throws java.lang.Exception
getCategoryFromCache
in interface AdminCategoryMgrIf
catId
- the catIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getCategoryTreeFromCache(int languageId) throws java.lang.Exception
getCategoryTreeFromCache
in interface AdminCategoryMgrIf
languageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic int getCategoryLevel(AdminCategory cat) throws java.lang.Exception
getCategoryLevel
in interface AdminCategoryMgrIf
cat
- the catjava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getAllCategories(int languageId) throws java.lang.Exception
getAllCategories
in interface AdminCategoryMgrIf
languageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getAllCategoryImages() throws java.lang.Exception
getAllCategoryImages
in interface AdminCategoryMgrIf
java.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getTopLevelCategories(int languageId, AdminDataDescriptor dataDesc) throws java.lang.Exception
getTopLevelCategories
in interface AdminCategoryMgrIf
languageId
- the languageIddataDesc
- the dataDescjava.lang.Exception
- an unexpected exceptionpublic AdminMiscItem[] getMiscItems(int catgeoryId) throws org.apache.torque.TorqueException, KKAdminException, com.workingdogs.village.DataSetException, java.lang.Exception
catgeoryId
- the catgeoryIdjava.lang.Exception
- an unexpected exceptioncom.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)KKAdminException
- an unexpected exception in the KonaKart Admin engineorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)public AdminMiscItem[] getMiscItems(AdminSearch search) throws org.apache.torque.TorqueException, KKAdminException, com.workingdogs.village.DataSetException, java.lang.Exception
search
- the searchjava.lang.Exception
- an unexpected exceptioncom.workingdogs.village.DataSetException
- an unexpected exception due to data in Torque (the database layer)KKAdminException
- an unexpected exception in the KonaKart Admin engineorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)protected AdminCategory[] createCategoryTree(int languageId) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
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)KKAdminException
- an unexpected exception in the KonaKart Admin engineprotected AdminCategory[] getChildren(int parentId, int languageId) throws KKAdminException, java.lang.Exception
parentId
- the parentIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionKKAdminException
- an unexpected exception in the KonaKart Admin enginepublic int[] getChildren(int categoryId) throws java.lang.Exception
getChildren
in interface AdminCategoryMgrIf
categoryId
- the categoryIdjava.lang.Exception
- an unexpected exceptionprotected void deleteCatAndChildren(int categoryId) throws java.lang.Exception
categoryId
- the categoryIdjava.lang.Exception
- an unexpected exceptionprotected java.util.HashMap<java.lang.Integer,java.lang.Integer> getProductIdsPerCategory() throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
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)KKAdminException
- an unexpected exception in the KonaKart Admin engineprotected int getNumProductsPerCategory(int categoryId) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
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)KKAdminException
- an unexpected exception in the KonaKart Admin engineprotected void fillCatTreeWithProductNumbers(AdminCategory[] catTree) throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
catTree
- the catTreecom.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)KKAdminException
- an unexpected exception in the KonaKart Admin engineprotected void setChildrenProductNumbers(AdminCategory 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 AdminCategory getCategory(int categoryId, boolean getChildren, int languageId) throws java.lang.Exception
getCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdgetChildren
- If true we get all of the children. Children don't have an array of descriptions.languageId
- Needed to determine the language Id of the childrenjava.lang.Exception
- an unexpected exceptionpublic AdminCategory getCategory(int categoryId, boolean getChildren, int languageId, java.sql.Connection con) throws java.lang.Exception
getCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdgetChildren
- If true we get all of the children. Children don't have an array of descriptions.languageId
- Needed to determine the language Id of the childrencon
- Connection for transactionjava.lang.Exception
- an unexpected exceptionpublic AdminCategory getCategory(int categoryId, boolean getChildren, int languageId, java.lang.String storeId) throws java.lang.Exception
getCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdgetChildren
- If true we get all of the children. Children don't have an array of descriptions.languageId
- Needed to determine the language Id of the childrenstoreId
- The store idjava.lang.Exception
- an unexpected exceptionpublic AdminCategory getCategory(int categoryId, boolean getChildren, int languageId, java.lang.String storeId, java.sql.Connection con) throws java.lang.Exception
getCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdgetChildren
- If true we get all of the children. Children don't have an array of descriptions.languageId
- Needed to determine the language Id of the childrenstoreId
- The store idcon
- Connection for Transactionjava.lang.Exception
- an unexpected exceptionpublic boolean doesCategoryExist(int categoryId) throws org.apache.torque.TorqueException, KKAdminException
doesCategoryExist
in interface AdminCategoryMgrIf
categoryId
- the categoryIdorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)KKAdminException
- an unexpected exception in the KonaKart Admin enginepublic boolean doesCategoryExist(int categoryId, java.sql.Connection con) throws org.apache.torque.TorqueException, KKAdminException
doesCategoryExist
in interface AdminCategoryMgrIf
categoryId
- the categoryIdcon
- Connection for transactionorg.apache.torque.TorqueException
- an unexpected exception in Torque (the database layer)KKAdminException
- an unexpected exception in the KonaKart Admin enginepublic int insertCategory(AdminCategory cat) throws java.lang.Exception
insertCategory
in interface AdminCategoryMgrIf
cat
- the catjava.lang.Exception
- an unexpected exceptionpublic void editCategory(AdminCategory cat) throws java.lang.Exception
editCategory
in interface AdminCategoryMgrIf
cat
- the catjava.lang.Exception
- an unexpected exceptionprotected void validateCategory(AdminCategory cat) throws java.lang.Exception
cat
- the catjava.lang.Exception
- an unexpected exceptionpublic void deleteCategoryTree(int categoryId, int options) throws java.lang.Exception
deleteCategoryTree
in interface AdminCategoryMgrIf
categoryId
- the categoryIdoptions
- the optionsjava.lang.Exception
- an unexpected exceptionpublic void deleteSingleCategory(int categoryId) throws java.lang.Exception
deleteSingleCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdjava.lang.Exception
- an unexpected exceptionpublic void moveCategory(int categoryId, int newParentId) throws java.lang.Exception
moveCategory
in interface AdminCategoryMgrIf
categoryId
- the categoryIdnewParentId
- the newParentIdjava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getCategoriesPerPromotion(int promotionId, int languageId) throws java.lang.Exception
getCategoriesPerPromotion
in interface AdminCategoryMgrIf
promotionId
- the promotionIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionpublic AdminCategory[] getCategoriesPerProduct(int productId, int languageId) throws java.lang.Exception
getCategoriesPerProduct
in interface AdminCategoryMgrIf
productId
- the productIdlanguageId
- the languageIdjava.lang.Exception
- an unexpected exceptionprotected com.konakart.db.KKCriteria setAllCategoryAttrs(com.konakart.db.KKCriteria c, int languageId)
c
- the clanguageId
- the languageIdprotected com.konakart.db.KKCriteria setAllCategoryAttrs(com.konakart.db.KKCriteria c)
c
- the cprotected void manageDataDescriptor(AdminDataDescriptor dataDesc, com.konakart.db.KKCriteria c)
dataDesc
- the dataDescc
- the cpublic int[] getCategoriesPerTagGroup(int tagGroupId) throws java.lang.Exception
getCategoriesPerTagGroup
in interface AdminCategoryMgrIf
tagGroupId
- The id of the tag Groupjava.lang.Exception
- an unexpected exceptionpublic AdminCategoryToTagGroup[] getCategoriesToTagGroups() throws java.lang.Exception
getCategoriesToTagGroups
in interface AdminCategoryMgrIf
java.lang.Exception
- an unexpected exceptionprotected AdminCategory[] cloneTree(AdminCategory[] tree) throws java.lang.Exception
java.lang.Exception
protected void initStaticVariables(AdminCategoryMgr.CategoryStats catStats) throws KKAdminException
catStats
- the catStatsKKAdminException
- an unexpected exception in the KonaKart Admin enginepublic AdminCategoryMgr.CategoryStats getLastModifiedData() throws org.apache.torque.TorqueException, com.workingdogs.village.DataSetException, KKAdminException
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)KKAdminException
- an unexpected exception in the KonaKart Admin engineCopyright © 2018 DS Data Systems UK Ltd.