com.konakart.bl
Class WishListMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.WishListMgr
All Implemented Interfaces:
WishListMgrIf

public class WishListMgr
extends BaseMgr
implements WishListMgrIf

Manager for wish lists


Field Summary
protected static org.apache.commons.logging.Log log
          the log
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
WishListMgr(KKEngIf eng)
          Constructor
 
Method Summary
 int addToWishList(java.lang.String sessionId, WishListItemIf wishListItem)
          Add a WishListItem object to the wish list referenced by wishListId.
 int addToWishListWithOptions(java.lang.String sessionId, WishListItemIf wishListItem, AddToWishListOptionsIf options)
          Add a WishListItem object to the wish list referenced by wishListId.
protected  void checkWishListItemOptions(WishListItem wli)
          We may have the case where the wish list item object has an array of options that only have the id and value id set.
protected  FetchProductOptionsIf createFetchProductOptions(AddToWishListOptionsIf options)
          Creates a FetchProductOptions object from an AddToWishListOptions
 int createWishList(java.lang.String sessionId, WishListIf wishList)
          Create a wish list from a WishList object.
 int createWishListWithOptions(java.lang.String sessionId, WishListIf wishList, AddToWishListOptionsIf options)
          Create a wish list from a WishList object.
 void deleteWishList(java.lang.String sessionId, int wishListId)
          The wish list referenced by wishListId and all of the items contained by the wish list, will be deleted.
 void deleteWishListWithOptions(java.lang.String sessionId, int wishListId, AddToWishListOptionsIf options)
          The wish list referenced by wishListId and all of the items contained by the wish list, will be deleted.
 void editWishList(java.lang.String sessionId, WishListIf wishList)
          Edit an existing wish list object.
 void editWishListWithOptions(java.lang.String sessionId, WishListIf wishList, AddToWishListOptionsIf options)
          Edit an existing wish list object.
protected  int getCount(org.apache.torque.util.Criteria c)
          This method is mainly used for paging.
protected  int getCustomerId(java.lang.String sessionId, int customerId)
          If the sessionId is null, we check the customerId to ensure that it is negative.
 WishList getWishList(int wishListId)
          Get a wish list object for its id.
 WishList getWishList(java.lang.String sessionId, int wishListId)
          Get a wish list object for its id.
protected  WishListItem getWishListItem(int wishListItemId)
          Get a wish list item object for its id.
protected  WishListItem getWishListItemPerEncodedProductAndWishList(int wishListId, java.lang.String encodedProduct)
          This is used to see if a product that we are adding to the wish list already exists in it
 WishListItems getWishListItems(java.lang.String sessionId, DataDescriptorIf dataDesc, int wishListId, int languageId)
          Returns a WishListItems object containing an array of items and the number of items returned.
 WishListItems getWishListItemsWithOptions(java.lang.String sessionId, DataDescriptorIf dataDesc, int wishListId, int languageId, AddToWishListOptionsIf options)
          Returns a WishListItems object containing an array of items and the number of items returned.
 WishList getWishListWithItems(java.lang.String sessionId, int wishListId, int languageId)
          Returns a fully populated WishList object that may contain an array of WishListItem objects.
 WishList getWishListWithItemsWithOptions(java.lang.String sessionId, int wishListId, int languageId, AddToWishListOptionsIf options)
          Returns a fully populated WishList object that may contain an array of WishListItem objects.
protected  com.konakart.bl.WishListMgr.WishListAndCriteria getWishListWithItemsWithOptionsPrivate(java.lang.String sessionId, DataDescriptorIf dataDesc, int wishListId, int languageId, AddToWishListOptionsIf options)
          Protected method to get wish list items for all cases
 WishList getWishListWithOptions(java.lang.String sessionId, int wishListId, AddToWishListOptionsIf options)
          Get a wish list object for its id.
protected  void manageDataDescriptor(DataDescriptorIf dataDesc, org.apache.torque.util.Criteria c)
          Provides common code to deal with the management of the DataDescriptor
 void mergeWishListsWithOptions(java.lang.String sessionId, int customerFromId, int languageId, AddToWishListOptionsIf options)
          Add all items from the wish list of customerFrom to the wish list of customerTo which is retrieved from the sessionId.
protected  void populateOptsForWishListItem(WishListItem item, int priceId, int languageId, AddToWishListOptionsIf a2wOptions)
          The kk_wishlist_item table contains a products_id field which is encoded like this : 1{4}3{3}6 which means product of id==1 with product_options of id==4 and product_options_values of id==3 followed by product_options of id==3 and product_options_values of id==6.
protected  void populateWishListWithCustomerInfo(WishListIf wishList)
          Populates the wish list object with information about the customer so that a customer can select a public wish list for a particular person.
 void removeFromWishList(java.lang.String sessionId, int wishListItemId)
          Remove the WishListItem object referenced by wishListItemId.
 void removeFromWishListWithOptions(java.lang.String sessionId, int wishListItemId, AddToWishListOptionsIf options)
          Remove the WishListItem object referenced by wishListItemId.
 WishLists searchForWishLists(java.lang.String sessionId, DataDescriptorIf dataDesc, CustomerSearchIf customerSearch)
          All wish lists matching the search criteria will be returned.
protected  void setWishListCriteriaWithStandardAttributes(KKCriteria c)
          Common code to avoid duplication
protected  void setWishListItemCriteriaWithStandardAttributes(KKCriteria c)
          Common code to avoid duplication
 void updateWishListItemQuantityBought(int wishListItemId, int quantityBought)
          Updates the wishListItem quantity received attribute by adding quantityBought to the actual value.
 
Methods inherited from class com.konakart.bl.BaseMgr
addInsertAttr, addInsertAttr, checkRequired, getAdminEngMgr, getBasketMgr, getBillingMgr, getBookableProductMgr, getCatMgr, getConfigMgr, getCookieMgr, getCurrMgr, getCustMgr, getCustomerIdFromSession, getCustomerStatsMgr, getCustomerTagMgr, getEmailMgr, getEng, getLangMgr, getManuMgr, getMiscItemMgr, getMode, getModeString, getMqMgr, getMultiStoreMgr, getNewCriteria, getNewCriteria, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, getTemplate, getTemplateRoot, getVelocityContextMgr, getWishListMgr, init, isEnterprise, isMultiStoreShareCustomers, isMultiStoreShareProducts
 
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

Constructor Detail

WishListMgr

public WishListMgr(KKEngIf eng)
            throws java.lang.Exception
Constructor

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

createWishList

public int createWishList(java.lang.String sessionId,
                          WishListIf wishList)
                   throws java.lang.Exception
Create a wish list from a WishList object. Once created, the method getWishListWithItems() can be called to add wish list items to the wish list. The compulsory attributes for the WishListItem are:

Specified by:
createWishList in interface WishListMgrIf
Parameters:
sessionId -
wishList -
Returns:
Returns the id of the new WishList object
Throws:
java.lang.Exception

createWishListWithOptions

public int createWishListWithOptions(java.lang.String sessionId,
                                     WishListIf wishList,
                                     AddToWishListOptionsIf options)
                              throws java.lang.Exception
Create a wish list from a WishList object. Once created, the method getWishListWithItems() can be called to add wish list items to the wish list. This method may be called even when a customer isn't logged in. In this case the customerId attribute of the options object must be set to the id of the temporary customer which is negative. The compulsory attributes for the WishListItem are:

Specified by:
createWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId -
wishList -
options -
Returns:
Returns the id of the new WishList object
Throws:
java.lang.Exception

editWishList

public void editWishList(java.lang.String sessionId,
                         WishListIf wishList)
                  throws java.lang.Exception
Edit an existing wish list object. A check is made that the wish list actually belongs to the user referenced by the session id.

Specified by:
editWishList in interface WishListMgrIf
Parameters:
sessionId -
wishList -
Throws:
java.lang.Exception

editWishListWithOptions

public void editWishListWithOptions(java.lang.String sessionId,
                                    WishListIf wishList,
                                    AddToWishListOptionsIf options)
                             throws java.lang.Exception
Edit an existing wish list object. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. A check is made that the wish list actually belongs to the user referenced by the session id or customer id.

Specified by:
editWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user
wishList - The wish list to be edited
options -
Throws:
java.lang.Exception

addToWishList

public int addToWishList(java.lang.String sessionId,
                         WishListItemIf wishListItem)
                  throws java.lang.Exception
Add a WishListItem object to the wish list referenced by wishListId. If the wish list doesn't belong to the logged in customer, an exception is thrown. If the WishListItem already exists, then it is updated.
The compulsory attributes for the WishListItem are: The WishListItem may also contain an array of options if these are applicable for the chosen product.

Specified by:
addToWishList in interface WishListMgrIf
Parameters:
sessionId -
wishListItem -
Returns:
Returns the id of the new wishListItem object
Throws:
java.lang.Exception

addToWishListWithOptions

public int addToWishListWithOptions(java.lang.String sessionId,
                                    WishListItemIf wishListItem,
                                    AddToWishListOptionsIf options)
                             throws java.lang.Exception
Add a WishListItem object to the wish list referenced by wishListId. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. If the wish list doesn't belong to the logged in customer or the customer referenced by the customer id, an exception is thrown. If the WishListItem already exists, then it is updated.
The compulsory attributes for the WishListItem are: The WishListItem may also contain an array of options if these are applicable for the chosen product. If options is set to null, this method is identical to addToWishList(). Otherwise the functionality differs depending on the combination of options set.

Specified by:
addToWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId -
wishListItem -
options -
Returns:
Returns the id of the new wishListItem object
Throws:
java.lang.Exception

removeFromWishList

public void removeFromWishList(java.lang.String sessionId,
                               int wishListItemId)
                        throws java.lang.Exception
Remove the WishListItem object referenced by wishListItemId. The WishListItem will only be deleted if the wish list belongs to the logged in customer. If the wish list does not belong to the customer referenced by the sessionId, an exception will be thrown.

Specified by:
removeFromWishList in interface WishListMgrIf
Parameters:
sessionId -
wishListItemId -
Throws:
java.lang.Exception

removeFromWishListWithOptions

public void removeFromWishListWithOptions(java.lang.String sessionId,
                                          int wishListItemId,
                                          AddToWishListOptionsIf options)
                                   throws java.lang.Exception
Remove the WishListItem object referenced by wishListItemId. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. The WishListItem will only be deleted if the wish list belongs to the logged in customer or the customer referenced by the customer id. If the wish list does not belong to the customer referenced by the sessionId or customer id, an exception will be thrown.

Specified by:
removeFromWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId -
wishListItemId -
options -
Throws:
java.lang.Exception

deleteWishList

public void deleteWishList(java.lang.String sessionId,
                           int wishListId)
                    throws java.lang.Exception
The wish list referenced by wishListId and all of the items contained by the wish list, will be deleted. An exception will be thrown if the wish list does not belong to the logged in customer.

Specified by:
deleteWishList in interface WishListMgrIf
Parameters:
sessionId -
wishListId -
Throws:
java.lang.Exception

deleteWishListWithOptions

public void deleteWishListWithOptions(java.lang.String sessionId,
                                      int wishListId,
                                      AddToWishListOptionsIf options)
                               throws java.lang.Exception
The wish list referenced by wishListId and all of the items contained by the wish list, will be deleted. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. The WishListItem will only be deleted if the wish list belongs to the logged in customer or the customer referenced by the customer id. An exception will be thrown if the wish list does not belong to the logged in customer or customer referenced by customerId.

Specified by:
deleteWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId -
wishListId -
options -
Throws:
java.lang.Exception

mergeWishListsWithOptions

public void mergeWishListsWithOptions(java.lang.String sessionId,
                                      int customerFromId,
                                      int languageId,
                                      AddToWishListOptionsIf options)
                               throws java.lang.Exception
Add all items from the wish list of customerFrom to the wish list of customerTo which is retrieved from the sessionId. This is done when a customer logs in, to move his temporary wish list to his permanent wish list.

The currently logged in customer may have more than one wish list. The one used is the first one found of listType == 0.

Specified by:
mergeWishListsWithOptions in interface WishListMgrIf
Parameters:
sessionId -
customerFromId -
languageId -
options -
Throws:
java.lang.Exception

searchForWishLists

public WishLists searchForWishLists(java.lang.String sessionId,
                                    DataDescriptorIf dataDesc,
                                    CustomerSearchIf customerSearch)
                             throws java.lang.Exception
All wish lists matching the search criteria will be returned. They will be grouped by customerId. Note that in order to retrieve the wish list items, you must call the getWishListWithItems() method, passing it the id of the wish list. This will also populate the final price attributes of the wish list.
If customerSearch is null, then only the wish lists of the logged in customer will be returned. If dataDesc is set to null, a default DataDescriptor will be used.
Only the following attributes of the CustomerSearchIf object will be used: The custom fields of the dataDesc object will also be used in the search if not set to null.

Specified by:
searchForWishLists in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user. It may be null if the user isn't logged in.
dataDesc -
customerSearch -
Returns:
Returns a WishListsIf object containing an array of wishList objects and paging information.
Throws:
java.lang.Exception

getCount

protected int getCount(org.apache.torque.util.Criteria c)
                throws org.apache.torque.TorqueException,
                       com.workingdogs.village.DataSetException
This method is mainly used for paging.

Parameters:
c -
Returns:
The number of records present in the database matching the given criteria
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getWishListWithItems

public WishList getWishListWithItems(java.lang.String sessionId,
                                     int wishListId,
                                     int languageId)
                              throws java.lang.Exception
Returns a fully populated WishList object that may contain an array of WishListItem objects. An exception will be thrown if the wish list doesn't belong to the logged in customer and is private.
Each WishListItem object will have a populated product attribute and populated opts attribute if the WishListItem contains options. The items will be ordered by priority with the highest priority first.

Specified by:
getWishListWithItems in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user. It may be null if the user isn't logged in.
wishListId -
languageId -
Returns:
Returns an array of WishListItem objects
Throws:
java.lang.Exception

getWishListWithItemsWithOptions

public WishList getWishListWithItemsWithOptions(java.lang.String sessionId,
                                                int wishListId,
                                                int languageId,
                                                AddToWishListOptionsIf options)
                                         throws java.lang.Exception
Returns a fully populated WishList object that may contain an array of WishListItem objects. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. An exception will be thrown if the wish list doesn't belong to the logged in customer or customer referenced by customer id, and is private.
Each WishListItem object will have a populated product attribute and populated opts attribute if the WishListItem contains options. The items will be ordered by priority with the highest priority first. If options is set to null, this method is identical to getWishListWithItems(). Otherwise the functionality differs depending on the combination of options set.

Specified by:
getWishListWithItemsWithOptions in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user. It may be null if the user isn't logged in.
wishListId -
languageId -
options -
Returns:
Returns an array of WishListItem objects
Throws:
java.lang.Exception

getWishListItemsWithOptions

public WishListItems getWishListItemsWithOptions(java.lang.String sessionId,
                                                 DataDescriptorIf dataDesc,
                                                 int wishListId,
                                                 int languageId,
                                                 AddToWishListOptionsIf options)
                                          throws java.lang.Exception
Returns a WishListItems object containing an array of items and the number of items returned. The DataDescriptor object can be user to sort and page the returned items. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. An exception will be thrown if the wish list doesn't belong to the logged in customer or customer referenced by customer id, and is private.
However, by setting the attributes of dataDesc, the following functionality may be controlled : If the onlyShowAvailable attribute of the options object is set, then the wish list items that have quantity received equal to quantity desired, are not returned.

Specified by:
getWishListItemsWithOptions in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user. It may be null if the user isn't logged in.
dataDesc -
wishListId -
languageId -
options -
Returns:
Returns a WishListItems objects
Throws:
java.lang.Exception

getWishListItems

public WishListItems getWishListItems(java.lang.String sessionId,
                                      DataDescriptorIf dataDesc,
                                      int wishListId,
                                      int languageId)
                               throws java.lang.Exception
Returns a WishListItems object containing an array of items and the number of items returned. The DataDescriptor object can be user to sort and page the returned items. An exception will be thrown if the wish list doesn't belong to the logged in customer and is private.
However, by setting the attributes of dataDesc, the following functionality may be controlled :

Specified by:
getWishListItems in interface WishListMgrIf
Parameters:
sessionId - The session id of the logged in user. It may be null if the user isn't logged in.
dataDesc -
wishListId -
languageId -
Returns:
Returns a WishListItems objects
Throws:
java.lang.Exception

getWishListWithItemsWithOptionsPrivate

protected com.konakart.bl.WishListMgr.WishListAndCriteria getWishListWithItemsWithOptionsPrivate(java.lang.String sessionId,
                                                                                                 DataDescriptorIf dataDesc,
                                                                                                 int wishListId,
                                                                                                 int languageId,
                                                                                                 AddToWishListOptionsIf options)
                                                                                          throws java.lang.Exception
Protected method to get wish list items for all cases

Parameters:
sessionId -
dataDesc -
wishListId -
languageId -
options -
Returns:
Returns a wish list object with a populated array of wish list items and a Criteria object that may be used to calculate the total count by callers of this method.
Throws:
java.lang.Exception

checkWishListItemOptions

protected void checkWishListItemOptions(WishListItem wli)
                                 throws java.lang.Exception
We may have the case where the wish list item object has an array of options that only have the id and value id set. If this is the case we need to populate them with the price so that the total can be calculated. Any option that is attached to the wish list, should also be present in the product, so here we get the fully populated option from the product and attach it to the wish list.

Parameters:
wli -
Throws:
java.lang.Exception

getWishListItemPerEncodedProductAndWishList

protected WishListItem getWishListItemPerEncodedProductAndWishList(int wishListId,
                                                                   java.lang.String encodedProduct)
                                                            throws org.apache.torque.TorqueException,
                                                                   com.workingdogs.village.DataSetException
This is used to see if a product that we are adding to the wish list already exists in it

Parameters:
wishListId -
encodedProduct -
Returns:
WishList Object
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

getWishList

public WishList getWishList(java.lang.String sessionId,
                            int wishListId)
                     throws java.lang.Exception
Get a wish list object for its id. The items are not populated. An exception is thrown if the wish list doesn't belong to the logged in customer and is private. Null is returned if the wish list doesn't exist.

Specified by:
getWishList in interface WishListMgrIf
Parameters:
sessionId -
wishListId -
Returns:
Return a WishList object
Throws:
java.lang.Exception

getWishListWithOptions

public WishList getWishListWithOptions(java.lang.String sessionId,
                                       int wishListId,
                                       AddToWishListOptionsIf options)
                                throws java.lang.Exception
Get a wish list object for its id. The items are not populated. The sessionId may be left null if a temporary customer id (negative number) is added to the options object. An exception will be thrown if the wish list doesn't belong to the logged in customer or customer referenced by customer id, and is private. Null is returned if the wish list doesn't exist.

Specified by:
getWishListWithOptions in interface WishListMgrIf
Parameters:
sessionId -
wishListId -
options -
Returns:
Return a WishList object
Throws:
java.lang.Exception

getWishList

public WishList getWishList(int wishListId)
                     throws org.apache.torque.TorqueException,
                            com.workingdogs.village.DataSetException
Get a wish list object for its id. The items are not populated. Null is returned if the wish list doesn't exist.

Specified by:
getWishList in interface WishListMgrIf
Parameters:
wishListId -
Returns:
Return a WishList object
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

populateWishListWithCustomerInfo

protected void populateWishListWithCustomerInfo(WishListIf wishList)
                                         throws java.lang.Exception
Populates the wish list object with information about the customer so that a customer can select a public wish list for a particular person. Only attributes set to null are populated. If not set to null, we use the data contained in the attribute.

Parameters:
wishList -
Throws:
java.lang.Exception

getWishListItem

protected WishListItem getWishListItem(int wishListItemId)
                                throws org.apache.torque.TorqueException,
                                       com.workingdogs.village.DataSetException
Get a wish list item object for its id.

Parameters:
wishListItemId -
Returns:
Returns a wish list item object
Throws:
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException

setWishListCriteriaWithStandardAttributes

protected void setWishListCriteriaWithStandardAttributes(KKCriteria c)
Common code to avoid duplication

Parameters:
c -

setWishListItemCriteriaWithStandardAttributes

protected void setWishListItemCriteriaWithStandardAttributes(KKCriteria c)
Common code to avoid duplication

Parameters:
c -

populateOptsForWishListItem

protected void populateOptsForWishListItem(WishListItem item,
                                           int priceId,
                                           int languageId,
                                           AddToWishListOptionsIf a2wOptions)
                                    throws java.lang.Exception
The kk_wishlist_item table contains a products_id field which is encoded like this : 1{4}3{3}6 which means product of id==1 with product_options of id==4 and product_options_values of id==3 followed by product_options of id==3 and product_options_values of id==6. We have to read this encoded field called encodedProduct and create an array of Options and then set the opts attribute and the productId attribute of the WishListItem object passed in.

Parameters:
item -
priceId -
languageId -
a2wOptions -
Throws:
java.lang.Exception

createFetchProductOptions

protected FetchProductOptionsIf createFetchProductOptions(AddToWishListOptionsIf options)
Creates a FetchProductOptions object from an AddToWishListOptions

Parameters:
options -
Returns:
Return a FetchProductOptions object

updateWishListItemQuantityBought

public void updateWishListItemQuantityBought(int wishListItemId,
                                             int quantityBought)
                                      throws java.lang.Exception
Updates the wishListItem quantity received attribute by adding quantityBought to the actual value.

Specified by:
updateWishListItemQuantityBought in interface WishListMgrIf
Parameters:
wishListItemId -
quantityBought -
Throws:
java.lang.Exception

manageDataDescriptor

protected void manageDataDescriptor(DataDescriptorIf dataDesc,
                                    org.apache.torque.util.Criteria c)
Provides common code to deal with the management of the DataDescriptor

Parameters:
dataDesc -
c -

getCustomerId

protected int getCustomerId(java.lang.String sessionId,
                            int customerId)
                     throws java.lang.Exception
If the sessionId is null, we check the customerId to ensure that it is negative. If it is negative, this means that it is a non registered customer or a customer that hasn't logged in yet and so there is no customer mapped to the session id. Otherwise we ensure that the sessionId is valid and we don't use the customerId because we get the id from the session.

Parameters:
sessionId -
customerId -
Returns:
Returns the customerId that should be used by the caller
Throws:
java.lang.Exception


Copyright © 2011 DS Data Systems UK Ltd.