org.starhope.appius.mb
Class ShippingOrder

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.util.BaseDatum
          extended by org.starhope.appius.mb.ShippingOrder
All Implemented Interfaces:
com.sun.sgs.app.ManagedObject, Externalizable, Serializable, Invoiceable, ShippingInvoice, CastsToJSON

public class ShippingOrder
extends BaseDatum
implements Invoiceable, ShippingInvoice

WRITEME

Author:
brpocock
See Also:
Serialized Form

Field Summary
private  BigDecimal amount
          WRITEME
private  com.sun.sgs.app.ManagedReference<UserAddress> billingAddress
          WRITEME
private  com.sun.sgs.app.ManagedReference<User> buyer
          WRITEME
private  Currency currency
          WRITEME
private  String invoiceNumber
          WRITEME
private  com.sun.sgs.app.ManagedReference<User> recipient
          WRITEME
private static long serialVersionUID
          WRITEME
private  com.sun.sgs.app.ManagedReference<UserAddress> shippingAddress
          WRITEME
private  String shipToOrganization
          WRITEME
private  String title
          WRITEME
 
Fields inherited from class org.starhope.appius.util.BaseDatum
database_id
 
Constructor Summary
ShippingOrder()
           
 
Method Summary
static ShippingOrder get(org.json.JSONObject object)
           
static ShippingOrder get(String id)
           
 UserAddress getAddress()
           
 BigDecimal getAmount()
           
 Person getBuyer()
          TODO: refactor payment gateways to use the buyer information: promote this up to Invoiceable interface.
 Currency getCurrency()
           
 String getInvoiceID()
           
 char getInvoiceIDPrefix()
           
 UserAddress getShippingAddress()
           
 UserAddress getShipToAddress()
           
 String getShipToOrganization()
           
 Person getShipToUser()
           
 String getTitle()
           
 Person getUser()
           
 void set(org.json.JSONObject o)
          This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in.
 void setAddress(UserAddress userAddress)
           
 void setBuyer(User newBuyer)
           
 void setInvoiceNumber(String string)
           
 void setShippingAddress(UserAddress shippingAddress)
           
 void setShipToAddress(UserAddress userAddress)
           
 void setShipToOrganization(String string)
           
 void setTitle(String string)
           
 void setUser(User newUser)
           
 org.json.JSONObject toJSON()
          This returns a copy of the object's data cast into a JSON form.
 
Methods inherited from class org.starhope.appius.util.BaseDatum
changed, commitToDatabase, delete, equals, flush, get, get, getID, getUniqueBoundName, readExternal, refJSON, setID, sqlDateTime, writeExternal
 
Methods inherited from class org.starhope.appius.util.ManagedReferenceHolder
deref, setRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
WRITEME

See Also:
Constant Field Values

amount

private BigDecimal amount
WRITEME


billingAddress

private com.sun.sgs.app.ManagedReference<UserAddress> billingAddress
WRITEME


buyer

private com.sun.sgs.app.ManagedReference<User> buyer
WRITEME


currency

private Currency currency
WRITEME


invoiceNumber

private String invoiceNumber
WRITEME


recipient

private com.sun.sgs.app.ManagedReference<User> recipient
WRITEME


shippingAddress

private com.sun.sgs.app.ManagedReference<UserAddress> shippingAddress
WRITEME


shipToOrganization

private String shipToOrganization
WRITEME


title

private String title
WRITEME

Constructor Detail

ShippingOrder

public ShippingOrder()
Method Detail

get

public static ShippingOrder get(org.json.JSONObject object)
                         throws RuntimeException,
                                NotFoundException,
                                org.json.JSONException
Parameters:
object - WRITEME
Returns:
WRITEME
Throws:
org.json.JSONException - WRITEME
NotFoundException - WRITEME
RuntimeException - WRITEME

get

public static ShippingOrder get(String id)
                         throws RuntimeException,
                                NotFoundException
Parameters:
id - WRITEME
Returns:
WRITEME
Throws:
NotFoundException - WRITEME
RuntimeException - WRITEME

getAddress

public UserAddress getAddress()
Specified by:
getAddress in interface Invoiceable
Returns:
the billing address for a purchase
See Also:
Invoiceable.getAddress()

getAmount

public BigDecimal getAmount()
Specified by:
getAmount in interface Invoiceable
Returns:
the price of a purchase
See Also:
Invoiceable.getAmount()

getBuyer

public Person getBuyer()
Description copied from interface: Invoiceable
TODO: refactor payment gateways to use the buyer information: promote this up to Invoiceable interface.

Specified by:
getBuyer in interface Invoiceable
Returns:
the buyer, paying-for this order
See Also:
Invoiceable.getBuyer()

getCurrency

public Currency getCurrency()
Specified by:
getCurrency in interface Invoiceable
Returns:
the currency used to describe the price in Invoiceable.getAmount()
See Also:
Invoiceable.getCurrency()

getInvoiceID

public String getInvoiceID()
Specified by:
getInvoiceID in interface Invoiceable
Returns:
the invoice ID ("order number") for payment
See Also:
Invoiceable.getInvoiceID()

getInvoiceIDPrefix

public char getInvoiceIDPrefix()
Specified by:
getInvoiceIDPrefix in interface Invoiceable
Returns:
A single-character code representing this class of invoiceable items. This permits easy identification of the type of object being paid for, regardless of how we come across the invoice number.
See Also:
Invoiceable.getInvoiceIDPrefix()

getShippingAddress

public UserAddress getShippingAddress()
Returns:
the shippingAddress

getShipToAddress

public UserAddress getShipToAddress()
Specified by:
getShipToAddress in interface ShippingInvoice
See Also:
ShippingInvoice.getShipToAddress()

getShipToOrganization

public String getShipToOrganization()
Specified by:
getShipToOrganization in interface ShippingInvoice
See Also:
ShippingInvoice.getShipToOrganization()

getShipToUser

public Person getShipToUser()
Specified by:
getShipToUser in interface ShippingInvoice
See Also:
ShippingInvoice.getShipToUser()

getTitle

public String getTitle()
Specified by:
getTitle in interface Invoiceable
Returns:
the description of a purchase
See Also:
Invoiceable.getTitle()

getUser

public Person getUser()
Returns:
the recipient of this order

set

public void set(org.json.JSONObject o)
Description copied from interface: CastsToJSON
This method will attempt to set the data contents of this object to the values derived from the JSON object being passed-in. All exceptions are ignored, but any errors in the JSON data could cause the command to fail, completely or partially.

Specified by:
set in interface CastsToJSON
Overrides:
set in class BaseDatum
Parameters:
o - The JSON object containing a the new data for this object.
See Also:
CastsToJSON.set(org.json.JSONObject)

setAddress

public void setAddress(UserAddress userAddress)
Parameters:
userAddress - the billing address of the buyer

setBuyer

public void setBuyer(User newBuyer)
Parameters:
newBuyer - WRITEME

setInvoiceNumber

public void setInvoiceNumber(String string)
                      throws DataException
Parameters:
string - the invoice number for this object. Must be compatible with its prefix.
Throws:
DataException - if the invoice number mismatches the prefix for this class

setShippingAddress

public void setShippingAddress(UserAddress shippingAddress)
Parameters:
shippingAddress - the shippingAddress to set

setShipToAddress

public void setShipToAddress(UserAddress userAddress)
Parameters:
userAddress - the address to which to ship the product(s) purchased

setShipToOrganization

public void setShipToOrganization(String string)
Parameters:
string - The organization name to apply to the shipping address

setTitle

public void setTitle(String string)
Parameters:
string - The title of this order

setUser

public void setUser(User newUser)
Parameters:
newUser - WRITEME

toJSON

public org.json.JSONObject toJSON()
Description copied from interface: CastsToJSON
This returns a copy of the object's data cast into a JSON form.

Specified by:
toJSON in interface CastsToJSON
Overrides:
toJSON in class BaseDatum
Returns:
The string representing this object in JSON format
See Also:
BaseDatum.toJSON()