com.konakart.al
Class CustomerMgr

java.lang.Object
  extended by com.konakart.al.BaseMgr
      extended by com.konakart.al.CustomerMgr

public class CustomerMgr
extends BaseMgr

Contains methods to manage customer details and login / logout.


Field Summary
 
Fields inherited from class com.konakart.al.BaseMgr
eng, kkAppEng, log
 
Constructor Summary
protected CustomerMgr(com.konakart.appif.KKEngIf eng, KKAppEng kkAppEng)
          Constructor
 
Method Summary
 int addAddressToCustomer(com.konakart.appif.AddressIf addr)
          Call the engine to create a new customer address which is added to the addresses of the current customer.
 void addProductNotificationsToCustomer(int productId)
          Add the product notification to the currently logged in customer.
 void changePassword(java.lang.String currentPassword, java.lang.String newPassword)
          Calls the engine to change the current password with the new one.
protected  void createGuest()
          We create a customer object for a guest.
 void deleteAddressFromCustomer(int addrId)
          Call the engine to delete the customer address.
 void deleteProductNotificationsFromCustomer(int productId)
          Delete the product notification from the customer's list of notifications.
 void editCustomer(com.konakart.appif.CustomerIf cust)
          Calls the engine to update the customer data with the data passed in as a parameter.
 void editCustomerAddress(com.konakart.appif.AddressIf addr)
          Call the engine to edit the customer address.
 void emptyZonesForRegistration()
          Empties the zonesForRegistration array so that the UI doesn't use it.
 void fetchProductNotificationsPerCustomer()
          Fetch the product notifications for a customer and language and set them on the customer object.
 void fetchZonesForRegistration(int countryId)
          Fetch the zones for the given country.
 com.konakart.appif.CustomerIf getCurrentCustomer()
          Returns the current customer.
 com.konakart.appif.AddressIf getSelectedAddr()
          Returns the currently selected address.
 com.konakart.appif.ZoneIf[] getZonesForRegistration()
          The array of zone objects is normally used during the customer registration process or when adding / editing customer addresses.
 java.lang.String login(java.lang.String emailAddr, java.lang.String password)
          Login and if successful, set the current customer object.
 java.lang.String loginByAdmin(java.lang.String adminSession, int customerId)
          Login for the customer identified by customerId and if successful, set the current customer object.
 void logout()
          Log-off and reset some variables.
 com.konakart.appif.CustomerIf populateCurrentCustomerAddresses(boolean force)
          Ensures that the currentCustomer object has his default address and array of addresses populated
 void refreshCustomerCachedData()
          Normally called after a login to get and cache customer relevant data such as the customer's basket, the customer's orders and the customer's order history.
 int registerCustomer(com.konakart.appif.CustomerRegistrationIf cr)
          Register a new customer.
 void sendNewPassword(java.lang.String emailAddr)
          Calls the engine to send a new password to the user.
 void setSelectedAddr(com.konakart.appif.AddressIf selectedAddr)
          Sets the selected address to the one passed in as a parameter.
 void setSelectedAddrFromId(int addrId)
          Ensures that the selectedAddr attribute is populated.
 
Methods inherited from class com.konakart.al.BaseMgr
getEng, getKkAppEng, setEng, setKkAppEng
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CustomerMgr

protected CustomerMgr(com.konakart.appif.KKEngIf eng,
                      KKAppEng kkAppEng)
               throws com.konakart.app.KKException
Constructor

Parameters:
eng -
kkAppEng -
Throws:
com.konakart.app.KKException
Method Detail

setSelectedAddrFromId

public void setSelectedAddrFromId(int addrId)
                           throws KKAppException
Ensures that the selectedAddr attribute is populated. The addrId should match the id of one of the addresses of the current customer.

Parameters:
addrId - Address Id of one of the addresses of the current customer
Throws:
KKAppException

editCustomerAddress

public void editCustomerAddress(com.konakart.appif.AddressIf addr)
                         throws com.konakart.app.KKException,
                                KKAppException
Call the engine to edit the customer address.

Parameters:
addr - The address object to be edited
Throws:
com.konakart.app.KKException
KKAppException

deleteAddressFromCustomer

public void deleteAddressFromCustomer(int addrId)
                               throws com.konakart.app.KKException,
                                      KKAppException
Call the engine to delete the customer address.

Parameters:
addrId - The address Id of the address to be deleted.
Throws:
com.konakart.app.KKException
KKAppException

addAddressToCustomer

public int addAddressToCustomer(com.konakart.appif.AddressIf addr)
                         throws com.konakart.app.KKException,
                                KKAppException
Call the engine to create a new customer address which is added to the addresses of the current customer.

Parameters:
addr - The address to be added
Returns:
Returns the id of the address object
Throws:
com.konakart.app.KKException
KKAppException

getSelectedAddr

public com.konakart.appif.AddressIf getSelectedAddr()
Returns the currently selected address.

Returns:
Returns the selectedAddr.

setSelectedAddr

public void setSelectedAddr(com.konakart.appif.AddressIf selectedAddr)
Sets the selected address to the one passed in as a parameter.

Parameters:
selectedAddr - The selectedAddr to set.

fetchProductNotificationsPerCustomer

public void fetchProductNotificationsPerCustomer()
                                          throws com.konakart.app.KKException
Fetch the product notifications for a customer and language and set them on the customer object. Each item has a product object which isn't however fully populated. We set an empty array rather than null because an empty array indicates that there are no notifications rather than null, which indicates that we haven't read them from the DB yet.

Throws:
com.konakart.app.KKException

fetchZonesForRegistration

public void fetchZonesForRegistration(int countryId)
                               throws com.konakart.app.KKException
Fetch the zones for the given country. They are used by the customer when registering so that he can make a selection from a drop list. The zonesForRegistration attribute is set with the array of zones.

Parameters:
countryId - The id of the country for which we are setting the zones.
Throws:
com.konakart.app.KKException

emptyZonesForRegistration

public void emptyZonesForRegistration()
                               throws com.konakart.app.KKException
Empties the zonesForRegistration array so that the UI doesn't use it.

Throws:
com.konakart.app.KKException

addProductNotificationsToCustomer

public void addProductNotificationsToCustomer(int productId)
                                       throws com.konakart.app.KKException
Add the product notification to the currently logged in customer.

Parameters:
productId - The id of the product to be added
Throws:
com.konakart.app.KKException

deleteProductNotificationsFromCustomer

public void deleteProductNotificationsFromCustomer(int productId)
                                            throws com.konakart.app.KKException
Delete the product notification from the customer's list of notifications.

Parameters:
productId - The id of the product to be removed
Throws:
com.konakart.app.KKException

editCustomer

public void editCustomer(com.konakart.appif.CustomerIf cust)
                  throws com.konakart.app.KKException
Calls the engine to update the customer data with the data passed in as a parameter.

Parameters:
cust - The Customer object to be edited
Throws:
com.konakart.app.KKException

populateCurrentCustomerAddresses

public com.konakart.appif.CustomerIf populateCurrentCustomerAddresses(boolean force)
                                                               throws com.konakart.app.KKException,
                                                                      KKAppException
Ensures that the currentCustomer object has his default address and array of addresses populated

Parameters:
force - If set to true the addresses will be refreshed even if they already exist
Returns:
Returns the customer with populated addresses
Throws:
com.konakart.app.KKException
KKAppException

createGuest

protected void createGuest()
                    throws com.konakart.app.KKException
We create a customer object for a guest. We give it a negative id which will never be used by a real customer. The reason we do this is so we can reuse all for the logic for the customer cart even for a guest without having to create new logic in order to store a guest cart.

Throws:
com.konakart.app.KKException

getCurrentCustomer

public com.konakart.appif.CustomerIf getCurrentCustomer()
Returns the current customer. If the id of the current customer is negative, this means that the customer hasn't logged in yet and that it is a temporary object used so that the customer can still create basket items.

Returns:
Current Customer

registerCustomer

public int registerCustomer(com.konakart.appif.CustomerRegistrationIf cr)
                     throws com.konakart.app.KKException
Register a new customer.

Parameters:
cr - The CustomerRegistration object
Returns:
Returns the id of the new customer
Throws:
com.konakart.app.KKException

login

public java.lang.String login(java.lang.String emailAddr,
                              java.lang.String password)
                       throws com.konakart.app.KKException
Login and if successful, set the current customer object. If before login, the customer had placed items in the basket, these items are not lost once the customer logs in. The session id is returned but it is also stored by the client engine so that it is used automatically by the client engine when it has to communicate with the server engine.

Parameters:
emailAddr - The user id
password - The password
Returns:
Return the session id
Throws:
com.konakart.app.KKException

loginByAdmin

public java.lang.String loginByAdmin(java.lang.String adminSession,
                                     int customerId)
                              throws com.konakart.app.KKException
Login for the customer identified by customerId and if successful, set the current customer object. The session id is returned but it is also stored by the client engine so that it is used automatically by the client engine when it has to communicate with the server engine. The adminSession must be a valid session belonging to an administrator.

Parameters:
adminSession - Valid session belonging to an administrator
customerId - Id of the customer being logged in
Returns:
The session id
Throws:
com.konakart.app.KKException

refreshCustomerCachedData

public void refreshCustomerCachedData()
                               throws com.konakart.app.KKException
Normally called after a login to get and cache customer relevant data such as the customer's basket, the customer's orders and the customer's order history. If this method isn't called, then the UI will not show updated data.

Throws:
com.konakart.app.KKException

logout

public void logout()
            throws com.konakart.app.KKException
Log-off and reset some variables. A guest customer is created and becomes the current customer.

Throws:
com.konakart.app.KKException

changePassword

public void changePassword(java.lang.String currentPassword,
                           java.lang.String newPassword)
                    throws com.konakart.app.KKException
Calls the engine to change the current password with the new one.

Parameters:
currentPassword - The current password
newPassword - The new password
Throws:
com.konakart.app.KKException

sendNewPassword

public void sendNewPassword(java.lang.String emailAddr)
                     throws com.konakart.app.KKException
Calls the engine to send a new password to the user.

Parameters:
emailAddr - The email address where the new password will be sent
Throws:
com.konakart.app.KKException

getZonesForRegistration

public com.konakart.appif.ZoneIf[] getZonesForRegistration()
The array of zone objects is normally used during the customer registration process or when adding / editing customer addresses.

Returns:
Returns an array of Zone objects


Copyright © 2006 DS Data Systems UK Ltd.