Skip to content
Snippets Groups Projects
Commit 5e4a8674 authored by Eilert Tunheim's avatar Eilert Tunheim
Browse files

Added comments to AccountHandler.java file

parent 9a4c0d4e
Branches
No related tags found
No related merge requests found
......@@ -9,8 +9,21 @@ import static com.application.DB.Constants.*;
import static com.application.DB.Settings.*;
import static com.application.GUI.PopUpWindows.LoginPopup.getPasswordTextField;
/**
* This class handles the login system and all related functionality
*
* @author Eilert Tunheim, Karin Pettersen, Mads Arnesen
* @version 1.0.0
*/
public class AccountHandler {
/**
* This function iterates through the results and sets the information
*
* @param username input parameter for the username
* @param password input parameter for the password
* @throws Exception throws exception if anything goes wrong
*/
public static void getAccountInformation(String username, String password) throws Exception {
TableResult result = logIn(username,password);
......@@ -42,6 +55,14 @@ public class AccountHandler {
}
}
/**
* This function creates the login sql statement and returns a TableResult to be iterated through
*
* @param username input parameter for the username
* @param password input parameter for the password
* @return a TableResult that can be iterated through
* @throws Exception throws exception if anything goes wrong
*/
public static TableResult logIn(String username, String password) throws Exception {
// Sqlstatement
......@@ -56,6 +77,13 @@ public class AccountHandler {
return HelpingFunctions.createQueryJob(sqlStatement);
}
/**
* Retrieves information regarding an account based on the username input
*
* @param username input parameter for the username
* @return a TableResult that can be iterated through
* @throws Exception throws exception if anything goes wrong
*/
public static TableResult getAccount(String username) throws Exception {
// Sqlstatement
......@@ -70,6 +98,18 @@ public class AccountHandler {
return HelpingFunctions.createQueryJob(sqlStatement);
}
/**
* This function takes a number of parameters as input and creates a user in the database
*
* @param firstName input parameter for firstname
* @param lastName input parameter for lastName
* @param phoneNo input parameter for phoneNo
* @param username input parameter for username
* @param password input parameter for password
* @param isAdmin input parameter from the checkbox is the account is admin or not
* @return a boolean if the user was added or not
* @throws Exception throws exception if anything goes wrong
*/
public static boolean addUser(String firstName, String lastName, String phoneNo, String username, String password, boolean isAdmin) throws Exception {
if(getAccount(username).getTotalRows() == 0) {
......@@ -87,6 +127,13 @@ public class AccountHandler {
}
}
/**
* This function deletes an account based on the username input parameter
*
* @param username input parameter for username
* @return a boolean if the user was deleted or not
* @throws Exception throws exception if anything goes wrong
*/
public static boolean deleteUser(String username) throws Exception {
if(getAccount(username).getTotalRows() != 0){
......@@ -102,5 +149,4 @@ public class AccountHandler {
return false;
}
}
}
Manifest-Version: 1.0
Main-Class: com.application.Main
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment