Class BaseShippingProcessor

All Implemented Interfaces:
BusinessObject, BusinessProcessor, ShippingProcessor
Direct Known Subclasses:
BasicShippingProcessor, FedExShippingProcessor, UPSShippingProcessor, USPSShippingProcessor

public abstract class BaseShippingProcessor extends BaseBusinessProcessor implements ShippingProcessor
Abstract class that provides methods useful for ShippingProcessor implementations.
Author:
David Tobey
  • Field Details

    • log

      static org.apache.commons.logging.Log log
    • shippingOption

      private String shippingOption
    • availableOptions

      private Collection availableOptions
    • dropShipperIDs

      public Collection dropShipperIDs
    • dropShippers

      public Collection dropShippers
    • currentDropShipperID

      public Integer currentDropShipperID
  • Constructor Details

    • BaseShippingProcessor

      public BaseShippingProcessor()
  • Method Details

    • getShippingOption

      public String getShippingOption()
    • setShippingOption

      public void setShippingOption(String string)
    • getAvailableOptions

      public Collection getAvailableOptions()
    • setAvailableOptions

      public void setAvailableOptions(Collection availableOptions)
    • loadShippingOptions

      public Collection loadShippingOptions(Map argument) throws Exception
      Description copied from interface: ShippingProcessor
      Load the shipping options related to this ShippingProcessor.

      Shipping options might include, for example, ground, 2-day air, bulk, etc.

      The Collection returned should be a collection of Map objects that must include the following keys:

      • code: A unique String code for the shipping option under this shipping processor. E.g., "GROUND".
      • name: The String name of the shipping option for diplay to users. E.g., "Ground".
      • price: The formatted price for the shipping option represented as a String and including currency formatting, for display to the user.
      • priceDouble: The raw price for the shipping option represented as a Double.
      Specified by:
      loadShippingOptions in interface ShippingProcessor
      Parameters:
      argument - A Map containing information from the current request.
      Returns:
      A Collection of Map objects that contain the code, name, and price for each shipping option related to this ShippingProcessor.
      Throws:
      Exception
    • loadShippingOptions

      public abstract Collection loadShippingOptions() throws Exception
      Throws:
      Exception
    • processShipping

      public abstract int processShipping() throws Exception
      Throws:
      Exception
    • processShipping

      public Map processShipping(Map parameters) throws Exception
      Assists with processing of shipping charges. Copies the incoming Map of parameters to this BaseShippingProcessor instance and calls processShipping() followed by updateTotalsAndStatuses() to update the order's totals. Finally, writes the new totals to the database using OrderGatewayDAO.updateOrderAndDelivery(boolean, com.softslate.commerce.businessobjects.order.Order, com.softslate.commerce.businessobjects.order.OrderDelivery).
      Specified by:
      processShipping in interface ShippingProcessor
      Parameters:
      parameters - A Map containing the shipping infofmation submitted by the user. It should contain a key named shippingOption that contains the code of the shipping option selected by the user.
      Returns:
      A Map containing a least one key named "resultCode", which contains a String parsable into an integer, representing the results of the processing. 0 for the resultCode indicates success, anything else indicates an error and that processing should stop.
      Throws:
      Exception
    • verifyOption

      public boolean verifyOption()
      Verifies that the option the user selected is allowed by checking it against the Collection of avialable options.
      Returns:
      true, if the option the user selected is allowed.
    • updateOrderWithOption

      public void updateOrderWithOption()
      Sets the option the user selected in the user's order, by default in the order delivery's status details field.
    • updateOrderWithOptionPrice

      public void updateOrderWithOptionPrice()
      Sets the shipping price in the order based on the option the user selected.
    • updateOrderDeliveryAddressIfPickUp

      protected void updateOrderDeliveryAddressIfPickUp()
    • updateTotalsAndStatuses

      public void updateTotalsAndStatuses() throws Exception
      Updates the totals and statuses of a user's order with a new shipping charge included. The user's Order and that order's first OrderDelivery are updated with new price totals, and subtotals.
      Throws:
      Exception
    • updateTotalsAndStatusesInDatabase

      public void updateTotalsAndStatusesInDatabase() throws Exception
      Throws:
      Exception
    • retrieveDropShippersFromOrder

      public Collection retrieveDropShippersFromOrder(Order order) throws Exception
      Returns a Collection of Manufacturer objects associated with the order items in the given order, whose "isDropShipper" flag is set to true. Used by shipping processors such as the UPS processor to query for rates separately for each drop shipper.
      Parameters:
      order -
      Returns:
      A Collection of Manufacturer objects associated with the order items in the given order, whose "isDropShipper" flag is set to true
      Throws:
      Exception
    • isPackageOkToCreate

      public boolean isPackageOkToCreate(OrderShippingRule osr)
    • findPackageWeight

      public Double findPackageWeight(OrderShippingRule osr)
    • mergeRates

      public Collection mergeRates(Collection mergedRates, Collection rates)
    • doEstimatedDeliveryDateWithShipDateToday

      public String doEstimatedDeliveryDateWithShipDateToday(Integer deliveryDays)
    • doEstimatedDeliveryDate

      public String doEstimatedDeliveryDate(Calendar shipDate, Integer deliveryDays)
    • formatDeliveryDate

      protected String formatDeliveryDate(Calendar shipDate)
    • pushPastWeekendsAndHolidays

      protected Calendar pushPastWeekendsAndHolidays(Calendar shipDate)
    • isBlackedOutHoliday

      protected boolean isBlackedOutHoliday(Calendar c)
    • orderHasGiftCertificatesOnly

      public boolean orderHasGiftCertificatesOnly(Order order)