com.konakart.bl
Class CustomerTagMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.CustomerTagMgr
All Implemented Interfaces:
CustomerTagMgrIf

public class CustomerTagMgr
extends BaseMgr
implements CustomerTagMgrIf

Manager for customer tags


Field Summary
protected static org.apache.commons.logging.Log log
          the log
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
CustomerTagMgr(KKEngIf eng)
          Constructor
 
Method Summary
 void addToCustomerTag(int customerId, java.lang.String tagName, int tagValue)
          Look at addToCustomerTag(String sessionId, String tagName, int tagValue)
 void addToCustomerTag(java.lang.String sessionId, java.lang.String tagName, int tagValue)
          This method is used for customer tags where the value is of type com.konakart.app.CustomerTag.MULTI_INT_TYPE.
 void addToCustomerTagForGuest(int customerId, java.lang.String tagName, int tagValue)
          Look at addToCustomerTag(String sessionId, String tagName, int tagValue)
protected  void checkNegativeCustId(int customerId)
          Utility method used to check that the customer id is negative.
 void deleteCustomerTag(int customerId, java.lang.String tagName)
          Look at deleteCustomerTag(String sessionId, String tagName)
 void deleteCustomerTag(java.lang.String sessionId, java.lang.String tagName)
          This method deletes the customer tag referenced by the parameter tagName and for the customer referenced by the sessionId.
 void deleteCustomerTagForGuest(int customerId, java.lang.String tagName)
          Look at deleteCustomerTag(String sessionId, String tagName)
 boolean evaluateExpression(int customerId, int expressionId, java.lang.String expressionName)
          Look at evaluateExpression(String sessionId, int expressionId, String expressionName)
 boolean evaluateExpression(java.lang.String sessionId, int expressionId, java.lang.String expressionName)
          An expression object is retrieved from the database and evaluated for the customer referenced by the sessionId.
 boolean evaluateExpressionForGuest(int customerId, int expressionId, java.lang.String expressionName)
          Look at evaluateExpression(String sessionId, int expressionId, String expressionName)
protected  CustomerTag getCustomerTag(int customerId, java.lang.String tagName, boolean getValue)
          Look at getCustomerTag(String sessionId, String tagName)
 CustomerTagIf getCustomerTag(java.lang.String sessionId, java.lang.String tagName)
          A CustomerTag object referenced by the parameter tagName is returned.
 CustomerTagIf getCustomerTagForGuest(int customerId, java.lang.String tagName)
          Look at getCustomerTag(String sessionId, String tagName)
protected  CustomerTagIf[] getCustomerTags(int customerId)
          Look at getCustomerTags(String sessionId)
 CustomerTagIf[] getCustomerTags(java.lang.String sessionId)
          This method fetches all of the customer tags for the customer referenced by the sessionId.
An empty array is returned if no tags exist.
 CustomerTagIf[] getCustomerTagsForGuest(int customerId)
          Look at getCustomerTags(String sessionId)
 java.lang.String getCustomerTagValue(int customerId, java.lang.String tagName)
          Look at getCustomerTagValue(String sessionId, String tagName)
 java.lang.String getCustomerTagValue(java.lang.String sessionId, java.lang.String tagName)
          A string is returned containing the value of the customer tag referenced by the parameter tagName and for the customer referenced by the sessionId.
 java.lang.String getCustomerTagValueForGuest(int customerId, java.lang.String tagName)
          Look at getCustomerTagValue(String sessionId, String tagName)
 ExpressionIf getExpression(int customerId, int expressionId, java.lang.String expressionName)
          Look at getExpression(String sessionId, int expressionId, String expressionName)
 ExpressionIf getExpression(java.lang.String sessionId, int expressionId, java.lang.String expressionName)
          An Expression object, fully populated with an array of Expression Variables is returned.
 ExpressionIf getExpressionForGuest(int customerId, int expressionId, java.lang.String expressionName)
          Look at getExpression(String sessionId, int expressionId, String expressionName)
protected  void insertCustomerTag(int customerId, CustomerTagIf tag)
          Look at insertCustomerTag(String sessionId, CustomerTagIf tag)
 void insertCustomerTag(java.lang.String sessionId, CustomerTagIf tag)
          Assigns a customer tag to the customer referenced by the sessionId.
 void insertCustomerTagForGuest(int customerId, CustomerTagIf tag)
          Look at insertCustomerTag(String sessionId, CustomerTagIf tag)
protected  void setExpressionCriteriaWithStandardAttributes(KKCriteria c)
          Common code to avoid duplication which sets up the standard attributes for Expressions on the criteria object
protected  void setExpressionVariableCriteriaWithStandardAttributes(KKCriteria c, int customerId, boolean getValue)
          Common code to avoid duplication which sets up the standard attributes for Expression Variables on the criteria object
protected  void setTagCriteriaWithStandardAttributes(KKCriteria c, int customerId, boolean getValue)
          Common code to avoid duplication which sets up the standard attributes for Tags on the criteria object
protected  void updateNumVariables(int ExpressionId, int numVariables)
          Update the number of variables attribute for the Expression
 
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

CustomerTagMgr

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

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

evaluateExpression

public boolean evaluateExpression(java.lang.String sessionId,
                                  int expressionId,
                                  java.lang.String expressionName)
                           throws java.lang.Exception
An expression object is retrieved from the database and evaluated for the customer referenced by the sessionId. If the expressionName parameter is not set to null, then the Expression is searched for by name. Otherwise it is searched for by the id contained in the expressionId parameter.

Specified by:
evaluateExpression in interface CustomerTagMgrIf
Parameters:
sessionId -
expressionId -
expressionName -
Returns:
Returns true or false
Throws:
java.lang.Exception

evaluateExpressionForGuest

public boolean evaluateExpressionForGuest(int customerId,
                                          int expressionId,
                                          java.lang.String expressionName)
                                   throws java.lang.Exception
Look at evaluateExpression(String sessionId, int expressionId, String expressionName)

Specified by:
evaluateExpressionForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
expressionId -
expressionName -
Returns:
Returns true or false
Throws:
java.lang.Exception

evaluateExpression

public boolean evaluateExpression(int customerId,
                                  int expressionId,
                                  java.lang.String expressionName)
                           throws java.lang.Exception
Look at evaluateExpression(String sessionId, int expressionId, String expressionName)

Parameters:
customerId -
expressionId -
expressionName -
Returns:
Returns true or false
Throws:
java.lang.Exception

getExpression

public ExpressionIf getExpression(java.lang.String sessionId,
                                  int expressionId,
                                  java.lang.String expressionName)
                           throws java.lang.Exception
An Expression object, fully populated with an array of Expression Variables is returned. If the expressionName parameter is not set to null, then the Expression is searched for by name. Otherwise it is searched for by the id contained in the expressionId parameter. If the sessionId parameter is null we get the expression variables without any customer tag values. Otherwise the expression variables will be populated with the customer tag values for the customer referenced by sessionId. other

Specified by:
getExpression in interface CustomerTagMgrIf
Parameters:
sessionId -
expressionId -
expressionName -
Returns:
Returns a fully populated Expression object
Throws:
java.lang.Exception

getExpressionForGuest

public ExpressionIf getExpressionForGuest(int customerId,
                                          int expressionId,
                                          java.lang.String expressionName)
                                   throws java.lang.Exception
Look at getExpression(String sessionId, int expressionId, String expressionName)

Specified by:
getExpressionForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
expressionId -
expressionName -
Returns:
Returns a fully populated Expression object
Throws:
java.lang.Exception

getExpression

public ExpressionIf getExpression(int customerId,
                                  int expressionId,
                                  java.lang.String expressionName)
                           throws java.lang.Exception
Look at getExpression(String sessionId, int expressionId, String expressionName)

Specified by:
getExpression in interface CustomerTagMgrIf
Parameters:
customerId -
expressionId -
expressionName -
Returns:
Returns a fully populated Expression object
Throws:
java.lang.Exception

updateNumVariables

protected void updateNumVariables(int ExpressionId,
                                  int numVariables)
                           throws org.apache.torque.TorqueException,
                                  KKException
Update the number of variables attribute for the Expression

Parameters:
ExpressionId -
numVariables -
Throws:
org.apache.torque.TorqueException
KKException

insertCustomerTag

public void insertCustomerTag(java.lang.String sessionId,
                              CustomerTagIf tag)
                       throws java.lang.Exception
Assigns a customer tag to the customer referenced by the sessionId. If a tag already exists with this name, then the value is replaced with the new value. The compulsory tag fields are:

Note that a customer tag with name tag.getName() must exist in the database since it is used to validate tag.getValue().

Specified by:
insertCustomerTag in interface CustomerTagMgrIf
Parameters:
sessionId -
tag -
Throws:
java.lang.Exception

insertCustomerTagForGuest

public void insertCustomerTagForGuest(int customerId,
                                      CustomerTagIf tag)
                               throws java.lang.Exception
Look at insertCustomerTag(String sessionId, CustomerTagIf tag)

Specified by:
insertCustomerTagForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
tag -
Throws:
java.lang.Exception

insertCustomerTag

protected void insertCustomerTag(int customerId,
                                 CustomerTagIf tag)
                          throws java.lang.Exception
Look at insertCustomerTag(String sessionId, CustomerTagIf tag)

Parameters:
customerId -
tag -
Throws:
java.lang.Exception

addToCustomerTag

public void addToCustomerTag(java.lang.String sessionId,
                             java.lang.String tagName,
                             int tagValue)
                      throws java.lang.Exception
This method is used for customer tags where the value is of type com.konakart.app.CustomerTag.MULTI_INT_TYPE. This customer tag type is used to store a series of integers and is useful for cases where you want to store information such as the last 5 product ids that a customer looked at.

If the customer tag doesn't yet exist for the customer referenced by the sessionId, then a new customer tag is added with the value in the tagValue parameter. Otherwise the new value is added. When the number of integers stored reaches the maximum value defined for the customer tag, then the new value is added and the oldest value is removed.

Specified by:
addToCustomerTag in interface CustomerTagMgrIf
Parameters:
sessionId -
tagName -
tagValue -
Throws:
java.lang.Exception

addToCustomerTagForGuest

public void addToCustomerTagForGuest(int customerId,
                                     java.lang.String tagName,
                                     int tagValue)
                              throws java.lang.Exception
Look at addToCustomerTag(String sessionId, String tagName, int tagValue)

Specified by:
addToCustomerTagForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
tagName -
tagValue -
Throws:
java.lang.Exception

addToCustomerTag

public void addToCustomerTag(int customerId,
                             java.lang.String tagName,
                             int tagValue)
                      throws java.lang.Exception
Look at addToCustomerTag(String sessionId, String tagName, int tagValue)

Parameters:
customerId -
tagName -
tagValue -
Throws:
java.lang.Exception

getCustomerTag

public CustomerTagIf getCustomerTag(java.lang.String sessionId,
                                    java.lang.String tagName)
                             throws java.lang.Exception
A CustomerTag object referenced by the parameter tagName is returned. The value attribute of the tag is populated for the customer referenced by the sessionId. If sessionId is set to null, then a customer tag object with a null value is returned. The CustomerTag object contains utility methods to convert the tag string into its original type (i.e. Date, boolean, int etc.).

Specified by:
getCustomerTag in interface CustomerTagMgrIf
Parameters:
sessionId -
tagName -
Returns:
Returns a CustomerTag object, populated with the value.
Throws:
java.lang.Exception

getCustomerTagForGuest

public CustomerTagIf getCustomerTagForGuest(int customerId,
                                            java.lang.String tagName)
                                     throws java.lang.Exception
Look at getCustomerTag(String sessionId, String tagName)

Specified by:
getCustomerTagForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
tagName -
Returns:
Returns a CustomerTag object, populated with the value.
Throws:
java.lang.Exception

getCustomerTag

protected CustomerTag getCustomerTag(int customerId,
                                     java.lang.String tagName,
                                     boolean getValue)
                              throws com.workingdogs.village.DataSetException,
                                     org.apache.torque.TorqueException,
                                     KKException
Look at getCustomerTag(String sessionId, String tagName)

Parameters:
customerId -
tagName -
getValue - When true, we attempt to get the value of the tag
Returns:
Returns a CustomerTag object
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getCustomerTagValue

public java.lang.String getCustomerTagValue(java.lang.String sessionId,
                                            java.lang.String tagName)
                                     throws java.lang.Exception
A string is returned containing the value of the customer tag referenced by the parameter tagName and for the customer referenced by the sessionId. This method is faster than the getCustomerTag method, but the actual CustomerTag object isn't available to convert the String into a more usable form such as boolean or date.

Specified by:
getCustomerTagValue in interface CustomerTagMgrIf
Parameters:
sessionId -
tagName -
Returns:
Returns a string containing the tag value
Throws:
java.lang.Exception

getCustomerTagValueForGuest

public java.lang.String getCustomerTagValueForGuest(int customerId,
                                                    java.lang.String tagName)
                                             throws java.lang.Exception
Look at getCustomerTagValue(String sessionId, String tagName)

Specified by:
getCustomerTagValueForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
tagName -
Returns:
Returns a string containing the tag value
Throws:
java.lang.Exception

getCustomerTagValue

public java.lang.String getCustomerTagValue(int customerId,
                                            java.lang.String tagName)
                                     throws java.lang.Exception
Look at getCustomerTagValue(String sessionId, String tagName)

Parameters:
customerId -
tagName -
Returns:
Returns a string containing the tag value
Throws:
java.lang.Exception

deleteCustomerTag

public void deleteCustomerTag(java.lang.String sessionId,
                              java.lang.String tagName)
                       throws java.lang.Exception
This method deletes the customer tag referenced by the parameter tagName and for the customer referenced by the sessionId.

Specified by:
deleteCustomerTag in interface CustomerTagMgrIf
Parameters:
sessionId -
tagName -
Throws:
java.lang.Exception

deleteCustomerTagForGuest

public void deleteCustomerTagForGuest(int customerId,
                                      java.lang.String tagName)
                               throws java.lang.Exception
Look at deleteCustomerTag(String sessionId, String tagName)

Specified by:
deleteCustomerTagForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
tagName -
Throws:
java.lang.Exception

deleteCustomerTag

public void deleteCustomerTag(int customerId,
                              java.lang.String tagName)
                       throws java.lang.Exception
Look at deleteCustomerTag(String sessionId, String tagName)

Parameters:
customerId -
tagName -
Throws:
java.lang.Exception

getCustomerTags

public CustomerTagIf[] getCustomerTags(java.lang.String sessionId)
                                throws java.lang.Exception
This method fetches all of the customer tags for the customer referenced by the sessionId.
An empty array is returned if no tags exist.

Specified by:
getCustomerTags in interface CustomerTagMgrIf
Parameters:
sessionId -
Returns:
Returns an array of CustomerTag objects
Throws:
java.lang.Exception

getCustomerTagsForGuest

public CustomerTagIf[] getCustomerTagsForGuest(int customerId)
                                        throws java.lang.Exception
Look at getCustomerTags(String sessionId)

Specified by:
getCustomerTagsForGuest in interface CustomerTagMgrIf
Parameters:
customerId -
Returns:
Returns an array of CustomerTag objects
Throws:
java.lang.Exception

getCustomerTags

protected CustomerTagIf[] getCustomerTags(int customerId)
                                   throws java.lang.Exception
Look at getCustomerTags(String sessionId)

Parameters:
customerId -
Returns:
Returns an array of CustomerTag objects
Throws:
java.lang.Exception

setTagCriteriaWithStandardAttributes

protected void setTagCriteriaWithStandardAttributes(KKCriteria c,
                                                    int customerId,
                                                    boolean getValue)
Common code to avoid duplication which sets up the standard attributes for Tags on the criteria object

Parameters:
c - criteria object
customerId - customer Id
getValue - when true join with customer to tag table to get value

setExpressionCriteriaWithStandardAttributes

protected void setExpressionCriteriaWithStandardAttributes(KKCriteria c)
Common code to avoid duplication which sets up the standard attributes for Expressions on the criteria object

Parameters:
c - criteria object

setExpressionVariableCriteriaWithStandardAttributes

protected void setExpressionVariableCriteriaWithStandardAttributes(KKCriteria c,
                                                                   int customerId,
                                                                   boolean getValue)
Common code to avoid duplication which sets up the standard attributes for Expression Variables on the criteria object

Parameters:
c - criteria object
customerId - customer Id
getValue - when true join with customer to tag table to get value

checkNegativeCustId

protected void checkNegativeCustId(int customerId)
                            throws KKException
Utility method used to check that the customer id is negative.

Parameters:
customerId -
Throws:
KKException


Copyright © 2011 DS Data Systems UK Ltd.