Menu

DatabaseCalls

Stephen Bromley

DatabaseCalls

Class stub used to make all database calls

Constructors

Methods

login:
Expected arguments: Connection conn, String username, String password
Return type: User

Queries the database for a user with the provided w number and matching password. Returns this user if they exist returns null if they don't.

getAllUsers:
Expected arguments: Connection conn
Return type: Map(String, User)

Returns a map of key string w number value user containing all users in the database.

createuser:
Expected arguments: Connection conn, String wNumber, String firstName, String lastName, String email, Date year, boolean isAdmin
Return type: Boolean

Creates a user in the database and sets a default password of first name initial last name initial and last four numbers of the w number example = "John Doe w01234567 password is jd4567". Returns true if successful false if fails.

updateUser:
Expected arguments: Connection conn, String wNumber, String firstName, String lastName, String email, Date year, boolean isAdmin
Return type: User

Updates a user with the matching W number with the provided information.

changePassword:
Expected arguments: Connection conn, String wNumber, String theNewPassword
Return type: Boolean

Changes the users password to the provided password. Returns true if succeeds false on fail.

updateForm:
Expected arguments:Connection conn, String theFormName, String theFormHtml, int theFormId, String wNumber
Return type:Boolean

Updates a user form.

userToBeEdited:
Expected arguments: Connection conn, String wNumber
Return type: User

Returns a user to be edited.

changePassword:
Expected arguments: Connection conn, String wNumber, String theNewPassword
Return type: Boolean

Changes a users password

getAllForms:
Expected arguments: Connection conn, String userID
Return type: Map<Integer,Form>

Returns a map of all a users forms.

createForm:
Expected arguments: Connection conn, String formHTML, String userID, Date lastEdit, String formName
Return type: Boolean

Creates a form tied to the given user.

createTemplate:
Expected arguments: Connection conn, String templateName, String templateHTML, String templateType
Return type: Boolean

Creates a new template in the database.

updateTemplate:
Expected arguments: Connection conn, int templateID, String templateName
Return type: Boolean

Updates a template with the given name. This updated template is a new entry in the database with a higher version number.

getAllTemplates:
Expected arguments: Connection conn
Return type: Map<Integer, TherapyTemplate="">

Returns a map of all active templates and the previous version of those templates.

generatePDF:
Expected arguments: Connection conn, String userID, int formID
Return type: String

Returns the string version of a forms html. THIS FUNCTION IS NOT USED AT THIS TIME.


Related

Wiki: Home
Wiki: ServletForms
Wiki: ServletTherapy
Wiki: ServletUser