com.konakartadmin.bl
Class AdminCategoryMgr

java.lang.Object
  extended by com.konakartadmin.bl.AdminBaseMgr
      extended by com.konakartadmin.bl.AdminCategoryMgr
All Implemented Interfaces:
AdminCategoryMgrIf

public class AdminCategoryMgr
extends AdminBaseMgr
implements AdminCategoryMgrIf

The AdminCategoryMgr - for Managing Category Objects for the Admin Application


Nested Class Summary
 
Nested classes/interfaces inherited from class com.konakartadmin.bl.AdminBaseMgr
AdminBaseMgr.StaticData
 
Field Summary
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
 
Fields inherited from class com.konakartadmin.bl.AdminBaseMgr
adminEng, baseMgrMutex, baseStaticDataHM, cDataEnd, cDataStart, kkConf, kkInstanceId, mgrFactory, STORE_ID, templateBaseDir
 
Constructor Summary
AdminCategoryMgr(KKAdminIf eng)
          Constructor
 
Method Summary
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.
 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[] 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.lang.String storeId)
           
 AdminCategory[] getCategoryTree(int languageId, boolean getNumProducts)
          Returns an array of top level categories each of which includes an array of child categories etc.
 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.
 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.
protected  AdminCategory[] getTopLevelCategories(int languageId)
          Returns all of the top level categories which are those that have a parentId = 0.
 AdminCategory[] getTopLevelCategories(int languageId, AdminDataDescriptor dataDesc)
          Returns all of the top level categories which are those that have a parentId = 0.
 int insertCategory(AdminCategory cat)
          Insert a category as a child of the parent category.
protected  void manageDataDescriptor(AdminDataDescriptor dataDesc, com.konakart.bl.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.bl.KKCriteria setAllCategoryAttrs(com.konakart.bl.KKCriteria c)
           
protected  com.konakart.bl.KKCriteria setAllCategoryAttrs(com.konakart.bl.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
 
Methods inherited from class com.konakartadmin.bl.AdminBaseMgr
addInsertAttr, addInsertAttr, checkIntIsSet, checkRequired, getAdminAddressMgr, getAdminAuditMgr, getAdminBillingMgr, getAdminBookableProductMgr, getAdminCatMgr, getAdminConfigMgr, getAdminCurrMgr, getAdminCustMgr, getAdminCustTagMgr, getAdminEmailMgr, getAdminEng, getAdminHtmlMgr, getAdminLanguageMgr, getAdminManuMgr, getAdminMessageMgr, getAdminMiscItemMgr, getAdminModulesMgr, getAdminMultiStoreMgr, getAdminOrderMgr, getAdminPdfMgr, getAdminProdAttrMgr, getAdminProdMgr, getAdminPromMgr, getAdminPublishProdMgr, getAdminReviewMgr, getAdminSearchRuleMgr, getAdminSecMgr, getAdminSolrMgr, getAdminStoreMgr, getAdminTagMgr, getAdminTaxMgr, getAdminValidationMgr, getAdminVelocityContextMgr, getAdminWishListMgr, getBooleanFromString, getExportXMLData, getIntFromString, getKkConfig, getKkInstanceId, getMode, getModeString, getMqMgr, getNewCriteria, getNewCriteria, getPostSearchText, getPreSearchText, getPropertyValue, getRecordCount, getRewardPointMgr, getSingleIntResult, getStoreId, getTemplate, getTemplateBase, getXml_io, init, isConfigSet, isEnterprise, isMultiStoreLanguagesShared, isMultiStoreMode, isMultiStoreShareCategories, isMultiStoreShareCustomers, isMultiStoreShareProducts, isMultiStoreSingleDBCSMode, isMultiStoreSingleDBMode, isMultiStoreSingleDBNonCSMode, manageException, refreshConfigs, removeCData, setAdminEng, setupWildCardRules, setWildCardAfter, setWildCardBefore, shutdownGracefully, shutdownGracefully, timestampStr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
the log


DELETE_CHILDREN

public static final int DELETE_CHILDREN
Used by deleteCategoryTree

See Also:
Constant Field Values

ATTACH_CHILDREN_TO_PARENT

public static final int ATTACH_CHILDREN_TO_PARENT
Used by deleteCategoryTree

See Also:
Constant Field Values
Constructor Detail

AdminCategoryMgr

public AdminCategoryMgr(KKAdminIf eng)
                 throws java.lang.Exception
Constructor

Parameters:
eng - KKAdmin engine
Throws:
java.lang.Exception
Method Detail

getCategoryTree

public AdminCategory[] getCategoryTree(int languageId,
                                       boolean getNumProducts)
                                throws java.lang.Exception
Returns an array of top level categories each of which includes an array of child categories etc. so that the category tree structure can be navigated.

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.

Specified by:
getCategoryTree in interface AdminCategoryMgrIf
Parameters:
languageId -
getNumProducts -
Returns:
Array of Category Objects
Throws:
java.lang.Exception

getTopLevelCategories

protected AdminCategory[] getTopLevelCategories(int languageId)
                                         throws java.lang.Exception
Returns all of the top level categories which are those that have a parentId = 0. They are returned in the order of the sort order defined by the DB.

Parameters:
languageId -
Returns:
Array of Category Objects
Throws:
java.lang.Exception

getTopLevelCategories

public AdminCategory[] getTopLevelCategories(int languageId,
                                             AdminDataDescriptor dataDesc)
                                      throws java.lang.Exception
Returns all of the top level categories which are those that have a parentId = 0. An AdminDataDescriptor object may be supplied in order to add constraints and control the number of categories returned.

Specified by:
getTopLevelCategories in interface AdminCategoryMgrIf
Parameters:
languageId -
dataDesc -
Returns:
Array of Category Objects
Throws:
java.lang.Exception

getMiscItems

public AdminMiscItem[] getMiscItems(int catgeoryId)
                             throws org.apache.torque.TorqueException,
                                    KKAdminException,
                                    com.workingdogs.village.DataSetException,
                                    java.lang.Exception
Get the MiscItems associated with the specified catgeoryId

Parameters:
catgeoryId -
Returns:
An array of MiscItems which could be null
Throws:
java.lang.Exception
com.workingdogs.village.DataSetException
KKAdminException
org.apache.torque.TorqueException

getMiscItems

public AdminMiscItem[] getMiscItems(AdminSearch search)
                             throws org.apache.torque.TorqueException,
                                    KKAdminException,
                                    com.workingdogs.village.DataSetException,
                                    java.lang.Exception
Get the MiscItems associated with the specified search criteria

Parameters:
search -
Returns:
An array of MiscItems which could be null
Throws:
java.lang.Exception
com.workingdogs.village.DataSetException
KKAdminException
org.apache.torque.TorqueException

getChildren

protected AdminCategory[] getChildren(int parentId,
                                      int languageId)
                               throws KKAdminException,
                                      java.lang.Exception
Returns an array of child categories, children of the input parameter, parent. It is recursive and so fetches the grandchildren etc.

Parameters:
parentId -
languageId -
Returns:
Array of Category Objects
Throws:
java.lang.Exception
KKAdminException

getChildren

public int[] getChildren(int categoryId)
                  throws java.lang.Exception
Returns an array of categoryId describing the children of the given category. Returns null if there are no children.

Specified by:
getChildren in interface AdminCategoryMgrIf
Parameters:
categoryId -
Returns:
Return an array of categoryId
Throws:
java.lang.Exception

deleteCatAndChildren

protected void deleteCatAndChildren(int categoryId)
                             throws java.lang.Exception
Deletes this category plus all of the child categories plus any products that exist.

Parameters:
categoryId -
Throws:
java.lang.Exception

getProductIdsPerCategory

protected java.util.HashMap<java.lang.Integer,java.lang.Integer> getProductIdsPerCategory()
                                                                                   throws org.apache.torque.TorqueException,
                                                                                          com.workingdogs.village.DataSetException,
                                                                                          KKAdminException
Returns a HashMap with CategoryId as the key and Number of Products for that category as the value. The products need to have a non 0 status to be considered.

Returns:
HashMap Contains number of products per category
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException

getNumProductsPerCategory

protected int getNumProductsPerCategory(int categoryId)
                                 throws org.apache.torque.TorqueException,
                                        com.workingdogs.village.DataSetException,
                                        KKAdminException
Returns the number of products for a leaf category by doing a direct query on the database. The products need to have a non 0 status to be considered.

Parameters:
categoryId -
Returns:
Return an int defining the number of products per category
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
KKAdminException

fillCatTreeWithProductNumbers

protected void fillCatTreeWithProductNumbers(AdminCategory[] catTree)
                                      throws org.apache.torque.TorqueException,
                                             com.workingdogs.village.DataSetException,
                                             KKAdminException
Receives an array of Categories as input and compiles the numberOfProducts field for each Category

Parameters:
catTree -
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKAdminException

setChildrenProductNumbers

protected void setChildrenProductNumbers(AdminCategory parent,
                                         java.util.HashMap<java.lang.Integer,java.lang.Integer> hm)
                                  throws com.workingdogs.village.DataSetException
Recurses through all of the category tree setting the numberOfProducts attribute.

Parameters:
parent - The parent category.
hm -
Throws:
com.workingdogs.village.DataSetException

getCategory

public AdminCategory getCategory(int categoryId,
                                 boolean getChildren,
                                 int languageId)
                          throws java.lang.Exception
Specified by:
getCategory in interface AdminCategoryMgrIf
Parameters:
categoryId -
getChildren - 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 children
Returns:
Return a fully populated single category object (no children)
Throws:
java.lang.Exception

getCategory

public AdminCategory getCategory(int categoryId,
                                 boolean getChildren,
                                 int languageId,
                                 java.lang.String storeId)
                          throws java.lang.Exception
Specified by:
getCategory in interface AdminCategoryMgrIf
Parameters:
categoryId -
getChildren - 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 children
storeId - The store id
Returns:
Return a fully populated single category object (no children)
Throws:
java.lang.Exception

doesCategoryExist

public boolean doesCategoryExist(int categoryId)
                          throws org.apache.torque.TorqueException,
                                 KKAdminException
Return true if the category exists.

Specified by:
doesCategoryExist in interface AdminCategoryMgrIf
Parameters:
categoryId -
Returns:
True if the category exists
Throws:
org.apache.torque.TorqueException
KKAdminException

insertCategory

public int insertCategory(AdminCategory cat)
                   throws java.lang.Exception
Insert a category as a child of the parent category. If parent category is 0, we make it a top level category.

Specified by:
insertCategory in interface AdminCategoryMgrIf
Parameters:
cat -
Returns:
Returns the category Id
Throws:
java.lang.Exception

editCategory

public void editCategory(AdminCategory cat)
                  throws java.lang.Exception
Edit the category.

Specified by:
editCategory in interface AdminCategoryMgrIf
Parameters:
cat -
Throws:
java.lang.Exception

validateCategory

protected void validateCategory(AdminCategory cat)
                         throws java.lang.Exception
Used to validate a category before editing or inserting

Parameters:
cat -
Throws:
java.lang.Exception

deleteCategoryTree

public void deleteCategoryTree(int categoryId,
                               int options)
                        throws java.lang.Exception
Delete the category referenced to by categoryId. The child categories and products will either be moved up a level or deleted. If the category is a top level category, then the products will be deleted.

Specified by:
deleteCategoryTree in interface AdminCategoryMgrIf
Parameters:
categoryId -
options -
Throws:
java.lang.Exception

deleteSingleCategory

public void deleteSingleCategory(int categoryId)
                          throws java.lang.Exception
Delete a single category.

Specified by:
deleteSingleCategory in interface AdminCategoryMgrIf
Parameters:
categoryId -
Throws:
java.lang.Exception

moveCategory

public void moveCategory(int categoryId,
                         int newParentId)
                  throws java.lang.Exception
Move this category to make it a child of the category identified by newParentId

Specified by:
moveCategory in interface AdminCategoryMgrIf
Parameters:
categoryId -
newParentId -
Throws:
java.lang.Exception

getCategoriesPerPromotion

public AdminCategory[] getCategoriesPerPromotion(int promotionId,
                                                 int languageId)
                                          throws java.lang.Exception
Returns all of the categories for the promotion

Specified by:
getCategoriesPerPromotion in interface AdminCategoryMgrIf
Parameters:
promotionId -
languageId -
Returns:
Array of Category Objects
Throws:
java.lang.Exception

getCategoriesPerProduct

public AdminCategory[] getCategoriesPerProduct(int productId,
                                               int languageId)
                                        throws java.lang.Exception
Returns all of the categories for the product

Specified by:
getCategoriesPerProduct in interface AdminCategoryMgrIf
Parameters:
productId -
languageId -
Returns:
Array of Category Objects
Throws:
java.lang.Exception

setAllCategoryAttrs

protected com.konakart.bl.KKCriteria setAllCategoryAttrs(com.konakart.bl.KKCriteria c,
                                                         int languageId)
Parameters:
c -
languageId -
Returns:
Returns a criteria object

setAllCategoryAttrs

protected com.konakart.bl.KKCriteria setAllCategoryAttrs(com.konakart.bl.KKCriteria c)
Parameters:
c -
Returns:
Returns a criteria object

manageDataDescriptor

protected void manageDataDescriptor(AdminDataDescriptor dataDesc,
                                    com.konakart.bl.KKCriteria c)
Provides common code to deal with the management of the DataDescriptor.

Parameters:
dataDesc -
c -

getCategoriesPerTagGroup

public int[] getCategoriesPerTagGroup(int tagGroupId)
                               throws java.lang.Exception
Return an array of Category Ids linked to the specified tag group. An empty array is returned if no linked Category objects exist.

Specified by:
getCategoriesPerTagGroup in interface AdminCategoryMgrIf
Parameters:
tagGroupId - The id of the tag Group
Returns:
Returns an array of Category ids
Throws:
java.lang.Exception

getCategoriesToTagGroups

public AdminCategoryToTagGroup[] getCategoriesToTagGroups()
                                                   throws java.lang.Exception
Return an array of all of the AdminCategoryToTagGroup records. An empty array is returned if no such records exist.

Specified by:
getCategoriesToTagGroups in interface AdminCategoryMgrIf
Returns:
Returns an array of AdminCategoryToTagGroups
Throws:
java.lang.Exception


Copyright © 2011 DS Data Systems UK Ltd.