#8: Cleanup & Javadoc
Some checks failed
Quality Check / Linting Check (push) Failing after 15s
Quality Check / Linting Check (pull_request) Failing after 21s
Quality Check / Javadoc Check (push) Successful in 37s
Quality Check / Javadoc Check (pull_request) Successful in 34s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-05-22 09:49:52 +02:00
parent 7db1c83a08
commit 680e9c3f10
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
6 changed files with 51 additions and 10 deletions

View file

@ -37,10 +37,17 @@ public class Main extends Application {
@Override
public void start(Stage primaryStage) {
this.primaryStage = primaryStage;
executePassword();
User user = executeLogin();
if(user != null){
executeMainApplication(user);
}
}
private void executePassword() {
/**
* Executes the login.
* @return User The {@link User} object for the logged-in {@link User}. Is {@code null}, if the login was not successful,
*/
private User executeLogin() {
try {
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/login/LoginView.fxml"));
@ -55,12 +62,10 @@ public class Main extends Application {
controller.initialize(loginStage);
loginStage.showAndWait();
if(controller.user != null){
executeMainApplication(controller.user);
}
return controller.user;
} catch (IOException exception) {
exception.printStackTrace();
return null;
}
}

View file

@ -13,6 +13,11 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.*;
/**
* {@link Fixture} for {@link User}.
*
* @author Dominik Säume
*/
public class UserFixture implements Fixture<User> {
private static final String SCHEMA = "/de/hitec/nhplus/login/database/User.sql";
private static final String PERMISSION_SCHEMA = "/de/hitec/nhplus/login/database/UserPermission.sql";

View file

@ -1,5 +1,11 @@
package de.hitec.nhplus.login;
/**
* A simple class holding the bitmasks for all permissions.
* This is a class instead of an enum, for ease of use.
*
* @author Dominiok Säume
*/
public class Permissions {
public final static int EVERYBODY = 0b0;
public final static int NURSE = 0b1;

View file

@ -7,8 +7,13 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class User {
/**
* The model for a {@link User}.
*
* @author Dominik Säume
*/
public class User {
private int id;
private String username;
@ -17,6 +22,10 @@ public class User {
private int permissions = 0;
private Nurse nurse;
/**
* This constructor allows instantiating a {@link User} object with all existing fields.
*/
public User(
int id,
String username,
@ -33,6 +42,9 @@ public class User {
this.nurse = nurse;
}
/**
* This constructor allows instantiating a {@link User} object.
*/
public User(
String username,
int permissions,
@ -42,6 +54,12 @@ public class User {
this.permissions = permissions;
this.nurse = nurse;
}
/**
* Sets the {@link User} password. The {@link User} will need to be manually stored with the
* {@link de.hitec.nhplus.login.database.UserDao UserDao}, for changes to persists.
* @param password The new Password
*/
public void setPassword(String password) {
try {
SecureRandom random = new SecureRandom();
@ -59,6 +77,7 @@ public class User {
public boolean hasNursePermissions(){
return (permissions & Permissions.NURSE) != 0;
}
public boolean hasAdminPermissions(){
return (permissions & Permissions.MANAGEMENT) != 0;
}

View file

@ -44,7 +44,7 @@ public class Nurse extends Person {
/**
* This constructor allows instantiating a {@link Nurse} object with
* specifying if the nurse is locked or not.
* specifying whether the {@link Nurse} is locked or not.
*/
public Nurse(
String firstName,

View file

@ -1,5 +1,11 @@
package de.hitec.nhplus.utils.tab;
/**
* A simple class holding the data needed for constructing a tab.
*
* @author Dominiok Säume
* @see TabManager
*/
public class TabStruct {
public String title;
public String view;