diff --git a/src/main/java/com/application/DB/AccountHandler.java b/src/main/java/com/application/DB/AccountHandler.java index 7c38d7daa53a7fb829153700face33bd79ae1e1b..ead7643810d8a9f72887e2908cff68d6d0f6107b 100644 --- a/src/main/java/com/application/DB/AccountHandler.java +++ b/src/main/java/com/application/DB/AccountHandler.java @@ -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; } } - } diff --git a/target/classes/META-INF/MANIFEST.MF b/target/classes/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..797d99b7b0f4c83c466174cd972c3ce28a801788 --- /dev/null +++ b/target/classes/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.application.Main +