org.starhope.appius.pay
Class GiftCard

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
          extended by org.starhope.appius.pay.GiftCard

public class GiftCard
extends SQLPeerDatum

Author:
brpocock

Field Summary
private  com.sun.sgs.app.ManagedReference<Avatar> avatar
           
private  String code
           
private  com.sun.sgs.app.ManagedReference<User> createdBy
           
private  Date createdOn
           
private  Date expires
           
private  String memo
           
private static long serialVersionUID
           
private  com.sun.sgs.app.ManagedReference<User> usedBy
           
private  Date usedOn
           
 
Constructor Summary
GiftCard()
           
 
Method Summary
 void apply(User recipient)
          Syntactic sugar for apply (recipient, “now”)
 void apply(User recipient, Date applyOn)
           
static GiftCard get(String code)
           
 Avatar getAvatar()
           
 String getCode()
           
 Person getCreatedBy()
           
 Date getCreatedOn()
           
 Date getExpires()
           
 String getMemo()
           
 Person getUsedBy()
           
 Date getUsedOn()
           
 void set(org.json.JSONObject o)
           
 void setAvatar(Avatar avatar)
           
 void setCode(String newCode)
           
 void setCreatedBy(User newCreatedBy)
           
 void setCreatedOn(Date newCreatedOn)
           
 void setExpires(Date newExpires)
           
 void setMemo(String newMemo)
           
 void setUsedBy(User newUsedBy)
           
 void setUsedOn(Date newUsedOn)
           
 org.json.JSONObject toJSON()
           
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, flush, get, getCacheUniqueID, prepare, prepare, saveInCache, set
 
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
See Also:
Constant Field Values

avatar

private com.sun.sgs.app.ManagedReference<Avatar> avatar

code

private String code

createdBy

private com.sun.sgs.app.ManagedReference<User> createdBy

createdOn

private Date createdOn

expires

private Date expires

memo

private String memo

usedBy

private com.sun.sgs.app.ManagedReference<User> usedBy

usedOn

private Date usedOn
Constructor Detail

GiftCard

public GiftCard()
Method Detail

get

public static GiftCard get(String code)
                    throws RuntimeException,
                           NotFoundException
Parameters:
code - serial number of gift card
Returns:
gift card
Throws:
NotFoundException - if the gift card isn't found in the database
RuntimeException - if something bad happens

apply

public void apply(User recipient)
           throws AlreadyUsedException,
                  DataException
Syntactic sugar for apply (recipient, “now”)

Parameters:
recipient - The user who will receive the benefits of the gift card being applied
Throws:
DataException - if there is a problem with the data objects being used.
AlreadyUsedException - if the gift card has been used previously

apply

public void apply(User recipient,
                  Date applyOn)
           throws AlreadyUsedException,
                  DataException
Parameters:
recipient - The user who will receive the benefits of the gift card being applied
applyOn - The date and time at which the gift card's benefits are applied.
Throws:
AlreadyUsedException - if the gift card has been used previously
DataException - if there is a problem with the data objects being used.

getAvatar

public Avatar getAvatar()
Returns:
get the avatar associated with this gift card, if any

getCode

public String getCode()
Returns:
WRITEME

getCreatedBy

public Person getCreatedBy()
Returns:
WRITEME

getCreatedOn

public Date getCreatedOn()
Returns:
WRITEME

getExpires

public Date getExpires()
Returns:
WRITEME

getMemo

public String getMemo()
Returns:
WRITEME

getUsedBy

public Person getUsedBy()
Returns:
WRITEME

getUsedOn

public Date getUsedOn()
Returns:
WRITEME

set

public void set(org.json.JSONObject o)
Overrides:
set in class SQLPeerDatum
See Also:
CastsToJSON.set(org.json.JSONObject)

setAvatar

public void setAvatar(Avatar avatar)
               throws DataException
Parameters:
avatar - WRITEME
Throws:
DataException - WRITEME

setCode

public void setCode(String newCode)
Parameters:
newCode - WRITEME

setCreatedBy

public void setCreatedBy(User newCreatedBy)
Parameters:
newCreatedBy - WRITEME

setCreatedOn

public void setCreatedOn(Date newCreatedOn)
Parameters:
newCreatedOn - WRITEME

setExpires

public void setExpires(Date newExpires)
                throws DataException
Parameters:
newExpires - WRITEME
Throws:
DataException - WRITEME

setMemo

public void setMemo(String newMemo)
Parameters:
newMemo - WRITEME

setUsedBy

public void setUsedBy(User newUsedBy)
Parameters:
newUsedBy - WRITEME

setUsedOn

public void setUsedOn(Date newUsedOn)
               throws AlreadyUsedException,
                      DataException
Parameters:
newUsedOn - WRITEME
Throws:
AlreadyUsedException - WRITEME
DataException - WRITEME

toJSON

public org.json.JSONObject toJSON()
Overrides:
toJSON in class SQLPeerDatum
Returns:
See Also:
org.starhope.appius.util.BaseDatum#toJSON()