diff --git a/Bachelor_application.iml b/Bachelor_application.iml index b94cb914ec5ad223d705dca95552625827a51c34..63536120db03a1f97595d415b676f8acde7073aa 100644 --- a/Bachelor_application.iml +++ b/Bachelor_application.iml @@ -58,13 +58,13 @@ <orderEntry type="library" name="Maven: org.jblas:jblas:1.2.4" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.13.2" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.8.2" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.8.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.9.0-M1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.9.0-M1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.8.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.9.0-M1" level="project" /> <orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.2" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.8.2" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.8.2" level="project" /> - <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.8.2" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.9.0-M1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.9.0-M1" level="project" /> + <orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.9.0-M1" level="project" /> </component> </module> \ No newline at end of file diff --git a/src/main/java/com/application/DB/HelpingFunctions.java b/src/main/java/com/application/DB/HelpingFunctions.java index a354a794e847db5b5796e47922aeca2b7fc896bd..8f843ccd21d456af2ccc52c8da34ed11135da2ae 100644 --- a/src/main/java/com/application/DB/HelpingFunctions.java +++ b/src/main/java/com/application/DB/HelpingFunctions.java @@ -184,7 +184,7 @@ public static boolean isValidInput (String input){ NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!"); return true; } - else if(input.contains("UNION")){ + else if(input.toLowerCase().contains("union")){ NotificationPopUp.displayNotificationWindow("Keyword: 'UNION' is not allowed"); return true; } diff --git a/src/main/java/com/application/GUI/PopUpWindows/InputPopup.java b/src/main/java/com/application/GUI/PopUpWindows/InputPopup.java index fe07431d0739826764285cbccabbde1a73fd8b2f..5059812c1319c0ef145c3e3d5be0641e6d101906 100644 --- a/src/main/java/com/application/GUI/PopUpWindows/InputPopup.java +++ b/src/main/java/com/application/GUI/PopUpWindows/InputPopup.java @@ -134,38 +134,42 @@ public class InputPopup { if(getLogin().getText().equals("Login")){ err = true; + NotificationPopUp.displayNotificationWindow("Please login!"); } // If the input is null, sets the value to be empty if (treeSpeciesList.getValue() == null) { Constants.TREE_SPECIES = ""; - } else if (isValidInput(treeSpeciesList.getValue())) { - treeSpeciesList.setValue(""); - err = true; } - if (dimensionsList.getValue() == null) { Constants.DIMENSIONS = ""; - } else if (dimensionsList.getValue().length() > MAX_USER_INPUT_CHARACTERS) { - NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!"); - dimensionsList.setValue(""); - err = true; } - if (sawsetList.getValue() == null) { Constants.SAWSET = ""; - } else if (sawsetList.getValue().length() > MAX_USER_INPUT_CHARACTERS) { - NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!"); - sawsetList.setValue(""); - err = true; } - if (moistureList.getValue() == null) { Constants.MOISTURE_GOAL = ""; - } else if (moistureList.getValue().length() > MAX_USER_INPUT_CHARACTERS) { - NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!"); - moistureList.setValue(""); + } + + System.out.println(getLogin().getText()); + + System.out.println("TREE_SPECIES: "+ Constants.TREE_SPECIES); + System.out.println("DIMENSIONS: "+ Constants.DIMENSIONS); + System.out.println("SAWSET: "+ Constants.SAWSET); + System.out.println("MOISTURE_GOAL: "+ Constants.MOISTURE_GOAL); + + // Validates inputs + if(isValidInput(Constants.TREE_SPECIES) || + isValidInput(Constants.DIMENSIONS) || + isValidInput(Constants.SAWSET) || + isValidInput(Constants.MOISTURE_GOAL)) { + err = true; + + treeSpeciesList.setValue(""); + dimensionsList.setValue(""); + sawsetList.setValue(""); + moistureList.setValue(""); } @@ -249,7 +253,7 @@ public class InputPopup { } } else { - NotificationPopUp.displayNotificationWindow("Please login!"); + } } diff --git a/src/main/java/com/application/GUI/PopUpWindows/LoginPopup.java b/src/main/java/com/application/GUI/PopUpWindows/LoginPopup.java index 4efc31586ad18c9cce9da6f8e8e724a9cbf4ee87..5f1312a1075f7859792055d525113c9d01bd5c34 100644 --- a/src/main/java/com/application/GUI/PopUpWindows/LoginPopup.java +++ b/src/main/java/com/application/GUI/PopUpWindows/LoginPopup.java @@ -15,6 +15,7 @@ import java.security.MessageDigest; import static com.application.DB.AccountHandler.*; import static com.application.DB.Constants.*; +import static com.application.DB.HelpingFunctions.isValidInput; import static com.application.GUI.Panes.CreateLogoBar.getLogin; public class LoginPopup { @@ -57,16 +58,20 @@ public class LoginPopup { closeButton.setOnAction(event -> window.close()); getPasswordTextField().setOnKeyPressed( event -> { - if( event.getCode() == KeyCode.ENTER ) { - if(loginButtonPressed()){ - window.close(); + if (event.getCode() == KeyCode.ENTER) { + if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) { + if (loginButtonPressed()) { + window.close(); + } } } }); loginButton.setOnAction(event -> { - if(loginButtonPressed()){ - window.close(); + if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) { + if (loginButtonPressed()) { + window.close(); + } } }); @@ -150,6 +155,13 @@ public class LoginPopup { close.setOnAction(event -> window.close()); addUser.setOnAction(event -> { + // Validate input parameters + if(!isValidInput(firstNameTextField.getText()) && + !isValidInput(lastNameTextField.getText()) && + !isValidInput(phoneNoTextField.getText()) && + !isValidInput(usernameTextField.getText()) && + !isValidInput(passwordFirstField.getText()) && + !isValidInput(passwordSecondField.getText())) { // If the passwords match each other, add the user, if not display an errormessage if(passwordFirstField.getText().contentEquals(passwordSecondField.getText())){ @@ -166,7 +178,7 @@ public class LoginPopup { } catch (Exception e) { e.printStackTrace(); } - } else { + } }else { NotificationPopUp.displayNotificationWindow("Passwords does not match!"); passwordFirstField.clear(); passwordSecondField.clear(); @@ -202,17 +214,19 @@ public class LoginPopup { close.setOnAction(event -> window.close()); delete.setOnAction(event -> { - try { - boolean results = deleteUser(usernameTextField.getText()); - if(results){ - NotificationPopUp.displayNotificationWindow(usernameTextField.getText()+" was successfully deleted!"); - window.close(); - } else { - NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText()); - usernameTextField.clear(); + if(!isValidInput(usernameTextField.getText())) { + try { + boolean results = deleteUser(usernameTextField.getText()); + if (results) { + NotificationPopUp.displayNotificationWindow(usernameTextField.getText() + " was successfully deleted!"); + window.close(); + } else { + NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText()); + usernameTextField.clear(); + } + } catch (Exception e) { + e.printStackTrace(); } - } catch (Exception e) { - e.printStackTrace(); } }); diff --git a/src/main/java/com/application/GUI/PopUpWindows/OutputPopup.java b/src/main/java/com/application/GUI/PopUpWindows/OutputPopup.java index 9c4409b1b609c912b4c16e0e06c6051f3d2c4679..713900efeea7023f25f5b66442ffb399c21b209e 100644 --- a/src/main/java/com/application/GUI/PopUpWindows/OutputPopup.java +++ b/src/main/java/com/application/GUI/PopUpWindows/OutputPopup.java @@ -16,6 +16,7 @@ import java.time.format.DateTimeFormatter; import static com.application.DB.Constants.IS_FINISHED; import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS; +import static com.application.DB.HelpingFunctions.isValidInput; public class OutputPopup { @@ -47,7 +48,8 @@ public class OutputPopup { boolean err = false; - if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ + // Validates inputs + if(isValidInput(moistureCheckTextField.getText())){ err = true; } @@ -82,7 +84,8 @@ public class OutputPopup { boolean err = false; - if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ + // Validates inputs + if(isValidInput(moistureCheckTextField.getText())){ err = true; } diff --git a/target/classes/com/application/DB/HelpingFunctions.class b/target/classes/com/application/DB/HelpingFunctions.class index 3db47b64dd3c30a11b99162c38704a8751a7d22f..ae99dc9d15f57f1214760b1ba7f59755aafca7d2 100644 Binary files a/target/classes/com/application/DB/HelpingFunctions.class and b/target/classes/com/application/DB/HelpingFunctions.class differ diff --git a/target/classes/com/application/GUI/PopUpWindows/InputPopup.class b/target/classes/com/application/GUI/PopUpWindows/InputPopup.class index 728dd498b6efc1a0bb249930929c014285629008..62565f7fd11a5290ee8e17ea4cd00fa91f1b4bb7 100644 Binary files a/target/classes/com/application/GUI/PopUpWindows/InputPopup.class and b/target/classes/com/application/GUI/PopUpWindows/InputPopup.class differ diff --git a/target/classes/com/application/GUI/PopUpWindows/LoginPopup.class b/target/classes/com/application/GUI/PopUpWindows/LoginPopup.class index c996a60c651e42f69b920f53c8fe40bb2b883af8..1fec1563ecd6919aee728f1c9762d233ca864312 100644 Binary files a/target/classes/com/application/GUI/PopUpWindows/LoginPopup.class and b/target/classes/com/application/GUI/PopUpWindows/LoginPopup.class differ diff --git a/target/classes/com/application/GUI/PopUpWindows/OutputPopup.class b/target/classes/com/application/GUI/PopUpWindows/OutputPopup.class index 7ed71568a3e74e47d6847f4f79edaffe2bfb1c97..cc1f1de4c84853d331977ef9d8d66bb7f2d983a8 100644 Binary files a/target/classes/com/application/GUI/PopUpWindows/OutputPopup.class and b/target/classes/com/application/GUI/PopUpWindows/OutputPopup.class differ