Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Bacheloroppgave_2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eilert Tunheim
Bacheloroppgave_2022
Commits
5e4a8674
Commit
5e4a8674
authored
2 years ago
by
Eilert Tunheim
Browse files
Options
Downloads
Patches
Plain Diff
Added comments to AccountHandler.java file
parent
9a4c0d4e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/application/DB/AccountHandler.java
+47
-1
47 additions, 1 deletion
src/main/java/com/application/DB/AccountHandler.java
target/classes/META-INF/MANIFEST.MF
+3
-0
3 additions, 0 deletions
target/classes/META-INF/MANIFEST.MF
with
50 additions
and
1 deletion
src/main/java/com/application/DB/AccountHandler.java
+
47
−
1
View file @
5e4a8674
...
...
@@ -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
;
}
}
}
This diff is collapsed.
Click to expand it.
target/classes/META-INF/MANIFEST.MF
0 → 100644
+
3
−
0
View file @
5e4a8674
Manifest-Version: 1.0
Main-Class: com.application.Main
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment