com.konakart.bl
Class BookableProductMgr

java.lang.Object
  extended by com.konakart.bl.BaseMgr
      extended by com.konakart.bl.BookableProductMgr
All Implemented Interfaces:
BookableProductMgrIf

public class BookableProductMgr
extends BaseMgr
implements BookableProductMgrIf

The manager for bookable products


Nested Class Summary
protected  class BookableProductMgr.TimeSlot
          protected class used to store a start and end time
 
Field Summary
protected static int LIMIT
           
protected static org.apache.commons.logging.Log log
          the log
 
Fields inherited from class com.konakart.bl.BaseMgr
templateBaseDir
 
Constructor Summary
BookableProductMgr(KKEngIf eng)
          Constructor
 
Method Summary
protected  boolean doTimeSlotsOverlap(BookableProductMgr.TimeSlot ts1, BookableProductMgr.TimeSlot ts2)
          Returns true if the two time slots overlap
 BookableProductIf getBookableProduct(int productId, BookableProductOptionsIf options)
          Gets a Bookable Product object for a product id
 Product[] getBookableProductConflict(java.lang.String sessionId, ProductIf bookableProd, BookableProductOptionsIf options)
          This method checks to see whether the bookable product passed in as a parameter conflicts with any bookable products that the customer identified by the sessionId has already signed up for.
If no conflicts are found, null is returned.
protected  Bookings getBookingsPerCustomer(int customerId, DataDescriptorIf dataDesc)
          Get an array of bookings for a logged in customer.
 Bookings getBookingsPerCustomer(java.lang.String sessionId, DataDescriptorIf dataDesc, BookableProductOptionsIf options)
          Get an array of bookings for a logged in customer.
 Bookings getBookingsPerProduct(DataDescriptorIf dataDesc, int productId, BookableProductOptionsIf options)
          Get an array of bookings for a product.
protected  int getCount(org.apache.torque.util.Criteria c)
          This method is mainly used for paging.
protected  int getTimeInMins(java.lang.String timeStr)
          Calculates a time in minutes from a time representation in the format 00:13 or 12:45 etc.
protected  java.util.ArrayList<BookableProductMgr.TimeSlot> getTimeSlots(java.lang.String times)
          Returns an array of times slots from times encoded in a string in the format 10:45;11:30 15:00;16:00 where the delimiter between start and end is ";" and between times is a space
protected  java.util.ArrayList<BookableProductMgr.TimeSlot>[] getWeeklySchedule(ProductIf bookableProd)
          Returns an array 7 elements long where each element is for a day of the week.
 int insertBooking(BookingIf booking, BookableProductOptionsIf options)
          Inserts a Booking object into the database.
 int insertBooking(java.lang.String sessionId, BookingIf booking, BookableProductOptionsIf options)
          Inserts a Booking object into the database.
protected  void manageDataDescriptor(DataDescriptorIf dataDesc, org.apache.torque.util.Criteria c)
          Add constraints and order by criteria
protected  void setBookableProductCriteriaWithStandardAttributes(KKCriteria c)
          Set the standard attributes
protected  void setBookingCriteriaWithStandardAttributes(KKCriteria c)
          Set the standard attributes
protected  void validateBooking(BookingIf booking, BookableProductOptionsIf options)
          Validate the booking
 
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


LIMIT

protected static final int LIMIT
See Also:
Constant Field Values
Constructor Detail

BookableProductMgr

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

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

getBookingsPerProduct

public Bookings getBookingsPerProduct(DataDescriptorIf dataDesc,
                                      int productId,
                                      BookableProductOptionsIf options)
                               throws com.workingdogs.village.DataSetException,
                                      org.apache.torque.TorqueException,
                                      KKException
Get an array of bookings for a product. The DatDescriptor object may be used to add constraints on the custom fields and to add order by criteria. The following OrderBy criteria are implemented:

Specified by:
getBookingsPerProduct in interface BookableProductMgrIf
Parameters:
dataDesc -
productId -
options - Not used at the moment. May be left null.
Returns:
Returns a Bookings object
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

getBookingsPerCustomer

public Bookings getBookingsPerCustomer(java.lang.String sessionId,
                                       DataDescriptorIf dataDesc,
                                       BookableProductOptionsIf options)
                                throws java.lang.Exception
Get an array of bookings for a logged in customer. The DatDescriptor object may be used to add constraints on the custom fields and to add order by criteria. The following OrderBy criteria are implemented:

Specified by:
getBookingsPerCustomer in interface BookableProductMgrIf
Parameters:
dataDesc -
sessionId -
options - Not used at the moment. May be left null.
Returns:
Returns a Bookings object
Throws:
java.lang.Exception

getBookingsPerCustomer

protected Bookings getBookingsPerCustomer(int customerId,
                                          DataDescriptorIf dataDesc)
                                   throws java.lang.Exception
Get an array of bookings for a logged in customer. The DatDescriptor object may be used to add constraints on the custom fields and to add order by criteria. The following OrderBy criteria are implemented:

Parameters:
dataDesc -
customerId -
Returns:
Returns a Bookings object
Throws:
java.lang.Exception

setBookingCriteriaWithStandardAttributes

protected void setBookingCriteriaWithStandardAttributes(KKCriteria c)
Set the standard attributes

Parameters:
c -

manageDataDescriptor

protected void manageDataDescriptor(DataDescriptorIf dataDesc,
                                    org.apache.torque.util.Criteria c)
Add constraints and order by criteria

Parameters:
dataDesc -
c -

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

insertBooking

public int insertBooking(BookingIf booking,
                         BookableProductOptionsIf options)
                  throws java.lang.Exception
Inserts a Booking object into the database. The object must be associated with an existing product through the product id attribute.

Specified by:
insertBooking in interface BookableProductMgrIf
Parameters:
booking - A booking object
options - Options allowing an exception to be thrown for exceeding the maximum number of bookings
Returns:
Returns the id of the inserted object
Throws:
java.lang.Exception

insertBooking

public int insertBooking(java.lang.String sessionId,
                         BookingIf booking,
                         BookableProductOptionsIf options)
                  throws java.lang.Exception
Inserts a Booking object into the database. The customer must be logged in with a valid session id. The id of the logged in customer is written into the customerId attribute of the Booking object before it is saved. The object must be associated with an existing product through the product id attribute.

Specified by:
insertBooking in interface BookableProductMgrIf
Parameters:
sessionId -
booking - A booking object
options - Options allowing an exception to be thrown for exceeding the maximum number of bookings
Returns:
Returns the id of the inserted object
Throws:
java.lang.Exception

validateBooking

protected void validateBooking(BookingIf booking,
                               BookableProductOptionsIf options)
                        throws java.lang.Exception
Validate the booking

Parameters:
booking -
options -
Throws:
java.lang.Exception

getBookableProduct

public BookableProductIf getBookableProduct(int productId,
                                            BookableProductOptionsIf options)
                                     throws com.workingdogs.village.DataSetException,
                                            org.apache.torque.TorqueException,
                                            KKException
Gets a Bookable Product object for a product id

Specified by:
getBookableProduct in interface BookableProductMgrIf
Parameters:
productId -
options - Not used at the moment. May be left null.
Returns:
Returns a Bookable Product object
Throws:
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
KKException

setBookableProductCriteriaWithStandardAttributes

protected void setBookableProductCriteriaWithStandardAttributes(KKCriteria c)
Set the standard attributes

Parameters:
c -

getBookableProductConflict

public Product[] getBookableProductConflict(java.lang.String sessionId,
                                            ProductIf bookableProd,
                                            BookableProductOptionsIf options)
                                     throws java.lang.Exception
This method checks to see whether the bookable product passed in as a parameter conflicts with any bookable products that the customer identified by the sessionId has already signed up for.
If no conflicts are found, null is returned. If a conflict is found then an array of conflicting bookable products is returned.

Specified by:
getBookableProductConflict in interface BookableProductMgrIf
Parameters:
sessionId -
bookableProd -
options - Not used at the moment. May be left null.
Returns:
Returns null for no conflict. Otherwise an array of conflicting products is returned.
Throws:
java.lang.Exception

doTimeSlotsOverlap

protected boolean doTimeSlotsOverlap(BookableProductMgr.TimeSlot ts1,
                                     BookableProductMgr.TimeSlot ts2)
Returns true if the two time slots overlap

Parameters:
ts1 -
ts2 -
Returns:
Returns true if the two time slots overlap

getWeeklySchedule

protected java.util.ArrayList<BookableProductMgr.TimeSlot>[] getWeeklySchedule(ProductIf bookableProd)
                                                                        throws KKException
Returns an array 7 elements long where each element is for a day of the week. Each element may contain an arrayList containing time slots for that day.

Parameters:
bookableProd -
Returns:
returns the weekly schedule (see above)
Throws:
KKException

getTimeSlots

protected java.util.ArrayList<BookableProductMgr.TimeSlot> getTimeSlots(java.lang.String times)
                                                                 throws KKException
Returns an array of times slots from times encoded in a string in the format 10:45;11:30 15:00;16:00 where the delimiter between start and end is ";" and between times is a space

Parameters:
times -
Returns:
Returns a list of TimeSlot objects
Throws:
KKException

getTimeInMins

protected int getTimeInMins(java.lang.String timeStr)
                     throws KKException
Calculates a time in minutes from a time representation in the format 00:13 or 12:45 etc.

Parameters:
timeStr -
Returns:
Returns the time in minutes
Throws:
KKException


Copyright © 2011 DS Data Systems UK Ltd.