© 2002 BEA Systems, Inc.


com.beasys.commerce.ebusiness.shoppingcart
Class ShoppingCartImpl

java.lang.Object
  |
  +--com.beasys.commerce.foundation.BelongingImpl
        |
        +--com.beasys.commerce.ebusiness.shoppingcart.ShoppingCartImpl

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.

See Also:
ShoppingCart, ShoppingCartHome, Serialized Form

Field Summary
 Money shipping
           Containment: By Value Multiplicity: 1:1
 java.util.Collection shoppingCartLines
          The shopping cart contains a list of ShoppingCart lines Containment: By Value Multiplicity: 0:N Interface: java.util.Collection
 Money subtotal
           
 Money total
           
 
Fields inherited from class com.beasys.commerce.foundation.BelongingImpl
__classIdentifier, __containingBelonging, __containingEntity, __mapKey, __sequenceNumber, _isDirty
 
Constructor Summary
ShoppingCartImpl()
           
 
Method Summary
 void addItemsFromShoppingCart(ShoppingCart items)
          Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.
 ShoppingCartLine addProductItem(ProductItem item, double quantity)
          Add an Item to the ShoppingCart.
 ShoppingCartLine addProductItem(ProductItem item, double quantity, Money unitPrice)
          Add an Item to the ShoppingCart.
 boolean addShoppingCartLine(ShoppingCartLine element)
          Ensures that this collection contains the specified element (optional operation).
 boolean addShoppingCartLineCollection(java.util.Collection collection)
          Adds all of the elements in the specified collection to this collection (optional operation).
 void clearShoppingCartLineCollection()
          Removes all of the elements from this collection (optional operation).
 int compareTo(java.lang.Object o)
          Compare this belonging to another
 boolean containsShoppingCartLine(ShoppingCartLine element)
          Returns true if this collection contains the specified element.
 boolean containsShoppingCartLineCollection(java.util.Collection collection)
          Returns true if this collection contains all of the elements in the specified collection.
 ShoppingCartLine createShoppingCartLine()
          Used internally by the ShoppingCart to create ShoppingCartLines.
 boolean equalsShoppingCartLineCollection(java.lang.Object object)
          Compares the specified object with this collection for equality.
 ShoppingCartLine findShoppingCartLine(java.lang.String productIdentifier)
          Find the ShoppingCartLine associated with the specified Item.
 double getCategoryQuantity(java.lang.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! This means the performance of this method cannot be great, and the method should be used parcimoniously.
 double getNumberOfUnits()
          Count the total quantity of items by summing the quantity on each line.
 java.util.ArrayList getOrderDiscountPresentations()
          Gets the order level discount list
 Money getShipping()
          Get the value of shipping
 java.util.ArrayList getShippingDiscountPresentations()
          Gets the shipping discount list
 java.util.Collection getShoppingCartLineCollection()
          Returns a deep copy of the entire collection
 Money getSubtotal()
          Get the value of subtotal
 Money getTotal()
          Get the value of total
 Money getTotal(int totalType)
          Gets the shopping cart total for the given total type
 Money getTotalPrice()
          Gets the overal shopping cart total
 java.lang.String interfaceName()
          interfaceName() returns the unqualified name of the interface from the UML model
 boolean isEmpty()
          Returns true if the shopping cart has no items
 boolean isShoppingCartLineCollectionEmpty()
          Returns true if this collection contains no elements.
 void removeAllProductItems()
          Removes all ShoppingCartLines.
 ProductItem removeProductItem(java.lang.String productIdentifier)
          Remove the ShoppingCartLine associated with the Item specified.
 boolean removeShoppingCartLine(ShoppingCartLine element)
          Removes a single instance of the specified element from this collection, if it is present (optional operation).
 boolean removeShoppingCartLineCollection(java.util.Collection collection)
          Removes all this collection's elements that are also contained in the specified collection (optional operation).
 boolean retainShoppingCartLineCollection(java.util.Collection collection)
          Retains only the elements in this collection that are contained in the specified collection (optional operation).
 void setByValue(Belonging value)
          It is possible to call set-by-value with a superclass.
 void setOrderDiscountPresentations(java.util.ArrayList orderDiscountPresentations)
          Sets the order level discount list
 void setProductItemQuantity(ProductItem item, double quantity)
          Sets the Quantity of the ShoppingCartLine associated with this Item.
 void setShipping(Money shipping)
          Set the value of shipping
 void setShippingDiscountPresentations(java.util.ArrayList shippingDiscountPresentations)
          Sets the shipping discount list
 void setShoppingCartLineCollection(java.util.Collection collection)
          Sets the entire collection
 void setSubtotal(Money subtotal)
          Set the value of subtotal
 void setTotal(Money total)
          Set the value of total
 int shoppingCartLineCollectionHashCode()
          Returns the hash code value for this collection.
 java.util.Iterator shoppingCartLineCollectionIterator()
          Returns an iterator over the elements in this collection.
 int shoppingCartLineCollectionSize()
          Returns the number of elements in this collection.
 Belonging value()
          value() is a more typesafe implementation of clone()
 
Methods inherited from class 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 inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

shipping

public Money shipping

subtotal

public Money subtotal

total

public Money total

shoppingCartLines

public java.util.Collection shoppingCartLines
The shopping cart contains a list of ShoppingCart lines
Constructor Detail

ShoppingCartImpl

public ShoppingCartImpl()
Method Detail

getTotal

public Money getTotal()
Get the value of total
Specified by:
getTotal in interface ShoppingCart

Returns:
total.

setTotal

public void setTotal(Money total)
Set the value of total
Specified by:
setTotal in interface ShoppingCart

Parameters:
total - total to be added

getSubtotal

public Money getSubtotal()
Get the value of subtotal
Specified by:
getSubtotal in interface ShoppingCart

Returns:
subtotal.

setSubtotal

public void setSubtotal(Money subtotal)
Set the value of subtotal
Specified by:
setSubtotal in interface ShoppingCart

Parameters:
subtotal - subtotal to be added

getShipping

public Money getShipping()
Get the value of shipping
Specified by:
getShipping in interface ShoppingCart

Returns:
shipping.

setShipping

public void setShipping(Money shipping)
Set the value of shipping
Specified by:
setShipping in interface ShoppingCart

Parameters:
shipping - shipping to be added

getShoppingCartLineCollection

public java.util.Collection getShoppingCartLineCollection()
Returns a deep copy of the entire collection
Specified by:
getShoppingCartLineCollection in interface ShoppingCart


setShoppingCartLineCollection

public void setShoppingCartLineCollection(java.util.Collection collection)
Sets the entire collection
Specified by:
setShoppingCartLineCollection in interface ShoppingCart


addShoppingCartLine

public boolean addShoppingCartLine(ShoppingCartLine element)
Ensures that this collection contains the specified element (optional operation).
Specified by:
addShoppingCartLine in interface ShoppingCart


addShoppingCartLineCollection

public boolean addShoppingCartLineCollection(java.util.Collection collection)
Adds all of the elements in the specified collection to this collection (optional operation).
Specified by:
addShoppingCartLineCollection in interface ShoppingCart


clearShoppingCartLineCollection

public void clearShoppingCartLineCollection()
Removes all of the elements from this collection (optional operation).
Specified by:
clearShoppingCartLineCollection in interface ShoppingCart


containsShoppingCartLine

public boolean containsShoppingCartLine(ShoppingCartLine element)
Returns true if this collection contains the specified element.
Specified by:
containsShoppingCartLine in interface ShoppingCart


containsShoppingCartLineCollection

public boolean containsShoppingCartLineCollection(java.util.Collection collection)
Returns true if this collection contains all of the elements in the specified collection.
Specified by:
containsShoppingCartLineCollection in interface ShoppingCart


equalsShoppingCartLineCollection

public boolean equalsShoppingCartLineCollection(java.lang.Object object)
Compares the specified object with this collection for equality.
Specified by:
equalsShoppingCartLineCollection in interface ShoppingCart


shoppingCartLineCollectionHashCode

public int shoppingCartLineCollectionHashCode()
Returns the hash code value for this collection.
Specified by:
shoppingCartLineCollectionHashCode in interface ShoppingCart


isShoppingCartLineCollectionEmpty

public boolean isShoppingCartLineCollectionEmpty()
Returns true if this collection contains no elements.
Specified by:
isShoppingCartLineCollectionEmpty in interface ShoppingCart


shoppingCartLineCollectionIterator

public java.util.Iterator shoppingCartLineCollectionIterator()
Returns an iterator over the elements in this collection.
Specified by:
shoppingCartLineCollectionIterator in interface ShoppingCart


removeShoppingCartLine

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


removeShoppingCartLineCollection

public boolean removeShoppingCartLineCollection(java.util.Collection collection)
Removes all this collection's elements that are also contained in the specified collection (optional operation).
Specified by:
removeShoppingCartLineCollection in interface ShoppingCart


retainShoppingCartLineCollection

public boolean retainShoppingCartLineCollection(java.util.Collection collection)
Retains only the elements in this collection that are contained in the specified collection (optional operation).
Specified by:
retainShoppingCartLineCollection in interface ShoppingCart


shoppingCartLineCollectionSize

public int shoppingCartLineCollectionSize()
Returns the number of elements in this collection.
Specified by:
shoppingCartLineCollectionSize in interface ShoppingCart


value

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

Returns:
a clone of this instance

interfaceName

public java.lang.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

setByValue

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:
setByValue in class BelongingImpl

compareTo

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

Parameters:
o - target object for comparision
Returns:
0 objects are equal
Overrides:
compareTo in class BelongingImpl

addItemsFromShoppingCart

public void addItemsFromShoppingCart(ShoppingCart items)
                              throws InvalidArgumentException
Add the ShoppingCartLines from the specified ShoppingCart to this ShoppingCart.
Specified by:
addItemsFromShoppingCart in interface ShoppingCart

Throws:
InvalidArgumentException -  

setProductItemQuantity

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 .
Specified by:
setProductItemQuantity in interface ShoppingCart

Throws:
InvalidArgumentException -  

removeProductItem

public ProductItem removeProductItem(java.lang.String productIdentifier)
                              throws InvalidArgumentException
Remove the ShoppingCartLine associated with the Item specified.
Specified by:
removeProductItem in interface ShoppingCart

Parameters:
productIdentifier, - (See productItem.getKey( ).getIdentifier( ) )
Throws:
InvalidArgumentException -  

removeAllProductItems

public void removeAllProductItems()
Removes all ShoppingCartLines. This resets the entire ShoppingCart.
Specified by:
removeAllProductItems in interface ShoppingCart


findShoppingCartLine

public ShoppingCartLine findShoppingCartLine(java.lang.String productIdentifier)
                                      throws ItemNotInShoppingCartException,
                                             InvalidArgumentException
Find the ShoppingCartLine associated with the specified Item. Throws an ItemNotInShoppingCartException if the Item cannot be found.
Specified by:
findShoppingCartLine in interface ShoppingCart

Parameters:
productIdentifier, - (See productItem.getKey( ).getIdentifier( ) )
Throws:
ItemNotInShoppingCartException -  
InvalidArgumentException -  

getNumberOfUnits

public double getNumberOfUnits()
Count the total quantity of items by summing the quantity on each line.
Specified by:
getNumberOfUnits in interface ShoppingCart


getCategoryQuantity

public double getCategoryQuantity(java.lang.String categoryId)
                           throws java.rmi.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.
Specified by:
getCategoryQuantity in interface ShoppingCart

Parameters:
categoryId, - a string that identifies the category
Returns:
the count over all the items which belong to that category

createShoppingCartLine

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.
Specified by:
createShoppingCartLine in interface ShoppingCart


addProductItem

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.
Specified by:
addProductItem in interface ShoppingCart

Throws:
InvalidArgumentException -  

addProductItem

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.
Specified by:
addProductItem in interface ShoppingCart

Throws:
InvalidArgumentException -  

isEmpty

public boolean isEmpty()
Returns true if the shopping cart has no items
Specified by:
isEmpty in interface ShoppingCart


getTotal

public Money getTotal(int totalType)
               throws InvalidArgumentException
Gets the shopping cart total for the given total type
Specified by:
getTotal in interface ShoppingCart

Parameters:
total - type
Throws:
InvalidArgumentException -  

getTotalPrice

public Money getTotalPrice()
Gets the overal shopping cart total
Specified by:
getTotalPrice in interface ShoppingCart


getShippingDiscountPresentations

public java.util.ArrayList getShippingDiscountPresentations()
Gets the shipping discount list
Specified by:
getShippingDiscountPresentations in interface ShoppingCart


setShippingDiscountPresentations

public void setShippingDiscountPresentations(java.util.ArrayList shippingDiscountPresentations)
Sets the shipping discount list
Specified by:
setShippingDiscountPresentations in interface ShoppingCart


getOrderDiscountPresentations

public java.util.ArrayList getOrderDiscountPresentations()
Gets the order level discount list
Specified by:
getOrderDiscountPresentations in interface ShoppingCart


setOrderDiscountPresentations

public void setOrderDiscountPresentations(java.util.ArrayList orderDiscountPresentations)
Sets the order level discount list
Specified by:
setOrderDiscountPresentations in interface ShoppingCart


© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved