com.konakart.al
Class ReviewMgr

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

public class ReviewMgr
extends BaseMgr

Contains methods to read and write product reviews.


Field Summary
 
Fields inherited from class com.konakart.al.BaseMgr
eng, kkAppEng, log
 
Constructor Summary
protected ReviewMgr(com.konakart.appif.KKEngIf eng, KKAppEng kkAppEng)
          Constructor
 
Method Summary
 int fetchAllReviews()
          The reviews are fetched from the engine and put in the currentReviews array.
 void fetchRandomReviewDetails()
          For the case of the random review, it exists in the randomReviews array.
 void fetchReviewDetails(int revId)
          Sets selectedReview by finding it within the currentReviews array.
 int fetchReviewsPerProduct(int prodId)
          The reviews are fetched from the engine and put in the currentReviews array.
 int getCurrentOffset()
          Returns the currentOffset in the review array.
 com.konakart.appif.ReviewIf[] getCurrentReviews()
          Returns an array of currentReviews.
 int getMaxRows()
          Maximum number of reviews to show in a list.
 java.lang.String getNavBack()
          Static string - navigate backwards.
 java.lang.String getNavNext()
          Static string - navigate forwards.
 java.lang.String getNavStart()
          Static string - navigate to the start.
 int getNumberOfReviews()
          Returns the number of reviews currently retrieved.
 int getNumRandomReviews()
          Returns the number of random reviews
 ExtendedReview getRandomReview()
          Pick out a review at random, by indexing the randomReviewArray with a counter that increments by 1 every time the function is called.
 com.konakart.appif.ReviewIf getSelectedReview()
          Returns the selectedReview.
 int getShowBack()
          Show the back button if set to 1.
 int getShowNext()
          Show the next button if set to 1.
 int getTotalNumberOfReviews()
          Returns the totalNumberOfReviews.
 void navigateCurrentReviews(java.lang.String navDir, boolean all)
          This method is called to navigate through a list of reviews when the list is longer than maxRows.
navDir can take the following values which are retrieved using getter methods on the ReviewMgr instance: getNavNext() getNavBack() getNavStart()
 void refreshCaches()
          Refreshes the Random review list.
 void refreshConfigs()
          Refresh the configuration variables.
 void reset()
          Puts the ReviewContainer object back into it's original state with no reviews selected.
 java.lang.String truncateDesc(java.lang.String desc, int wordLength, int stringLength)
          Format the description in order to truncate it and to split up very long words which could ruin the page formatting.
 int writeReview(java.lang.String reviewText, int rating, int customerId)
          Save a review in the database.
 
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

ReviewMgr

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

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

refreshConfigs

public void refreshConfigs()
                    throws com.konakart.app.KKException
Refresh the configuration variables. This is called automatically at a regular interval.

Throws:
com.konakart.app.KKException

reset

public void reset()
           throws com.konakart.app.KKException
Puts the ReviewContainer object back into it's original state with no reviews selected.

Throws:
com.konakart.app.KKException

refreshCaches

public void refreshCaches()
                   throws com.konakart.app.KKException
Refreshes the Random review list.

Throws:
com.konakart.app.KKException

fetchReviewsPerProduct

public int fetchReviewsPerProduct(int prodId)
                           throws com.konakart.app.KKException,
                                  KKAppException
The reviews are fetched from the engine and put in the currentReviews array.

Parameters:
prodId - The id of the product for which we are fetching reviews
Returns:
The number of reviews retrieved
Throws:
com.konakart.app.KKException
KKAppException

fetchAllReviews

public int fetchAllReviews()
                    throws com.konakart.app.KKException,
                           KKAppException
The reviews are fetched from the engine and put in the currentReviews array.

Returns:
The number of reviews retrieved
Throws:
com.konakart.app.KKException
KKAppException

navigateCurrentReviews

public void navigateCurrentReviews(java.lang.String navDir,
                                   boolean all)
                            throws com.konakart.app.KKException,
                                   KKAppException
This method is called to navigate through a list of reviews when the list is longer than maxRows.
navDir can take the following values which are retrieved using getter methods on the ReviewMgr instance:

Parameters:
navDir - The navigation direction
all - If set to true, it gets all reviews and doesn't filter them by product
Throws:
com.konakart.app.KKException
KKAppException

fetchReviewDetails

public void fetchReviewDetails(int revId)
                        throws com.konakart.app.KKException,
                               KKAppException
Sets selectedReview by finding it within the currentReviews array. It throws an exception if the review cannot be found.

Parameters:
revId - The id of the selected review
Throws:
com.konakart.app.KKException
KKAppException

fetchRandomReviewDetails

public void fetchRandomReviewDetails()
                              throws com.konakart.app.KKException,
                                     KKAppException
For the case of the random review, it exists in the randomReviews array. We need to get it, look up the product and set selected product and selectedReview.

Throws:
com.konakart.app.KKException
KKAppException

getRandomReview

public ExtendedReview getRandomReview()
Pick out a review at random, by indexing the randomReviewArray with a counter that increments by 1 every time the function is called. When the counter exceeds the size of the array, it is reset.

Returns:
Return a random review

getNumRandomReviews

public int getNumRandomReviews()
Returns the number of random reviews

Returns:
Returns the number of random reviews

truncateDesc

public java.lang.String truncateDesc(java.lang.String desc,
                                     int wordLength,
                                     int stringLength)
Format the description in order to truncate it and to split up very long words which could ruin the page formatting. If stringLength is set to zero, then it only truncates long words and doesn't truncate the string

Parameters:
desc - The description to be formatted
wordLength - The maximum word length
stringLength - The maximum string length
Returns:
Return a truncated description

getNumberOfReviews

public int getNumberOfReviews()
Returns the number of reviews currently retrieved.

Returns:
Returns the number of reviews currently retrieved.

writeReview

public int writeReview(java.lang.String reviewText,
                       int rating,
                       int customerId)
                throws com.konakart.app.KKException
Save a review in the database.

Parameters:
reviewText - the text to put into the review
rating - the rating for the review
customerId - id of the customer writing the review
Returns:
returns the id of the review that was created
Throws:
com.konakart.app.KKException

getCurrentOffset

public int getCurrentOffset()
Returns the currentOffset in the review array.

Returns:
Returns the currentOffset.

getCurrentReviews

public com.konakart.appif.ReviewIf[] getCurrentReviews()
Returns an array of currentReviews.

Returns:
Returns the currentReviews.

getMaxRows

public int getMaxRows()
Maximum number of reviews to show in a list.

Returns:
Returns the maxRows.

getShowBack

public int getShowBack()
Show the back button if set to 1. Don't show the back button if set to 0.

Returns:
Returns the showBack.

getShowNext

public int getShowNext()
Show the next button if set to 1. Don't show the next button if set to 0.

Returns:
Returns the showNext.

getSelectedReview

public com.konakart.appif.ReviewIf getSelectedReview()
Returns the selectedReview.

Returns:
Returns the selectedReview.

getNavBack

public java.lang.String getNavBack()
Static string - navigate backwards. It is the string required to pass to the navigateCurrentReviews() as the navdir attribute when navigating backwards.

Returns:
Returns the navBack.

getNavNext

public java.lang.String getNavNext()
Static string - navigate forwards. It is the string required to pass to the navigateCurrentReviews() as the navdir attribute when navigating forwards.

Returns:
Returns the navNext.

getNavStart

public java.lang.String getNavStart()
Static string - navigate to the start. It is the string required to pass to the navigateCurrentReviews() as the navdir attribute when navigating to the start.

Returns:
Returns the navStart.

getTotalNumberOfReviews

public int getTotalNumberOfReviews()
Returns the totalNumberOfReviews.

Returns:
Returns the totalNumberOfReviews.


Copyright © 2006 DS Data Systems UK Ltd.