com.elasticpath.sfweb.ajax.bean.impl
Class CartItemBeanImpl

java.lang.Object
  extended by com.elasticpath.sfweb.ajax.bean.impl.CartItemBeanImpl
All Implemented Interfaces:
EpDomain, Persistence, CartItem, ValueObject, CartItemBean, java.io.Serializable

public class CartItemBeanImpl
extends java.lang.Object
implements CartItemBean

A wrapper class for cart items sent through dwr.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Serial version id.
 
Constructor Summary
CartItemBeanImpl(CartItem cartItem, java.util.Currency currency, java.util.Locale locale)
          Creates a new dwr CartItemBean wrapper for a CartItem.
 
Method Summary
 void addDependentCartItem(CartItem dependentCartItem)
          Specify that another cart item depends on this cart item.
 void applyDiscount(java.math.BigDecimal amount)
          Adds a discount amount to this cart item.
 void clearDiscount()
          Removes previously applied CartItem discounts.
 void executeBeforePersistAction()
          Interceptor to perform tasks before persisting changes.
 java.math.BigDecimal getAmount(java.util.Currency currency)
          Get the total price of this shopping cart item.
 Money getAmountMoney(java.util.Currency currency)
          Get the amount as a Money object.
 CartItem getCartItem()
           
 java.util.Currency getCurrency()
           
 java.util.Set getDependentCartItems()
          Get the set of dependent cart items.
 java.lang.String getDisplayName()
          Convenience method for getting the product's localized display name.
 ElasticPath getElasticPath()
          Get the ElasticPath singleton.
 boolean getHasDependentCartItems()
          Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.
 java.lang.String getListPrice()
          Convenience method for getting the ProductSku list price.
 java.util.Locale getLocale()
           
 java.lang.String getLowestPrice()
          Convenience method for getting the lowest ProductSku price.
 CartItem getParentCartItem()
          Get the parent cart item that this cart item is dependent on.
 long getParentCartItemUidPk()
          Get the uidPk of the parent cart item that this cart item is dependent on.
 java.lang.String getProductBrandName()
          Convenience method for getting the product's seo url.
 java.lang.String getProductSeoUrl()
          Convenience method for getting the product's seo url.
 ProductSku getProductSku()
          Get the product SKU corresponding to this item in a cart.
 int getQuantity()
          Get the quantity of this item as a primitive int.
 java.lang.String getSavings()
          Convenience method for getting the amount of money saved.
 java.lang.String getTotalPrice()
          Convenience method for getting the amount without needing to pass in the currency.
 java.lang.String getType()
          Get the type of action, i.e.
 long getUidPk()
          Gets the unique identifier for the cart item object.
 boolean hasDependentCartItem(java.lang.String skuCode)
          Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.
 boolean hasDependentCartItems()
          Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.
 boolean hasSufficientInventory()
          Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).
 boolean isDependent()
          Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.
 boolean isLowestLessThanList()
          Convenience method for checking if item is on sale.
 boolean isPersistent()
          True if the cart item has previously been persisted.
 void setCurrency(java.util.Currency currency)
           
 void setDefaultValues()
          Set default values for those fields that need default values.
 void setDependentCartItems(java.util.Set dependentCartItems)
          Set the set of dependent cart items.
 void setElasticPath(ElasticPath elasticpath)
          Inject the ElasticPath singleton.
 void setLocale(java.util.Locale locale)
           
 void setParentCartItem(CartItem parentCartItem)
          Set the parent cart item that this cart item is dependent on.
 void setProductSku(ProductSku productSku)
          Set the product SKU corresponding to this item in a cart.
 void setQuantity(int quantity)
          Set the quantity of this item as a primitive int.
 void setType(java.lang.String type)
          Set the type of action.
 void setUidPk(long uidPk)
          Sets the unique identifier for the cart item object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Serial version id.

See Also:
Constant Field Values
Constructor Detail

CartItemBeanImpl

public CartItemBeanImpl(CartItem cartItem,
                        java.util.Currency currency,
                        java.util.Locale locale)
Creates a new dwr CartItemBean wrapper for a CartItem.

Parameters:
cartItem - the cart item to be wrapped
currency - the current currency
locale - the current locale
Method Detail

addDependentCartItem

public void addDependentCartItem(CartItem dependentCartItem)
Specify that another cart item depends on this cart item.

Specified by:
addDependentCartItem in interface CartItem
Parameters:
dependentCartItem - the other, dependent cart item

applyDiscount

public void applyDiscount(java.math.BigDecimal amount)
Adds a discount amount to this cart item. This will be subtracted from the amount of the CartItem and each invocation adds to the discount.

Specified by:
applyDiscount in interface CartItem
Parameters:
amount - the amount to discount

clearDiscount

public void clearDiscount()
Removes previously applied CartItem discounts.

Specified by:
clearDiscount in interface CartItem

executeBeforePersistAction

public void executeBeforePersistAction()
Interceptor to perform tasks before persisting changes.

Specified by:
executeBeforePersistAction in interface Persistence

getAmount

public java.math.BigDecimal getAmount(java.util.Currency currency)
Get the total price of this shopping cart item. The total price is the price * quantity - discount. The sale price is used in the calculation.

Specified by:
getAmount in interface CartItem
Parameters:
currency - the currency of the total price to be returned
Returns:
a BigDecimal object representing the total price

getAmountMoney

public Money getAmountMoney(java.util.Currency currency)
Get the amount as a Money object.

Specified by:
getAmountMoney in interface CartItem
Parameters:
currency - the currency of the total price to be returned
Returns:
a Money object representing the total price

getCartItem

public CartItem getCartItem()
Specified by:
getCartItem in interface CartItemBean
Returns:
the cart item

getCurrency

public java.util.Currency getCurrency()
Specified by:
getCurrency in interface CartItemBean
Returns:
the currency

getDependentCartItems

public java.util.Set getDependentCartItems()
Get the set of dependent cart items.

Specified by:
getDependentCartItems in interface CartItem
Returns:
the set of dependent cart items.

getDisplayName

public java.lang.String getDisplayName()
Convenience method for getting the product's localized display name.

Specified by:
getDisplayName in interface CartItemBean
Returns:
the localized product name

getElasticPath

public ElasticPath getElasticPath()
Get the ElasticPath singleton.

Specified by:
getElasticPath in interface EpDomain
Returns:
elasticpath the ElasticPath singleton.

getHasDependentCartItems

public boolean getHasDependentCartItems()
Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.

Specified by:
getHasDependentCartItems in interface CartItemBean
Returns:
true if this CartItem has other cart items that depend on it.

getListPrice

public java.lang.String getListPrice()
Convenience method for getting the ProductSku list price. Originally created for dwr One Page integration.

Specified by:
getListPrice in interface CartItemBean
Returns:
the String object representing the list price

getLocale

public java.util.Locale getLocale()
Specified by:
getLocale in interface CartItemBean
Returns:
the locale

getLowestPrice

public java.lang.String getLowestPrice()
Convenience method for getting the lowest ProductSku price. Originally created for dwr One Page integration.

Specified by:
getLowestPrice in interface CartItemBean
Returns:
the String object representing the lowest price

getParentCartItem

public CartItem getParentCartItem()
Get the parent cart item that this cart item is dependent on. Returns null if this cart item does not depend on another.

Specified by:
getParentCartItem in interface CartItem
Returns:
the parent cart item or null if there is no parent.

getParentCartItemUidPk

public long getParentCartItemUidPk()
Get the uidPk of the parent cart item that this cart item is dependent on. Returns 0 if this cart item does not depend on another.

Specified by:
getParentCartItemUidPk in interface CartItemBean
Returns:
the uidPk of the parent cart item or 0 if there is no parent.

getProductBrandName

public java.lang.String getProductBrandName()
Convenience method for getting the product's seo url. Originally created for dwr One Page integration.

Specified by:
getProductBrandName in interface CartItemBean
Returns:
the seo url string

getProductSeoUrl

public java.lang.String getProductSeoUrl()
Convenience method for getting the product's seo url. Originally created for dwr One Page integration.

Specified by:
getProductSeoUrl in interface CartItemBean
Returns:
the seo url string

getProductSku

public ProductSku getProductSku()
Get the product SKU corresponding to this item in a cart.

Specified by:
getProductSku in interface CartItem
Returns:
a ProductSKU

getQuantity

public int getQuantity()
Get the quantity of this item as a primitive int. Required by Spring Validatr.

Specified by:
getQuantity in interface CartItem
Returns:
the quantity

getSavings

public java.lang.String getSavings()
Convenience method for getting the amount of money saved. Originally created for dwr One Page integration.

Specified by:
getSavings in interface CartItemBean
Returns:
the String object representing the amount of money saved

getTotalPrice

public java.lang.String getTotalPrice()
Convenience method for getting the amount without needing to pass in the currency. Originally created for dwr One Page integration.

Specified by:
getTotalPrice in interface CartItemBean
Returns:
the String object representing the amount

getType

public java.lang.String getType()
Description copied from interface: CartItem
Get the type of action, i.e. cartItem, wishListItem etc. Make sure it matches the bean id in spring configuration for the implementation of an action.

Specified by:
getType in interface CartItem
Returns:
the cart item type

getUidPk

public long getUidPk()
Gets the unique identifier for the cart item object.

Specified by:
getUidPk in interface Persistence
Returns:
the unique identifier.

hasDependentCartItem

public boolean hasDependentCartItem(java.lang.String skuCode)
Returns true if this CartItem has another cart items that depend on it which matches the supplied skuCode.

Specified by:
hasDependentCartItem in interface CartItem
Parameters:
skuCode - The GUID of the particular dependant SKU to be in the cart.
Returns:
true if this CartItem has a depenant item that matches the supplied skuCode

hasDependentCartItems

public boolean hasDependentCartItems()
Returns true if this CartItem has other cart items that depend on it such that the dependent items cannot exist in the cart on their own.

Specified by:
hasDependentCartItems in interface CartItem
Returns:
true if this CartItem has other cart items that depend on it.

hasSufficientInventory

public boolean hasSufficientInventory()
Returns true if there is sufficent stock to sell this cart item (in the quantity set in the CartItem).

Specified by:
hasSufficientInventory in interface CartItem
Returns:
true if there is sufficient stock

isDependent

public boolean isDependent()
Returns true if this CartItem depends on another cart item such that it can't exist in the cart on its own.

Specified by:
isDependent in interface CartItem
Returns:
true if this CartItem depends on another cart item.

isLowestLessThanList

public boolean isLowestLessThanList()
Convenience method for checking if item is on sale. Originally created for dwr One Page integration.

Specified by:
isLowestLessThanList in interface CartItemBean
Returns:
is item is on sale or not

isPersistent

public boolean isPersistent()
True if the cart item has previously been persisted.

Specified by:
isPersistent in interface Persistence
Returns:
true if the cart item has previously been persisted.

setCurrency

public void setCurrency(java.util.Currency currency)
Specified by:
setCurrency in interface CartItemBean
Parameters:
currency - the currency to set

setDefaultValues

public void setDefaultValues()
Set default values for those fields that need default values.

Specified by:
setDefaultValues in interface Persistence

setDependentCartItems

public void setDependentCartItems(java.util.Set dependentCartItems)
Set the set of dependent cart items.

Specified by:
setDependentCartItems in interface CartItem
Parameters:
dependentCartItems - the set of dependent cart items.

setElasticPath

public void setElasticPath(ElasticPath elasticpath)
Inject the ElasticPath singleton.

Specified by:
setElasticPath in interface EpDomain
Parameters:
elasticpath - the ElasticPath singleton.

setLocale

public void setLocale(java.util.Locale locale)
Specified by:
setLocale in interface CartItemBean
Parameters:
locale - the locale to set

setParentCartItem

public void setParentCartItem(CartItem parentCartItem)
Set the parent cart item that this cart item is dependent on.

Specified by:
setParentCartItem in interface CartItem
Parameters:
parentCartItem - the parent cart item.

setProductSku

public void setProductSku(ProductSku productSku)
Set the product SKU corresponding to this item in a cart.

Specified by:
setProductSku in interface CartItem
Parameters:
productSku - the ProductSKU

setQuantity

public void setQuantity(int quantity)
Set the quantity of this item as a primitive int. Required by Spring Validator.

Specified by:
setQuantity in interface CartItem
Parameters:
quantity - the quantity

setType

public void setType(java.lang.String type)
Description copied from interface: CartItem
Set the type of action.

Specified by:
setType in interface CartItem
Parameters:
type - the cart item type

setUidPk

public void setUidPk(long uidPk)
Sets the unique identifier for the cart item object.

Specified by:
setUidPk in interface Persistence
Parameters:
uidPk - the new unique identifier.