FileDocCategorySizeDatePackage
Order.javaAPI DocJBoss 4.2.14495Fri Jul 13 20:55:36 BST 2007xpetstore.domain

Order

public class Order extends Object implements Serializable
author
Herve Tchepannou
hibernate.class
table="T_ORDER"

Fields Summary
public static final String
PENDING
public static final String
DELIVERED
public static final String
CANCELLED
private Address
_address
private CreditCard
_creditCard
private Customer
_customer
private Date
_orderDate
private long
_orderId
private Set
_orderItems
private String
_status
Constructors Summary
public Order()


    //~ Constructors -----------------------------------------------------------

       
    
        _customer   = new Customer(  );
        _address    = new Address(  );
        _creditCard = new CreditCard(  );
    
public Order(Customer customer)

        _customer   = customer;
        _address    = new Address( customer.getAddress(  ) );
        _creditCard = new CreditCard( customer.getCreditCard(  ) );
    
Methods Summary
public voidadd(Item item, int quantity)

        _orderItems.add( new OrderItem( item, quantity ) );
    
public AddressgetAddress()

return
Address
hibernate.component

        return _address;
    
public CreditCardgetCreditCard()

return
CreditCard
hibernate.component

        return _creditCard;
    
public CustomergetCustomer()

return
Customer
hibernate.many-to-one
column="customer_fk" cascade="none"

        return _customer;
    
public java.util.DategetOrderDate()

return
Date
hibernate.property

        return _orderDate;
    
public longgetOrderId()

return
long
hibernate.id
generator-class="vm.long"

        return _orderId;
    
public java.util.SetgetOrderItems()

return
Set
hibernate.set
role="orderItems" lazy="true" cascade="all"
hibernate.collection-key
column="order_fk"
hibernate.collection-one-to-many
class="xpetstore.domain.OrderItem"

        return _orderItems;
    
public java.lang.StringgetStatus()

return
String
hibernate.property
length="10"

        return _status;
    
public doublegetTotal()

        double   total = 0;
        Iterator it = _orderItems.iterator(  );

        while ( it.hasNext(  ) )
        {
            total += ( ( OrderItem ) it.next(  ) ).getSubTotal(  );
        }

        return total;
    
public voidsetAddress(Address address)
Sets the address.

param
address The address to set

        _address = address;
    
public voidsetCreditCard(CreditCard creditCard)
Sets the creditCard.

param
creditCard The creditCard to set

        _creditCard = creditCard;
    
public voidsetCustomer(Customer customer)
Sets the customer.

param
customer The customer to set

        _customer = customer;
    
public voidsetOrderDate(java.util.Date orderDate)
Sets the orderDate.

param
orderDate The orderDate to set

        _orderDate = orderDate;
    
public voidsetOrderId(long orderId)
Sets the orderId.

param
orderId The orderId to set

        _orderId = orderId;
    
public voidsetOrderItems(java.util.Set orderItems)
Sets the orderItems.

param
orderItems The orderItems to set

        _orderItems = orderItems;
    
public voidsetStatus(java.lang.String status)
Sets the status.

param
status The status to set

        _status = status;