ShoppingCartImpl Class

com.beasys.commerce.ebusiness.shoppingcart
ShoppingCartImpl Class

public class ShoppingCartImpl

    extends BelongingImpl
    implements ShoppingCart

The ShoppingCart is used to contain a list of ShoppingCartLines. The ShoppingCart also has a Customer associated with it so that it can calculate Customer dependent prices if necessary.

Related Topics

ShoppingCart
ShoppingCartHome


Hierarchy
Object
  BelongingImpl
    ShoppingCartImpl
All Implemented Interfaces

Belonging, BusinessSmartComponent, Cloneable, Comparable, RelationalReference, Serializable, ShoppingCart

Field Summary

public Money
shipping
  • Containment: By Value
  • Multiplicity: 1:1
public Collection
shoppingCartLines
The shopping cart contains a list of ShoppingCart lines
  • Containment: By Value
  • Multiplicity: 0:N
  • Interface: java.util.Collection
public Money
subtotal
Money
public Money
total
Money
   
Fields from  com.beasys.commerce.foundation.BelongingImpl
__classIdentifier, __containingBelonging, __containingEntity, __mapKey, __sequenceNumber, _isDirty
 

Constructor Summary

ShoppingCartImpl()

 

Method Summary

public void
addItemsFromShoppingCart(ShoppingCart items)
Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.
public ShoppingCartLine
addProductItem(ProductItem item, double quantity)
Add an Item to the ShoppingCart.
public ShoppingCartLine
addProductItem(ProductItem item, double quantity, Money unitPrice)
Add an Item to the ShoppingCart.
public boolean
addShoppingCartLine(ShoppingCartLine element)
Ensures that this collection contains the specified element (optional operation).
public boolean
addShoppingCartLineCollection(Collection collection)
Adds all of the elements in the specified collection to this collection (optional operation).
public void
clearShoppingCartLineCollection()
Removes all of the elements from this collection (optional operation).
public int
compareTo(Object o)
Compare this belonging to another
public boolean
containsShoppingCartLine(ShoppingCartLine element)
Returns true if this collection contains the specified element.
public boolean
containsShoppingCartLineCollection(Collection collection)
Returns true if this collection contains all of the elements in the specified collection.
public ShoppingCartLine
createShoppingCartLine()
Used internally by the ShoppingCart to create ShoppingCartLines.
public boolean
equalsShoppingCartLineCollection(Object object)
Compares the specified object with this collection for equality.
public ShoppingCartLine
findShoppingCartLine(String productIdentifier)
Find the ShoppingCartLine associated with the specified Item.
public double
getCategoryQuantity(String categoryId)
Count the number of product items that belong to a category Note This method creates/calls the CatalogManager and the ProductItemManager to resolve which items belong to what category!
public double
getNumberOfUnits()
Count the total quantity of items by summing the quantity on each line.
public ArrayList
getOrderDiscountPresentations()
Gets the order level discount list
public Money
getShipping()
Get the value of shipping
public ArrayList
getShippingDiscountPresentations()
Gets the shipping discount list
public Collection
getShoppingCartLineCollection()
Returns a deep copy of the entire collection
public Money
getSubtotal()
Get the value of subtotal
public Money
getTotal()
Get the value of total
public Money
getTotal(int totalType)
Gets the shopping cart total for the given total type
public Money
getTotalPrice()
Gets the overal shopping cart total
public String
interfaceName()
interfaceName() returns the unqualified name of the interface from the UML model
public boolean
isEmpty()
Returns true if the shopping cart has no items
public boolean
isShoppingCartLineCollectionEmpty()
Returns true if this collection contains no elements.
public void
removeAllProductItems()
Removes all ShoppingCartLines.
public ProductItem
removeProductItem(String productIdentifier)
Remove the ShoppingCartLine associated with the Item specified.
public boolean
removeShoppingCartLine(ShoppingCartLine element)
Removes a single instance of the specified element from this collection, if it is present (optional operation).
public boolean
removeShoppingCartLineCollection(Collection collection)
Removes all this collection's elements that are also contained in the specified collection (optional operation).
public boolean
retainShoppingCartLineCollection(Collection collection)
Retains only the elements in this collection that are contained in the specified collection (optional operation).
public void
setByValue(Belonging value)
It is possible to call set-by-value with a superclass.
public void
setOrderDiscountPresentations(ArrayList orderDiscountPresentations)
Sets the order level discount list
public void
setProductItemQuantity(ProductItem item, double quantity)
Sets the Quantity of the ShoppingCartLine associated with this Item.
public void
setShipping(Money shipping)
Set the value of shipping
public void
setShippingDiscountPresentations(ArrayList shippingDiscountPresentations)
Sets the shipping discount list
public void
setShoppingCartLineCollection(Collection collection)
Sets the entire collection
public void
setSubtotal(Money subtotal)
Set the value of subtotal
public void
setTotal(Money total)
Set the value of total
public int
shoppingCartLineCollectionHashCode()
Returns the hash code value for this collection.
public Iterator
shoppingCartLineCollectionIterator()
Returns an iterator over the elements in this collection.
public int
shoppingCartLineCollectionSize()
Returns the number of elements in this collection.
public Belonging
value()
value() is a more typesafe implementation of clone()
 
Methods from  com.beasys.commerce.foundation.BelongingImpl
clearRelationalBinding, clearRelationalBinding, clearRelationalBinding, clearRelationalBinding, clone, doRelationalBinding, doRelationalBinding, doRelationalBindingOnElement, doRelationalBindingOnElement, doRelationalBindingOnElement, doRelationalBindingOnSingleton, doRelationalBindingOnSingleton, doRelationalBindingOnSingleton, doRelationalBindingWithMapKey, doRelationalBindingWithMapKey, doRelationalBindingWithMapKey, enumerateRelationalBinding, enumerateRelationalBinding, equals, get__classIdentifier, get__containingBelonging, get__containingEntity, get__containingEntityReference, get__mapKey, get__sequenceNumber, getPersistenceHelperPlugin, hashCode, set__classIdentifier, set__containingBelonging, set__containingEntity, set__containingEntityReference, set__mapKey, toString
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface com.beasys.commerce.foundation.Belonging
clone, equals, interfaceName, setByValue, value
 
Methods from interface java.lang.Comparable
compareTo
 
Methods from interface com.beasys.commerce.foundation.RelationalReference
get__classIdentifier, get__containingBelonging, get__containingEntity, get__mapKey, get__sequenceNumber, set__containingBelonging, set__containingEntity, set__mapKey
 
Methods from interface com.beasys.commerce.ebusiness.shoppingcart.ShoppingCart
addItemsFromShoppingCart, addProductItem, addProductItem, addShoppingCartLine, addShoppingCartLineCollection, clearShoppingCartLineCollection, containsShoppingCartLine, containsShoppingCartLineCollection, createShoppingCartLine, equalsShoppingCartLineCollection, findShoppingCartLine, getCategoryQuantity, getNumberOfUnits, getOrderDiscountPresentations, getShipping, getShippingDiscountPresentations, getShoppingCartLineCollection, getSubtotal, getTotal, getTotal, getTotalPrice, isEmpty, isShoppingCartLineCollectionEmpty, removeAllProductItems, removeProductItem, removeShoppingCartLine, removeShoppingCartLineCollection, retainShoppingCartLineCollection, setOrderDiscountPresentations, setProductItemQuantity, setShipping, setShippingDiscountPresentations, setShoppingCartLineCollection, setSubtotal, setTotal, shoppingCartLineCollectionHashCode, shoppingCartLineCollectionIterator, shoppingCartLineCollectionSize
 

Field Detail

shipping

public Money shipping


shoppingCartLines

public Collection shoppingCartLines
The shopping cart contains a list of ShoppingCart lines


subtotal

public Money subtotal


total

public Money total

 

Constructor Detail

ShoppingCartImpl

public ShoppingCartImpl()
 

Method Detail

addItemsFromShoppingCart(ShoppingCart) Method

public void addItemsFromShoppingCart(ShoppingCart items)
throws InvalidArgumentException
Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.

Exceptions

InvalidArgumentException

addProductItem(ProductItem, double) Method

public ShoppingCartLine addProductItem(ProductItem item, 
                                       double quantity)
throws InvalidArgumentException
Add an Item to the ShoppingCart. If the Item is already in the ShoppingCart, increase its quantity.

Exceptions

InvalidArgumentException

addProductItem(ProductItem, double, Money) Method

public ShoppingCartLine addProductItem(ProductItem item, 
                                       double quantity, 
                                       Money unitPrice)
throws InvalidArgumentException
Add an Item to the ShoppingCart. If the Item is already in the ShoppingCart, increase its quantity.

Exceptions

InvalidArgumentException

addShoppingCartLine(ShoppingCartLine) Method

public boolean addShoppingCartLine(ShoppingCartLine element)
Ensures that this collection contains the specified element (optional operation).


addShoppingCartLineCollection(Collection) Method

public boolean addShoppingCartLineCollection(Collection collection)
Adds all of the elements in the specified collection to this collection (optional operation).


clearShoppingCartLineCollection() Method

public void clearShoppingCartLineCollection()
Removes all of the elements from this collection (optional operation).


compareTo(Object) Method

public int compareTo(Object o)
Compare this belonging to another

Overrides
BelongingImpl.compareTo(Object)

Parameters

o
target object for comparision

Returns

0 objects are equal

containsShoppingCartLine(ShoppingCartLine) Method

public boolean containsShoppingCartLine(ShoppingCartLine element)
Returns true if this collection contains the specified element.


containsShoppingCartLineCollection(Collection) Method

public boolean containsShoppingCartLineCollection(Collection collection)
Returns true if this collection contains all of the elements in the specified collection.


createShoppingCartLine() Method

public ShoppingCartLine createShoppingCartLine()
Used internally by the ShoppingCart to create ShoppingCartLines. If ShoppingCart is used to manage a list of lines that extend ShoppingCartLine, this method should be overridden to return an instance of the appropiate sub class.


equalsShoppingCartLineCollection(Object) Method

public boolean equalsShoppingCartLineCollection(Object object)
Compares the specified object with this collection for equality.


findShoppingCartLine(String) Method

public ShoppingCartLine findShoppingCartLine(String productIdentifier)
throws ItemNotInShoppingCartException, InvalidArgumentException
Find the ShoppingCartLine associated with the specified Item. Throws an ItemNotInShoppingCartException if the Item cannot be found.

Parameters

productIdentifier
(See productItem.getKey( ).getIdentifier( ) )

Exceptions

ItemNotInShoppingCartException
InvalidArgumentException

getCategoryQuantity(String) Method

public double getCategoryQuantity(String categoryId)
throws RemoteException
Count the number of product items that belong to a category Note This method creates/calls the CatalogManager and the ProductItemManager to resolve which items belong to what category! This means the performance of this method cannot be great, and the method should be used parcimoniously.

Parameters

categoryId
a string that identifies the category

Returns

the count over all the items which belong to that category

Exceptions

RemoteException

getNumberOfUnits() Method

public double getNumberOfUnits()
Count the total quantity of items by summing the quantity on each line.


getOrderDiscountPresentations() Method

public ArrayList getOrderDiscountPresentations()
Gets the order level discount list


getShipping() Method

public Money getShipping()
Get the value of shipping

Returns

shipping.

getShippingDiscountPresentations() Method

public ArrayList getShippingDiscountPresentations()
Gets the shipping discount list


getShoppingCartLineCollection() Method

public Collection getShoppingCartLineCollection()
Returns a deep copy of the entire collection


getSubtotal() Method

public Money getSubtotal()
Get the value of subtotal

Returns

subtotal.

getTotal() Method

public Money getTotal()
Get the value of total

Returns

total.

getTotal(int) Method

public Money getTotal(int totalType)
throws InvalidArgumentException
Gets the shopping cart total for the given total type

Parameters

totalType
type

Exceptions

InvalidArgumentException

getTotalPrice() Method

public Money getTotalPrice()
Gets the overal shopping cart total


interfaceName() Method

public String interfaceName()
interfaceName() returns the unqualified name of the interface from the UML model

Returns

the unqualified name of the belonging interface from the UML model

isEmpty() Method

public boolean isEmpty()
Returns true if the shopping cart has no items


isShoppingCartLineCollectionEmpty() Method

public boolean isShoppingCartLineCollectionEmpty()
Returns true if this collection contains no elements.


removeAllProductItems() Method

public void removeAllProductItems()
Removes all ShoppingCartLines. This resets the entire ShoppingCart.


removeProductItem(String) Method

public ProductItem removeProductItem(String productIdentifier)
throws InvalidArgumentException
Remove the ShoppingCartLine associated with the Item specified.

Parameters

productIdentifier
(See productItem.getKey( ).getIdentifier( ) )

Exceptions

InvalidArgumentException

removeShoppingCartLine(ShoppingCartLine) Method

public boolean removeShoppingCartLine(ShoppingCartLine element)
Removes a single instance of the specified element from this collection, if it is present (optional operation).


removeShoppingCartLineCollection(Collection) Method

public boolean removeShoppingCartLineCollection(Collection collection)
Removes all this collection's elements that are also contained in the specified collection (optional operation).


retainShoppingCartLineCollection(Collection) Method

public boolean retainShoppingCartLineCollection(Collection collection)
Retains only the elements in this collection that are contained in the specified collection (optional operation).


setByValue(Belonging) Method

public void setByValue(Belonging value)
It is possible to call set-by-value with a superclass. If that is the case, only the fields in the superclass will be set in this instance. The remaining fields get the default values.

It is also possible to call set-by-value with a subclass. In this case, the specialized fields in the subclass will be ignored. The overridden fields in the subclass will be populated.

Overrides
BelongingImpl.setByValue(Belonging)

Parameters

value
The Belonging to use for initialization.

setOrderDiscountPresentations(ArrayList) Method

public void setOrderDiscountPresentations(ArrayList orderDiscountPresentations)
Sets the order level discount list


setProductItemQuantity(ProductItem, double) Method

public void setProductItemQuantity(ProductItem item, 
                                   double quantity)
throws InvalidArgumentException
Sets the Quantity of the ShoppingCartLine associated with this Item. A new ShoppingCartLine is created if the Item is not present. This differs from addItem in that this method explicitly sets the absolute Quantity of a ShoppingCartLine rather than incrementing the existing value .

Exceptions

InvalidArgumentException

setShipping(Money) Method

public void setShipping(Money shipping)
Set the value of shipping

Parameters

shipping
shipping to be added

setShippingDiscountPresentations(ArrayList) Method

public void setShippingDiscountPresentations(ArrayList shippingDiscountPresentations)
Sets the shipping discount list


setShoppingCartLineCollection(Collection) Method

public void setShoppingCartLineCollection(Collection collection)
Sets the entire collection


setSubtotal(Money) Method

public void setSubtotal(Money subtotal)
Set the value of subtotal

Parameters

subtotal
subtotal to be added

setTotal(Money) Method

public void setTotal(Money total)
Set the value of total

Parameters

total
total to be added

shoppingCartLineCollectionHashCode() Method

public int shoppingCartLineCollectionHashCode()
Returns the hash code value for this collection.


shoppingCartLineCollectionIterator() Method

public Iterator shoppingCartLineCollectionIterator()
Returns an iterator over the elements in this collection.


shoppingCartLineCollectionSize() Method

public int shoppingCartLineCollectionSize()
Returns the number of elements in this collection.


value() Method

public Belonging value()
value() is a more typesafe implementation of clone()

Returns

a clone of this instance