atg.commerce.pricing
Class WeightRangeShippingCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.ShippingCalculatorImpl
              extended by atg.commerce.pricing.DoubleRangeShippingCalculator
                  extended by atg.commerce.pricing.WeightRangeShippingCalculator
All Implemented Interfaces:
ShippingPricingCalculator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class WeightRangeShippingCalculator
extends DoubleRangeShippingCalculator

This calculator will calculate shipping costs based upon the total weight of the items in a shipping group. So, the total weight of a shipping group will be calculated, then the range of weight values will be consulted to determine the cost. If the property addAmount is true then instead of setting the price quote amount to the value of the amount property, the calculator adds the amount to the current amount in the price quote. This can be used to configure a "surcharge" calculator, which increases the shipping price.

The shippingMethod property should be set to the name of a particular delivery process. For example: UPS Ground, UPS 2-day or UPS Next Day.

If the ignoreShippingMethod property is true, then this calculator does not expose a shipping method name (through getAvailableMethods). In addition this calculator will always attempt to perform pricing. This option is available if the user is not given a choice of different shipping methods.

See Also:
DoubleRangeShippingCalculator

Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.commerce.pricing.DoubleRangeShippingCalculator
mAmounts, MAX_VALUE_KEY, mHighRanges, mLowRanges, TOKEN
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
WeightRangeShippingCalculator()
           
 
Method Summary
 OrderManager getOrderManager()
          Return the OrderManager property.
protected  double getQuantity(ShippingGroupCommerceItemRelationship pCommerceItemRelationship)
          Get the quantity of a particular item that are being shipped by this this shipping group.
protected  double getRangeComparisonValue(Order pOrder, ShippingGroup pShippingGroup)
          Get the value that will be used in the range comparison.
protected  double getRangeComparisonValue(ShippingGroup pShippingGroup)
          Deprecated.  
protected  double getWeight(CommerceItem pCommerceItem)
          Responsible for getting the weight associated with an instance of a commerce item.
 java.lang.String getWeightProperty()
          Return the weightProperty property.
protected  double getWeightTotal(ShippingGroup pShippingGroup)
          Calculate the total weight of the items being shipped to the specified ShippingGroup.
 void setOrderManager(OrderManager pOrderManager)
          Set the OrderManager property.
 void setWeightProperty(java.lang.String pWeightProperty)
          Set the weightProperty property.
 
Methods inherited from class atg.commerce.pricing.DoubleRangeShippingCalculator
doStartService, getAmount, getRanges, initializeRanges, setRanges
 
Methods inherited from class atg.commerce.pricing.ShippingCalculatorImpl
getAmount, getAvailableMethods, getPricingTools, getShippingMethod, haveItemsToShip, isAddAmount, isIgnoreShippingMethod, performPricing, priceShippingGroup, priceShippingPriceInfo, resetShippingPriceInfo, setAddAmount, setIgnoreShippingMethod, setPricingTools, setShippingMethod
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

WeightRangeShippingCalculator

public WeightRangeShippingCalculator()
Method Detail

setWeightProperty

public void setWeightProperty(java.lang.String pWeightProperty)
Set the weightProperty property.


getWeightProperty

public java.lang.String getWeightProperty()
Return the weightProperty property.


setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Set the OrderManager property.


getOrderManager

public OrderManager getOrderManager()
Return the OrderManager property.


getRangeComparisonValue

protected double getRangeComparisonValue(ShippingGroup pShippingGroup)
                                  throws PricingException
Deprecated. 

Get the value that will be used in the range comparison. Make a call to getWeightTotal to actually compute the total.

Specified by:
getRangeComparisonValue in class DoubleRangeShippingCalculator
Parameters:
pShippingGroup - the shipping group
Returns:
the total weight
Throws:
PricingException - if an error occurs

getRangeComparisonValue

protected double getRangeComparisonValue(Order pOrder,
                                         ShippingGroup pShippingGroup)
                                  throws PricingException
Get the value that will be used in the range comparison. Make a call to getWeightTotal to actually compute the total.

Overrides:
getRangeComparisonValue in class DoubleRangeShippingCalculator
Parameters:
pShippingGroup - the shipping group
Returns:
the total weight
Throws:
PricingException - if an error occurs

getWeightTotal

protected double getWeightTotal(ShippingGroup pShippingGroup)
                         throws PricingException
Calculate the total weight of the items being shipped to the specified ShippingGroup. Iterate through all the items being shipped and extract out the number of items being shipped and each items weight. This it added to the running total of weight.

getWeight is called to extract the weight for each item.

Parameters:
pShippingGroup - a value of type 'ShippingGroup'
Returns:
a value of type 'double'
Throws:
PricingException

getWeight

protected double getWeight(CommerceItem pCommerceItem)
                    throws PricingException
Responsible for getting the weight associated with an instance of a commerce item. This is performed by getting the CatalogRef object from auxiliaryData object and extracting the property named by mWeightProperty out of it. This is returned.

This method can be overriden if the weight is to be obtained from another location.

Parameters:
pCommerceItem - the commerce item whose weight is to be extracted
Returns:
the weight of a single item
Throws:
PricingException

getQuantity

protected double getQuantity(ShippingGroupCommerceItemRelationship pCommerceItemRelationship)
Get the quantity of a particular item that are being shipped by this this shipping group. There are two cases that are accounted for. Either the Relationship is one of RelationshipTypes.SHIPPINGQUANTITY or its one of RelationshipTypes.SHIPPINGQUANTITYREMAINING. The quantity is extracted from the correct place and returned as a double.

Parameters:
pCommerceItemRelationship - a value of type 'CommerceItemRelationship'
Returns:
a value of type 'double'