org.starhope.appius.user
Class Parent

java.lang.Object
  extended by org.starhope.appius.util.ManagedReferenceHolder
      extended by org.starhope.appius.sql.SQLPeerDatum
          extended by org.starhope.appius.user.Person
              extended by org.starhope.appius.user.Parent

public class Parent
extends Person

This class represents the parent of a kid or teen account User.getParent()

Author:
brpocock

Field Summary
private  Date mailConfirmSent
           
private  int parentID
          Database ID value
 
Fields inherited from class org.starhope.appius.user.Person
canContact, dialect, forgotPasswordAnswer, forgotPasswordQuestion, givenName, language, mail, mailConfirmed, password
 
Constructor Summary
Parent(ResultSet rs)
           
Parent(String parentMail)
          Create a new Parent record
Parent(String mail, String password)
          Create a new parent record and set an initial password at the same time
 
Method Summary
 boolean checkPassword(String passwordGuess)
          This is an overriding method.
 void flush()
           
static Parent getByID(int id)
           
static Parent getByMail(String mail)
           
protected  String getCacheUniqueID()
          This is an overriding method.
 User[] getChildren()
           
 String getDisplayName()
          This method's only use is for more closely aligning User and Parent classes.
 HashMap<Timestamp,HashMap<String,String>> getHistory(Date after, int limit)
          This is an overriding method.
 int getID()
          WRITEME: document this method (theys, Aug 10, 2009)
 String getName()
          WRITEME: document this method (twheys, Aug 05, 2009)
static Parent getOrCreateByMail(String parentMail)
           
 String getResponsibleMail()
          This is an overriding method.
private  void insert()
          WRITEME: document this method (brpocock, Aug 26, 2009)
 boolean isRegistered()
           
 void mailIsConfirmed()
           
protected  void remindPassword()
          WRITEME: document this method (brpocock, Aug 12, 2009) method to send e-mail to account owner (parent account or user account) with a reset password.
 void rename(String newName)
          This is an overriding method.
 void requestApproval(User user)
          WRITEME: document this method (brpocock, Jul 8, 2009)
 void sentConfirmationMail()
           
protected  void set(ResultSet rs)
           
 org.json.JSONObject toJSON()
          This is an overriding method.
 
Methods inherited from class org.starhope.appius.user.Person
forgotPassword, getDialect, getForgotPasswordAnswer, getForgotPasswordQuestion, getGivenName, getLanguage, getMail, getMailConfirmed, getPassword, getResponsiblePerson, setCanContact, setGivenName, setMail, setMailConfirmed, setPassword, setPasswordRecovery
 
Methods inherited from class org.starhope.appius.sql.SQLPeerDatum
changed, findInCache, get, 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

mailConfirmSent

private Date mailConfirmSent

parentID

private int parentID
Database ID value

Constructor Detail

Parent

public Parent(ResultSet rs)
Parameters:
rs - resultset describing a parent

Parent

public Parent(String parentMail)
Create a new Parent record

Parameters:
parentMail - the address of the parent

Parent

public Parent(String mail,
              String password)
       throws AlreadyUsedException,
              PrivilegeRequiredException
Create a new parent record and set an initial password at the same time

Parameters:
mail - mail address
password - password
Throws:
AlreadyUsedException - if the user has an existing account, and they know the password
PrivilegeRequiredException - if the mail exists, but the password is wrong
Method Detail

getByID

public static Parent getByID(int id)
Parameters:
id - database ID number
Returns:
the relevant Parent record (if it exists), or null if not.

getByMail

public static Parent getByMail(String mail)
Parameters:
mail - The parent's eMail address
Returns:
the relevant Parent record, or null if there is none

getOrCreateByMail

public static Parent getOrCreateByMail(String parentMail)
Parameters:
parentMail - the mail address for the parent
Returns:
a new parent record or existing one; never null.

checkPassword

public boolean checkPassword(String passwordGuess)
This is an overriding method.

Overrides:
checkPassword in class Person
Parameters:
passwordGuess - The password guess
Returns:
true if password is correct false if password is incorrect
See Also:
Person.checkPassword(java.lang.String)

flush

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

getCacheUniqueID

protected String getCacheUniqueID()
This is an overriding method.

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

getChildren

public User[] getChildren()
Returns:
all children associated with this parent

getDisplayName

public String getDisplayName()
Description copied from class: Person
This method's only use is for more closely aligning User and Parent classes. Since Parent class does not have a user name, it returns null.

Specified by:
getDisplayName in class Person
Returns:
null
See Also:
Person.getDisplayName()

getHistory

public HashMap<Timestamp,HashMap<String,String>> getHistory(Date after,
                                                            int limit)
This is an overriding method.

Specified by:
getHistory in class Person
Parameters:
after - If non-null, specifies the date after which we want to view records. To see all records, back to the creation of the user record, supply a null.
limit - If this is a positive number, it limits the results to this number of records.
Returns:
A map of timestamps to key/value pairs. All values are expressed as strings (even though they may have numeric, enumerative, or date / date-time types in the database), since this is primarily (only?) for human-viewable auditing.
See Also:
Person.getHistory(java.sql.Date, int)

getID

public int getID()
WRITEME: document this method (theys, Aug 10, 2009)

Returns:

getName

public String getName()
WRITEME: document this method (twheys, Aug 05, 2009)

Returns:

getResponsibleMail

public String getResponsibleMail()
This is an overriding method.

Specified by:
getResponsibleMail in class Person
Returns:
the eMail address
See Also:
Person.getResponsibleMail()

insert

private void insert()
WRITEME: document this method (brpocock, Aug 26, 2009)


isRegistered

public boolean isRegistered()

mailIsConfirmed

public void mailIsConfirmed()

remindPassword

protected void remindPassword()
Description copied from class: Person
WRITEME: document this method (brpocock, Aug 12, 2009) method to send e-mail to account owner (parent account or user account) with a reset password.

Specified by:
remindPassword in class Person
See Also:
Person.remindPassword()

rename

public void rename(String newName)
This is an overriding method.

Specified by:
rename in class Person
Parameters:
newName - The new user name
See Also:
Person.rename(java.lang.String)

requestApproval

public void requestApproval(User user)
WRITEME: document this method (brpocock, Jul 8, 2009)

Parameters:
user -

sentConfirmationMail

public void sentConfirmationMail()

set

protected void set(ResultSet rs)
            throws SQLException
Specified by:
set in class SQLPeerDatum
Throws:
SQLException - if the database fails somehow
See Also:
SQLPeerDatum.set(java.sql.ResultSet)

toJSON

public org.json.JSONObject toJSON()
This is an overriding method.

Overrides:
toJSON in class SQLPeerDatum
Returns:
See Also:
org.starhope.appius.sql.SQLPeerDatum#toAS()