com.tootsville.promo
Class PeanutCode

java.lang.Object
  extended by org.starhope.appius.sql.SQLPeerDatum
      extended by com.tootsville.promo.PeanutCode
All Implemented Interfaces:
Serializable, Comparable<Object>

public class PeanutCode
extends SQLPeerDatum

Peanut Codes are hang-tags associated with various products, printed with unique serial numbers.

Author:
Tim Heys
See Also:
Serialized Form

Field Summary
private  Timestamp issued
           
private  BigDecimal maxPeanuts
           
private  BigDecimal minPeanuts
           
private  String peanutCode
           
private  int redeemedByID
           
private  Timestamp redeemedOn
           
private  int serialID
           
private static long serialVersionUID
          Java serialisation unique ID
 
Constructor Summary
PeanutCode(ResultSet rs)
           twheys@gmail.com Jan 7, 2010
PeanutCode(String pnutCodeSerial)
           twheys@gmail.com Jan 7, 2010
PeanutCode(String pnutCodeSerial, int minValue, int maxValue)
           twheys@gmail.com Jan 7, 2010
 
Method Summary
 void flush()
           
static PeanutCode getByPeanutCode(String serialNumber)
           twheys@gmail.com Jan 7, 2010
protected  String getCacheUniqueID()
           
 int getID()
           
 Timestamp getIssued()
           
 BigDecimal getMaxPeanuts()
           
 BigDecimal getMinPeanuts()
           
 String getPeanutCode()
           
 int getRedeemedByID()
           
 Timestamp getRedeemedOn()
           
private  BigDecimal getRedeemValue()
           twheys@gmail.com Jan 7, 2010
private  void insert()
          WRITEME
 boolean isRedeemed()
           twheys@gmail.com Jan 7, 2010
private  void redeem(int redeemerID)
           twheys@gmail.com Jan 7, 2010
static BigInteger redeemPeanutCode(GeneralUser redeemer, String peanutCode)
           twheys@gmail.com Jan 7, 2010
protected  void set(ResultSet rs)
           
 void setMaxPeanuts(BigDecimal newMaxPeanuts)
           
 void setMinPeanuts(BigDecimal newMinPeanuts)
           
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, compareTo, findInCache, saveInCache, set, toJSON
 
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
Java serialisation unique ID

See Also:
Constant Field Values

issued

private Timestamp issued

maxPeanuts

private BigDecimal maxPeanuts

minPeanuts

private BigDecimal minPeanuts

peanutCode

private String peanutCode

redeemedByID

private int redeemedByID

redeemedOn

private Timestamp redeemedOn

serialID

private int serialID
Constructor Detail

PeanutCode

public PeanutCode(ResultSet rs)
 twheys@gmail.com Jan 7, 2010
 
A PeanutCode WRITEME...

Parameters:
rs - WRITEME

PeanutCode

public PeanutCode(String pnutCodeSerial)
 twheys@gmail.com Jan 7, 2010
 
A PeanutCode WRITEME...

Parameters:
pnutCodeSerial - WRITEME

PeanutCode

public PeanutCode(String pnutCodeSerial,
                  int minValue,
                  int maxValue)
 twheys@gmail.com Jan 7, 2010
 
A PeanutCode WRITEME...

Parameters:
pnutCodeSerial - WRITEME
minValue - WRITEME
maxValue - WRITEME
Method Detail

getByPeanutCode

public static PeanutCode getByPeanutCode(String serialNumber)
                                  throws NotFoundException
 twheys@gmail.com Jan 7, 2010
 
TO getByPeanutCode WRITEME...

Parameters:
serialNumber - WRITEME
Returns:
WRITEME
Throws:
NotFoundException - WRITEME

redeemPeanutCode

public static BigInteger redeemPeanutCode(GeneralUser redeemer,
                                          String peanutCode)
                                   throws NotFoundException,
                                          AlreadyUsedException
 twheys@gmail.com Jan 7, 2010
 
TO redeemPeanutCode WRITEME...

Parameters:
redeemer - WRITEME
peanutCode - WRITEME
Returns:
WRITEME
Throws:
NotFoundException - WRITEME
AlreadyUsedException - WRITEME

flush

public void flush()
Specified by:
flush in class SQLPeerDatum
See Also:
SQLPeerDatum.flush()

getCacheUniqueID

protected String getCacheUniqueID()
Specified by:
getCacheUniqueID in class SQLPeerDatum
Returns:
The local (Stringified) version of an unique ID; usually the database ID column
See Also:
SQLPeerDatum.getCacheUniqueID()

getID

public int getID()
Returns:
the id

getIssued

public Timestamp getIssued()
Returns:
the issued

getMaxPeanuts

public BigDecimal getMaxPeanuts()
Returns:
the maxPeanuts

getMinPeanuts

public BigDecimal getMinPeanuts()
Returns:
the minPeanuts

getPeanutCode

public String getPeanutCode()
Returns:
the peanutCode

getRedeemedByID

public int getRedeemedByID()
Returns:
the redeemedByID

getRedeemedOn

public Timestamp getRedeemedOn()
Returns:
the redeemedOn

getRedeemValue

private BigDecimal getRedeemValue()
 twheys@gmail.com Jan 7, 2010
 
TO getRedeemValue WRITEME...

Returns:
WRITEME

insert

private void insert()
WRITEME


isRedeemed

public boolean isRedeemed()
 twheys@gmail.com Jan 7, 2010
 
TO isRedeemed WRITEME...

Returns:
WRITEME

redeem

private void redeem(int redeemerID)
 twheys@gmail.com Jan 7, 2010
 
TO redeem WRITEME...

Parameters:
redeemerID - WRITEME

set

protected void set(ResultSet rs)
            throws SQLException
Specified by:
set in class SQLPeerDatum
Parameters:
rs - The result of an SQL query, with the cursor already pointed at the row describing this specific instance of the object.
Throws:
SQLException - if the database fails somehow
See Also:
SQLPeerDatum.set(java.sql.ResultSet)

setMaxPeanuts

public void setMaxPeanuts(BigDecimal newMaxPeanuts)
Parameters:
newMaxPeanuts - the maxPeanuts to set

setMinPeanuts

public void setMinPeanuts(BigDecimal newMinPeanuts)
Parameters:
newMinPeanuts - the minPeanuts to set