BEA Systems, Inc.

theory.smart.ebusiness.order
Class OrderImpl

java.lang.Object
  |
  +--theory.smart.foundation.EntityImpl
        |
        +--theory.smart.ebusiness.order.OrderImpl
Direct Known Subclasses:
GiftRegistryImpl

public class OrderImpl
extends EntityImpl

The Order class collects OrderLines and provides indirect access to the Items they contain. An OrderLine is an Item and the quantity that the customer intends to by. It is the conceptual equivalent of a shopping cart or basket. The order combines the features of a list and a map. It is a list so that the positioning of the items in the order is preserved. The Order is responsible for ensuring that each item appears only once in the list and for adjusting the quantity as necessary.. When an Item is added to an Order an OrderLine is created. If an OrderLine for that Item already exists its quantity is adjusted..

 Primary Key = theory.smart.ebusiness.order.OrderPk
 

See Also:
Order, OrderHome, OrderValue, Serialized Form

Field Summary
 SmartHandle customer
           customer [Order] <>------> [theory.smart.ebusiness.customer.Customer]
 java.lang.String key
           key [Order] <*>------> [String] (Primary Key)
 com.sun.java.util.collections.LinkedList orderLines
           orderLine (List) [Order] <*>------> [theory.smart.ebusiness.order.OrderLine] 0..*
 WorkflowContext status
           status [Order] <*>------> [theory.smart.ebusiness.order.OrderWorkflow]
 Workflow statusWorkflow
           
 
Fields inherited from class theory.smart.foundation.EntityImpl
ctx, isDirty, isLoaded
 
Constructor Summary
OrderImpl()
           
 
Method Summary
 void addFirstOrderLine(OrderLine orderLine)
          Inserts the given orderLine at the beginning of the orderLine list.
 void addItem(Item item, Quantity quantity)
          Add an Item to this Order.
 void addItems(Order items)
          Add the OrderLines from the specified order to this order.
 void addLastOrderLine(OrderLine orderLine)
          Appends the given orderLine to the end of the orderLine list.
 void addOrderLine(int index, OrderLine orderLine)
          Inserts the specified orderLine at the specified position in the orderLine list.
 boolean addOrderLine(OrderLine orderLine)
          Appends the specified orderLine to the end of the orderLine list.
 boolean addOrderLines(int index, com.sun.java.util.collections.LinkedList orderLines)
          Inserts all of the orderLines in the specified collection into this list, starting at the specified position.
 boolean addOrderLines(com.sun.java.util.collections.LinkedList orderLines)
          Appends all of the orderLines in the specified collection to the end of the orderLine list, in the order that they are returned by the specified collection's iterator.
 void cancel()
          Apply the "cancel" transition to the OrderWorkflow.
 boolean containsOrderLine(OrderLine orderLine)
          Returns true if the orderLine list contains the specified element.
 void ejbActivate()
          ejbActivate method.
 OrderPk ejbCreate(OrderPk orderPk)
           
 java.util.Enumeration ejbFindAll()
           
 OrderPk ejbFindByPrimaryKey(OrderPk pk)
           
 void ejbLoad()
          ejbLoad method.
 void ejbPassivate()
          ejbPassivate method.
 void ejbPostCreate(OrderPk orderPk)
           
 void ejbRemove()
          ejbRemove method.
 void ejbStore()
          ejbStore method.
 void finalizePrices()
          Iterate the order lines and "lockin" the price of each.
 OrderLine findOrderLine(Item item)
          Find the order line associated with the specified Item.
 Customer getCustomer()
          Get the remote object reference of customer
 OrderLine getFirstOrderLine()
          Returns the first orderLine in the orderLine list.
 com.sun.java.util.collections.Collection getItems()
          Retrieves a list of the Items that are included in this order.
 java.lang.String getKey()
           
 OrderLine getLastOrderLine()
          Returns the last orderLine in the orderLine list.
 int getNumberOfOrderLines()
          Returns the number of orderLines in the orderLine list.
 Quantity getNumberOfUnits()
          Count the total quantity of items by summing the quantity on each line.
 OrderValue getOrderByValue()
          Get all of Order's attributes.
 OrderLine getOrderLine(int index)
          Returns the orderLine at the specified position in the orderLine list.
 com.sun.java.util.collections.LinkedList getOrderLines()
          Returns all of the orderLines in the orderLine list.
 com.sun.java.util.collections.LinkedList getOrderLines(int fromIndex, int toIndex)
          Returns a view of the portion of the orderLine list between fromIndex, inclusive, and toIndex, exclusive.
 java.lang.String getOrderPriceCalculationPolicyName()
          Return the name of the business policy that will be used when calculating the orders total price.
 java.lang.String getStatus()
          Returns the current state name of the theory.smart.ebusiness.order.OrderWorkflow workflow
 Price getTotalPrice()
          Calculate the price of the order by iterating the OrderLines and summing the line prices.
 int indexOfOrderLine(OrderLine orderLine)
          Returns the index in the orderLine list of the first occurrence of the specified element, or -1 if the orderLine list does not contain this element.
 void invoice()
          Apply the "Invoice" transition to the OrderWorkflow.
 boolean isOrderLinesEmtpy()
          Returns true if the orderLine list contains no orderLines.
 int lastIndexOfOrderLine(OrderLine orderLine)
          Returns the index in the orderLine list of the last occurrence of the specified element, or -1 if the orderLine list does not contain this element.
 void removeAllItems()
          Removes all OrderLines.
 void removeAllOrderLines()
          Removes all of the orderLines from the orderLine list.
 OrderLine removeFirstOrderLine()
          Removes and returns the first orderLine from the orderLine list.
 void removeItem(Item item)
          Remove the OrderLine associated with the Item specified.
 OrderLine removeLastOrderLine()
          Removes and returns the last orderLine from the orderLine list.
 OrderLine removeOrderLine(int index)
          Removes the orderLine at the specified position in the orderLine list.
 boolean removeOrderLine(OrderLine orderLine)
          Removes the first occurrence of the specified orderLine in the orderLine list.
 void returnOrder()
          Apply the "returnOrder" transition to the OrderWorkflow.
 void sendToShipping()
          Apply the "sendToShipping" transition to the OrderWorkflow.
 void setCustomer(Customer customer)
          Set the remote object reference of customer
 void setEntityContext(javax.ejb.EntityContext ctx)
          setEntityContext method.
 void setItemQuantity(Item item, Quantity n)
          Sets the Quantity of the OrderLine associated with this Item.
 void setOrderByValue(OrderValue value)
          Set all of Order's attributes to the passed in value.
 OrderLine setOrderLine(int index, OrderLine orderLine)
          Replaces the orderLine at the specified position in the orderLine list with the specified element.
 void ship()
          Apply the "ship" transition to the OrderWorkflow.
 void unsetEntityContext()
          unsetEntityContext method.
 
Methods inherited from class theory.smart.foundation.EntityImpl
ejbCreate, ejbPostCreate, getEntityContext, isModified
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

public java.lang.String key
                  key
 [Order] <*>------> [String] (Primary Key)

 

orderLines

public com.sun.java.util.collections.LinkedList orderLines
                  orderLine (List)
 [Order] <*>------> [theory.smart.ebusiness.order.OrderLine] 
                     0..*
 

status

public WorkflowContext status
                  status
 [Order] <*>------> [theory.smart.ebusiness.order.OrderWorkflow] 

 

statusWorkflow

public transient Workflow statusWorkflow

customer

public SmartHandle customer
                  customer
 [Order] <>------> [theory.smart.ebusiness.customer.Customer] 

 
Constructor Detail

OrderImpl

public OrderImpl()
          throws javax.ejb.CreateException
Method Detail

getOrderByValue

public OrderValue getOrderByValue()
                           throws java.rmi.RemoteException
Get all of Order's attributes.
Returns:
OrderValue the Order value object

setOrderByValue

public void setOrderByValue(OrderValue value)
                     throws java.rmi.RemoteException
Set all of Order's attributes to the passed in value. Note: Primary key attributes are not set.
Parameters:
OrderValue - the Order value object

ejbCreate

public OrderPk ejbCreate(OrderPk orderPk)
                  throws javax.ejb.CreateException,
                         java.rmi.RemoteException

ejbPostCreate

public void ejbPostCreate(OrderPk orderPk)
                   throws javax.ejb.CreateException,
                          java.rmi.RemoteException

ejbLoad

public void ejbLoad()
             throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbLoad method.
Overrides:
ejbLoad in class EntityImpl

ejbStore

public void ejbStore()
              throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbStore method.
Overrides:
ejbStore in class EntityImpl

ejbRemove

public void ejbRemove()
               throws java.rmi.RemoteException,
                      javax.ejb.RemoveException
Description copied from class: EntityImpl
ejbRemove method.
Overrides:
ejbRemove in class EntityImpl

ejbActivate

public void ejbActivate()
                 throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbActivate method.
Overrides:
ejbActivate in class EntityImpl

ejbPassivate

public void ejbPassivate()
                  throws java.rmi.RemoteException
Description copied from class: EntityImpl
ejbPassivate method.
Overrides:
ejbPassivate in class EntityImpl

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
                      throws java.rmi.RemoteException
Description copied from class: EntityImpl
setEntityContext method.
Overrides:
setEntityContext in class EntityImpl

unsetEntityContext

public void unsetEntityContext()
                        throws java.rmi.RemoteException
Description copied from class: EntityImpl
unsetEntityContext method.
Overrides:
unsetEntityContext in class EntityImpl

ejbFindByPrimaryKey

public OrderPk ejbFindByPrimaryKey(OrderPk pk)
                            throws javax.ejb.FinderException,
                                   java.rmi.RemoteException

ejbFindAll

public java.util.Enumeration ejbFindAll()
                                 throws javax.ejb.FinderException,
                                        java.rmi.RemoteException

getKey

public java.lang.String getKey()
                        throws java.rmi.RemoteException

addOrderLine

public void addOrderLine(int index,
                         OrderLine orderLine)
Inserts the specified orderLine at the specified position in the orderLine list. Shifts the orderLine currently at that position (if any) and any subsequent orderLines to the right (adds one to their indices).
Parameters:
index - index at which the specified orderLine is to be inserted.
orderLine - orderLine to be inserted.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addOrderLine

public boolean addOrderLine(OrderLine orderLine)
Appends the specified orderLine to the end of the orderLine list.
Parameters:
orderLine - orderLine to be appended to the orderLine list.
Returns:
true (as per the general contract of Collection.add).

addOrderLines

public boolean addOrderLines(int index,
                             com.sun.java.util.collections.LinkedList orderLines)
Inserts all of the orderLines in the specified collection into this list, starting at the specified position. Shifts the element currently at that position (if any) and any subsequent orderLines to the right (increases their indices). The new orderLines will appear in the orderLine list in the order that they are returned by the specified collection's iterator.
Parameters:
index - index at which to insert first element from the specified collection.
orderLines - orderLines to be inserted into the orderLine list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addOrderLines

public boolean addOrderLines(com.sun.java.util.collections.LinkedList orderLines)
Appends all of the orderLines in the specified collection to the end of the orderLine list, in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified Collection is the orderLine list, and the orderLine list is nonempty.)
Parameters:
orderLines - orderLines to be inserted into the orderLine list.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index > size()).

addFirstOrderLine

public void addFirstOrderLine(OrderLine orderLine)
Inserts the given orderLine at the beginning of the orderLine list.

addLastOrderLine

public void addLastOrderLine(OrderLine orderLine)
Appends the given orderLine to the end of the orderLine list. (Identical in function to the add method; included only for consistency.)

containsOrderLine

public boolean containsOrderLine(OrderLine orderLine)
Returns true if the orderLine list contains the specified element. More formally, returns true if and only if the orderLine list contains at least one orderLine e such that (o==null ? e==null : o.equals(e)).
Parameters:
orderLine - orderLine whose presence in the orderLine list is to be tested.
Returns:
true if the orderLine list contains the specified element.

getOrderLine

public OrderLine getOrderLine(int index)
Returns the orderLine at the specified position in the orderLine list.
Parameters:
index - index of orderLine to return.
Returns:
the orderLine at the specified position in the orderLine list.
Throws:
IndexOutOfBoundsException - if the specified index is is out of range (index < 0 || index >= size()).

getOrderLines

public com.sun.java.util.collections.LinkedList getOrderLines(int fromIndex,
                                                              int toIndex)
Returns a view of the portion of the orderLine list between fromIndex, inclusive, and toIndex, exclusive.
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toKey - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within the orderLine list.
Throws:
IndexOutOfBoundsException - endpoint index value out of range (fromIndex < 0 || toIndex > size)
java.lang.IllegalArgumentException - endpoint indices out of order (fromIndex > toIndex)

getOrderLines

public com.sun.java.util.collections.LinkedList getOrderLines()
Returns all of the orderLines in the orderLine list.
Returns:
all of the orderLines in the orderLine list.

getFirstOrderLine

public OrderLine getFirstOrderLine()
Returns the first orderLine in the orderLine list.
Returns:
the first orderLine in the orderLine list.

getLastOrderLine

public OrderLine getLastOrderLine()
Returns the last orderLine in the orderLine list.
Returns:
the last orderLine in the orderLine list.
Throws:
java.util.NoSuchElementException - if the orderLine list is empty.

getNumberOfOrderLines

public int getNumberOfOrderLines()
Returns the number of orderLines in the orderLine list.
Returns:
the number of orderLines in the orderLine list.

indexOfOrderLine

public int indexOfOrderLine(OrderLine orderLine)
Returns the index in the orderLine list of the first occurrence of the specified element, or -1 if the orderLine list does not contain this element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
orderLine - orderLine to search for.
Returns:
the index in the orderLine list of the first occurrence of the specified element, or -1 if the orderLine list does not contain this element.

isOrderLinesEmtpy

public boolean isOrderLinesEmtpy()
Returns true if the orderLine list contains no orderLines.

Returns:
true if the orderLine list contains no orderLines.

lastIndexOfOrderLine

public int lastIndexOfOrderLine(OrderLine orderLine)
Returns the index in the orderLine list of the last occurrence of the specified element, or -1 if the orderLine list does not contain this element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Parameters:
orderLine - orderLine to search for.
Returns:
the index in the orderLine list of the last occurrence of the specified element, or -1 if the orderLine list does not contain this element.

removeAllOrderLines

public void removeAllOrderLines()
Removes all of the orderLines from the orderLine list.

removeOrderLine

public OrderLine removeOrderLine(int index)
Removes the orderLine at the specified position in the orderLine list. Shifts any subsequent orderLines to the left (subtracts one from their indices). Returns the orderLine that was removed from the orderLine list.
Parameters:
index - the index of the orderLine to removed.
Returns:
the orderLine previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

removeOrderLine

public boolean removeOrderLine(OrderLine orderLine)
Removes the first occurrence of the specified orderLine in the orderLine list. If the orderLine list does not contain the element, it is unchanged. More formally, removes the orderLine with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an orderLine exists).
Parameters:
orderLine - orderLine to be removed from the orderLine list, if present.
Returns:
true if the orderLine list contained the specified element.

removeFirstOrderLine

public OrderLine removeFirstOrderLine()
Removes and returns the first orderLine from the orderLine list.
Returns:
the first orderLine from the orderLine list.
Throws:
java.util.NoSuchElementException - if the orderLine list is empty.

removeLastOrderLine

public OrderLine removeLastOrderLine()
Removes and returns the last orderLine from the orderLine list.
Returns:
the last orderLine from the orderLine list.
Throws:
java.util.NoSuchElementException - if the orderLine list is empty.

setOrderLine

public OrderLine setOrderLine(int index,
                              OrderLine orderLine)
Replaces the orderLine at the specified position in the orderLine list with the specified element.
Parameters:
index - index of orderLine to replace.
orderLine - orderLine to be stored at the specified position.
Returns:
the orderLine previously at the specified position.
Throws:
IndexOutOfBoundsException - if the specified index is out of range (index < 0 || index >= size()).

getStatus

public java.lang.String getStatus()
Returns the current state name of the theory.smart.ebusiness.order.OrderWorkflow workflow

getCustomer

public Customer getCustomer()
                     throws java.rmi.RemoteException
Get the remote object reference of customer
Returns:
customer.

setCustomer

public void setCustomer(Customer customer)
                 throws java.rmi.RemoteException
Set the remote object reference of customer
Parameters:
customers - customer to be added

addItems

public void addItems(Order items)
              throws java.rmi.RemoteException
Add the OrderLines from the specified order to this order.

addItem

public void addItem(Item item,
                    Quantity quantity)
             throws java.rmi.RemoteException
Add an Item to this Order. If the Item is already in the order, increase its quantity.

getItems

public com.sun.java.util.collections.Collection getItems()
                                                  throws java.rmi.RemoteException
Retrieves a list of the Items that are included in this order.

getNumberOfUnits

public Quantity getNumberOfUnits()
                          throws java.rmi.RemoteException
Count the total quantity of items by summing the quantity on each line.

setItemQuantity

public void setItemQuantity(Item item,
                            Quantity n)
                     throws java.rmi.RemoteException
Sets the Quantity of the OrderLine associated with this Item. A new OrderLine is created if the Item is not present. This differs from AddItem in that this method explicitly sets the absolute Quantity of an OrderLine rather than incrementing the existing value .

removeItem

public void removeItem(Item item)
                throws java.rmi.RemoteException
Remove the OrderLine associated with the Item specified.

removeAllItems

public void removeAllItems()
                    throws java.rmi.RemoteException
Removes all OrderLines. This resets the entire order.

getTotalPrice

public Price getTotalPrice()
                    throws java.rmi.RemoteException
Calculate the price of the order by iterating the OrderLines and summing the line prices.

findOrderLine

public OrderLine findOrderLine(Item item)
                        throws java.rmi.RemoteException,
                               javax.ejb.FinderException
Find the order line associated with the specified Item.

invoice

public void invoice()
             throws java.rmi.RemoteException,
                    IllegalWorkflowTransitionException
Apply the "Invoice" transition to the OrderWorkflow. This occurs when the order has been accepted by the customer and needs to be delivered to billing.

sendToShipping

public void sendToShipping()
                    throws java.rmi.RemoteException,
                           IllegalWorkflowTransitionException
Apply the "sendToShipping" transition to the OrderWorkflow. This occurs once the order has been recorded with billing.

ship

public void ship()
          throws java.rmi.RemoteException,
                 IllegalWorkflowTransitionException
Apply the "ship" transition to the OrderWorkflow. This occurs once the order has been succesfully processed by shipping.

returnOrder

public void returnOrder()
                 throws java.rmi.RemoteException,
                        IllegalWorkflowTransitionException
Apply the "returnOrder" transition to the OrderWorkflow. This occurs when an item is returned to inventory.

cancel

public void cancel()
            throws java.rmi.RemoteException,
                   IllegalWorkflowTransitionException
Apply the "cancel" transition to the OrderWorkflow. This when the order has been invoiced but before it has been shipped.

finalizePrices

public void finalizePrices()
                    throws java.rmi.RemoteException
Iterate the order lines and "lockin" the price of each. Before an order is finalized the price is calculated using the ItemPriceCalculationPolicy. Locking in the price involves recording the final price agreed upon with the customer.

getOrderPriceCalculationPolicyName

public java.lang.String getOrderPriceCalculationPolicyName()
                                                    throws java.rmi.RemoteException
Return the name of the business policy that will be used when calculating the orders total price.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved