Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mesji/bacheloroppgave_2022
1 result
Show changes
Commits on Source (15)
Showing
with 322 additions and 90 deletions
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
...@@ -55,5 +56,15 @@ ...@@ -55,5 +56,15 @@
<orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.commons:commons-math3:3.6.1" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.10.14" level="project" />
<orderEntry type="library" name="Maven: org.jblas:jblas:1.2.4" level="project" /> <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.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.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.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> </component>
</module> </module>
\ No newline at end of file
...@@ -46,6 +46,34 @@ ...@@ -46,6 +46,34 @@
<version>1.2.4</version> <version>1.2.4</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>11</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
......
...@@ -9,7 +9,7 @@ import static com.application.DB.Constants.*; ...@@ -9,7 +9,7 @@ import static com.application.DB.Constants.*;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
import static com.application.GUI.PopUpWindows.LoginPopup.getPasswordTextField; import static com.application.GUI.PopUpWindows.LoginPopup.getPasswordTextField;
public class Account_handler { public class AccountHandler {
public static void getAccountInformation(String username, String password) throws Exception { public static void getAccountInformation(String username, String password) throws Exception {
...@@ -63,21 +63,28 @@ public class Account_handler { ...@@ -63,21 +63,28 @@ public class Account_handler {
"FROM " + PROJECT_ID + "." + LOCATION_ID + "." + USERS_TABLE_NAME + " " + "FROM " + PROJECT_ID + "." + LOCATION_ID + "." + USERS_TABLE_NAME + " " +
"WHERE Username = " + '"' + username + '"'; "WHERE Username = " + '"' + username + '"';
System.out.println(sqlStatement); System.out.println(sqlStatement);
// Retrieves the results from the queryjob // Retrieves the results from the queryjob
return HelpingFunctions.createQueryJob(sqlStatement); return HelpingFunctions.createQueryJob(sqlStatement);
} }
public static void addUser(String firstName, String lastName, String phoneNo, String username, String password, boolean isAdmin) throws Exception { public static boolean addUser(String firstName, String lastName, String phoneNo, String username, String password, boolean isAdmin) throws Exception {
if(getAccount(username).getTotalRows() == 0) {
// Sqlstatement // Sqlstatement
final String sqlStatement = final String sqlStatement =
"INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + USERS_TABLE_NAME + "(First_name, Last_name, Phone_no, Username, Password, Admin) " + "INSERT INTO " + PROJECT_ID + "." + LOCATION_ID + "." + USERS_TABLE_NAME + "(First_name, Last_name, Phone_no, Username, Password, Admin) " +
"VALUES("+'"'+firstName+'"'+","+'"'+lastName+'"'+","+'"'+phoneNo+'"'+","+'"'+username+'"'+","+'"'+password+'"'+","+ isAdmin+") "; "VALUES(" + '"' + firstName + '"' + "," + '"' + lastName + '"' + "," + '"' + phoneNo + '"' + "," + '"' + username + '"' + "," + '"' + password + '"' + "," + isAdmin + ") ";
System.out.println(sqlStatement); System.out.println(sqlStatement);
HelpingFunctions.createQueryJob(sqlStatement); HelpingFunctions.createQueryJob(sqlStatement);
return true;
} else {
return false;
}
} }
public static boolean deleteUser(String username) throws Exception { public static boolean deleteUser(String username) throws Exception {
......
...@@ -41,9 +41,7 @@ public class Constants { ...@@ -41,9 +41,7 @@ public class Constants {
private static String userName; private static String userName;
private static String phoneNo; private static String phoneNo;
public static String getUserName() { public static String getUserName() { return userName;}
return userName;
}
public static void setUserName(String userName) { public static void setUserName(String userName) {
Constants.userName = userName; Constants.userName = userName;
......
package com.application.DB; package com.application.DB;
import com.application.GUI.PopUpWindows.NotificationPopUp;
import com.google.auth.oauth2.GoogleCredentials; import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.oauth2.ServiceAccountCredentials; import com.google.auth.oauth2.ServiceAccountCredentials;
import com.google.cloud.bigquery.*; import com.google.cloud.bigquery.*;
import io.opencensus.internal.StringUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -12,8 +14,10 @@ import java.util.Map; ...@@ -12,8 +14,10 @@ import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import static com.application.DB.Constants.KEY_FILE_NAME; import static com.application.DB.Constants.KEY_FILE_NAME;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
public class HelpingFunctions { public class HelpingFunctions {
...@@ -173,4 +177,22 @@ public class HelpingFunctions { ...@@ -173,4 +177,22 @@ public class HelpingFunctions {
public static void setLoadedData(boolean loadedData) { public static void setLoadedData(boolean loadedData) {
Constants.LOADED_DATA = loadedData; Constants.LOADED_DATA = loadedData;
} }
public static boolean isValidInput (String input){
if(input.length() > Constants.MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
return true;
}
else if(input.toLowerCase().contains("union")){
NotificationPopUp.displayNotificationWindow("Keyword: 'UNION' is not allowed");
return true;
}
else return false;
}
} }
...@@ -20,16 +20,14 @@ public final class Settings { ...@@ -20,16 +20,14 @@ public final class Settings {
public static int NUMBER_OF_SECONDS_LIVE_DATA = 60; public static int NUMBER_OF_SECONDS_LIVE_DATA = 60;
// Confidence interval // Confidence interval
public static final double CONFIDENCE_INTERVAL = 0.80; public static final double CONFIDENCE_INTERVAL = 0.95;
// Current sawmill settings; // Current sawmill settings;
public static final String PROJECT_ID = "sf-drying-optimization"; public static final String PROJECT_ID = "sf-drying-optimization";
public static final int LOCATION_ID = 124; public static final int LOCATION_ID = 124;
public static final String MAN_MOISTURE_TABLE = "int_dk_manMoisture"; public static final String MAN_MOISTURE_TABLE = "int_dk_manMoisture";
public static final String KWH_TABLE_NAME = "int_sd_winccsensordata"; public static final String KWH_TABLE_NAME = "int_sd_winccsensordata";
public static final String USERS_TABLE_NAME = "users"; public static String USERS_TABLE_NAME = "users";
public static final String KWH_NAME_PARAMETER = "VariantValue"; public static final String KWH_NAME_PARAMETER = "VariantValue";
public static final String KWH_TIMESTAMP_NAME_PARAMETER = "Timestamp"; public static final String KWH_TIMESTAMP_NAME_PARAMETER = "Timestamp";
public static final String KWH_VALUE_ID_NAME_PARAMETER = "ValueID"; public static final String KWH_VALUE_ID_NAME_PARAMETER = "ValueID";
......
...@@ -318,6 +318,7 @@ public class LineChartFunctionality { ...@@ -318,6 +318,7 @@ public class LineChartFunctionality {
} }
} }
getRegressionSeriesConfidenceInterval().getData().clear();
Map<Integer, ArrayList<Double>> confidenceIntervalShadow = statistics(multiMap,true); Map<Integer, ArrayList<Double>> confidenceIntervalShadow = statistics(multiMap,true);
for ( Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalShadow.entrySet()) { for ( Map.Entry<Integer, ArrayList<Double>> entry : confidenceIntervalShadow.entrySet()) {
for (int i = 0; i < entry.getValue().size(); i++) { for (int i = 0; i < entry.getValue().size(); i++) {
......
...@@ -87,6 +87,7 @@ public class CreateSideBar { ...@@ -87,6 +87,7 @@ public class CreateSideBar {
RingProgressIndicator ringProgressIndicator = new RingProgressIndicator(); RingProgressIndicator ringProgressIndicator = new RingProgressIndicator();
ringProgressIndicator.setRingWidth(100); ringProgressIndicator.setRingWidth(100);
ringProgressIndicator.makeIndeterminate(); ringProgressIndicator.makeIndeterminate();
ringProgressIndicator.setId("progressBar");
class WorkerThread extends Thread{ class WorkerThread extends Thread{
RingProgressIndicator rpi; RingProgressIndicator rpi;
......
...@@ -14,11 +14,13 @@ import java.time.LocalDateTime; ...@@ -14,11 +14,13 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Map; import java.util.Map;
import static com.application.DB.HelpingFunctions.isValidInput;
import static com.application.DB.Settings.*; import static com.application.DB.Settings.*;
import static com.application.DB.DB.getCurrentDrying; import static com.application.DB.DB.getCurrentDrying;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS; import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.HelpingFunctions.setLoadedData; import static com.application.DB.HelpingFunctions.setLoadedData;
import static com.application.GUI.LineChartFunctionality.*; import static com.application.GUI.LineChartFunctionality.*;
import static com.application.GUI.Panes.CreateLogoBar.getLogin;
import static com.application.Main.*; import static com.application.Main.*;
import static com.application.DB.DB.setInputParameters; import static com.application.DB.DB.setInputParameters;
...@@ -31,7 +33,6 @@ import static com.application.DB.DB.setInputParameters; ...@@ -31,7 +33,6 @@ import static com.application.DB.DB.setInputParameters;
*/ */
public class InputPopup { public class InputPopup {
public static void display() { public static void display() {
Stage window = new Stage(); Stage window = new Stage();
...@@ -127,39 +128,48 @@ public class InputPopup { ...@@ -127,39 +128,48 @@ public class InputPopup {
Constants.MOISTURE_GOAL = moistureList.getValue(); Constants.MOISTURE_GOAL = moistureList.getValue();
} }
boolean err = false; boolean err = false;
if(getLogin().getText().equals("Login")){
err = true;
NotificationPopUp.displayNotificationWindow("Please login!");
}
// If the input is null, sets the value to be empty // If the input is null, sets the value to be empty
if (treeSpeciesList.getValue() == null) { if (treeSpeciesList.getValue() == null) {
Constants.TREE_SPECIES = ""; Constants.TREE_SPECIES = "";
} else if (treeSpeciesList.getValue().length() > MAX_USER_INPUT_CHARACTERS) {
NotificationPopUp.displayNotificationWindow("A maximum of "+MAX_USER_INPUT_CHARACTERS+" characters is allowed!");
treeSpeciesList.setValue("");
err = true;
} }
if (dimensionsList.getValue() == null) { if (dimensionsList.getValue() == null) {
Constants.DIMENSIONS = ""; 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) { if (sawsetList.getValue() == null) {
Constants.SAWSET = ""; 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) { if (moistureList.getValue() == null) {
Constants.MOISTURE_GOAL = ""; 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; err = true;
treeSpeciesList.setValue("");
dimensionsList.setValue("");
sawsetList.setValue("");
moistureList.setValue("");
} }
...@@ -242,7 +252,9 @@ public class InputPopup { ...@@ -242,7 +252,9 @@ public class InputPopup {
ex.printStackTrace(); ex.printStackTrace();
} }
} } else {
}
} }
); );
......
package com.application.GUI.PopUpWindows; package com.application.GUI.PopUpWindows;
import javafx.event.EventHandler;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -10,13 +13,35 @@ import javafx.stage.Stage; ...@@ -10,13 +13,35 @@ import javafx.stage.Stage;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import static com.application.DB.Account_handler.*; import static com.application.DB.AccountHandler.*;
import static com.application.DB.Constants.*; import static com.application.DB.Constants.*;
import static com.application.DB.HelpingFunctions.isValidInput;
import static com.application.GUI.Panes.CreateLogoBar.getLogin; import static com.application.GUI.Panes.CreateLogoBar.getLogin;
public class LoginPopup { public class LoginPopup {
public static PasswordField PASSWORD_TEXT_FIELD = new PasswordField(); private static PasswordField PASSWORD_TEXT_FIELD = new PasswordField();
private static TextField USERNAME_TEXT_FIELD = new TextField();
/**
* Tries to login
*
* @return a boolean if an error should be thrown or not. True gives no error, false throws an error.
*/
private static boolean loginButtonPressed(){
try {
getAccountInformation(getUsernameTextField().getText(), hashPassword(getPasswordTextField().getText()));
if(getLogin().getText().equals("Admin")) {
LoginPopup.adminPopup();
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
return !getLogin().getText().equals("Login");
}
public static void login(){ public static void login(){
...@@ -27,36 +52,34 @@ public class LoginPopup { ...@@ -27,36 +52,34 @@ public class LoginPopup {
Label userNameLabel = new Label("Username:"); Label userNameLabel = new Label("Username:");
Label passwordLabel = new Label("Password:"); Label passwordLabel = new Label("Password:");
TextField userNameTextField = new TextField();
getPasswordTextField().clear();
Button closeButton = new Button("Close"); Button closeButton = new Button("Close");
Button loginButton = new Button("Login"); Button loginButton = new Button("Login");
getPasswordTextField().clear();
closeButton.setOnAction(event -> window.close()); closeButton.setOnAction(event -> window.close());
loginButton.setOnAction(event -> { getPasswordTextField().setOnKeyPressed( event -> {
if (event.getCode() == KeyCode.ENTER) {
try { if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) {
getAccountInformation(userNameTextField.getText(), hashPassword(getPasswordTextField().getText())); if (loginButtonPressed()) {
if(getLogin().getText().equals("Admin")) {
LoginPopup.adminPopup();
window.close(); window.close();
} }
} catch (Exception e) { }
e.printStackTrace();
} }
});
if(!getLogin().getText().equals("Login")){ loginButton.setOnAction(event -> {
window.close(); if(!isValidInput(getPasswordTextField().getText()) && !isValidInput(getUsernameTextField().getText())) {
if (loginButtonPressed()) {
window.close();
}
} }
}); });
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(userNameLabel, userNameTextField, passwordLabel, getPasswordTextField(), loginButton, closeButton); layout.getChildren().addAll(userNameLabel, getUsernameTextField(), passwordLabel, getPasswordTextField(), loginButton, closeButton);
Scene scene = new Scene(layout, 500, 300); Scene scene = new Scene(layout, 500, 300);
scene.getStylesheets().add(InputPopup.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm()); scene.getStylesheets().add(InputPopup.class.getResource("/com.application/CSS/styleSheet.css").toExternalForm());
...@@ -132,6 +155,13 @@ public class LoginPopup { ...@@ -132,6 +155,13 @@ public class LoginPopup {
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
addUser.setOnAction(event -> { 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 the passwords match each other, add the user, if not display an errormessage
if(passwordFirstField.getText().contentEquals(passwordSecondField.getText())){ if(passwordFirstField.getText().contentEquals(passwordSecondField.getText())){
...@@ -140,14 +170,15 @@ public class LoginPopup { ...@@ -140,14 +170,15 @@ public class LoginPopup {
// Tries to add the user // Tries to add the user
try { try {
addUser(firstNameTextField.getText(), lastNameTextField.getText(), phoneNoTextField.getText(), if(addUser(firstNameTextField.getText(), lastNameTextField.getText(), phoneNoTextField.getText(),
usernameTextField.getText(), hashedPassword, isAdminBox.isSelected()); usernameTextField.getText(), hashedPassword, isAdminBox.isSelected())){
NotificationPopUp.displayNotificationWindow("Successfully added user!"); NotificationPopUp.displayNotificationWindow("Successfully added user!");
window.close(); window.close();
} else NotificationPopUp.displayNotificationWindow("That username already exist in the database!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } }else {
NotificationPopUp.displayNotificationWindow("Passwords does not match!"); NotificationPopUp.displayNotificationWindow("Passwords does not match!");
passwordFirstField.clear(); passwordFirstField.clear();
passwordSecondField.clear(); passwordSecondField.clear();
...@@ -183,17 +214,19 @@ public class LoginPopup { ...@@ -183,17 +214,19 @@ public class LoginPopup {
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
delete.setOnAction(event -> { delete.setOnAction(event -> {
try { if(!isValidInput(usernameTextField.getText())) {
boolean results = deleteUser(usernameTextField.getText()); try {
if(results){ boolean results = deleteUser(usernameTextField.getText());
NotificationPopUp.displayNotificationWindow(usernameTextField.getText()+" was successfully deleted!"); if (results) {
window.close(); NotificationPopUp.displayNotificationWindow(usernameTextField.getText() + " was successfully deleted!");
} else { window.close();
NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText()); } else {
usernameTextField.clear(); NotificationPopUp.displayNotificationWindow("Could not find username: " + usernameTextField.getText());
usernameTextField.clear();
}
} catch (Exception e) {
e.printStackTrace();
} }
} catch (Exception e) {
e.printStackTrace();
} }
}); });
...@@ -280,4 +313,8 @@ public class LoginPopup { ...@@ -280,4 +313,8 @@ public class LoginPopup {
public static PasswordField getPasswordTextField() { public static PasswordField getPasswordTextField() {
return PASSWORD_TEXT_FIELD; return PASSWORD_TEXT_FIELD;
} }
public static TextField getUsernameTextField() {
return USERNAME_TEXT_FIELD;
}
} }
...@@ -4,6 +4,7 @@ import javafx.geometry.Pos; ...@@ -4,6 +4,7 @@ import javafx.geometry.Pos;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.text.TextAlignment; import javafx.scene.text.TextAlignment;
import javafx.stage.Modality; import javafx.stage.Modality;
...@@ -25,6 +26,12 @@ public class NotificationPopUp { ...@@ -25,6 +26,12 @@ public class NotificationPopUp {
Button close = new Button("Close"); Button close = new Button("Close");
close.setOnAction(event -> window.close()); close.setOnAction(event -> window.close());
close.setOnKeyPressed( event -> {
if( event.getCode() == KeyCode.ENTER ) {
window.close();
}
});
VBox layout = new VBox(10); VBox layout = new VBox(10);
layout.setAlignment(Pos.CENTER); layout.setAlignment(Pos.CENTER);
layout.getChildren().addAll(messageLabel,close); layout.getChildren().addAll(messageLabel,close);
......
...@@ -16,6 +16,7 @@ import java.time.format.DateTimeFormatter; ...@@ -16,6 +16,7 @@ import java.time.format.DateTimeFormatter;
import static com.application.DB.Constants.IS_FINISHED; import static com.application.DB.Constants.IS_FINISHED;
import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS; import static com.application.DB.Constants.MAX_USER_INPUT_CHARACTERS;
import static com.application.DB.HelpingFunctions.isValidInput;
public class OutputPopup { public class OutputPopup {
...@@ -47,7 +48,8 @@ public class OutputPopup { ...@@ -47,7 +48,8 @@ public class OutputPopup {
boolean err = false; boolean err = false;
if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ // Validates inputs
if(isValidInput(moistureCheckTextField.getText())){
err = true; err = true;
} }
...@@ -82,7 +84,8 @@ public class OutputPopup { ...@@ -82,7 +84,8 @@ public class OutputPopup {
boolean err = false; boolean err = false;
if(moistureCheckTextField.getCharacters().length() > MAX_USER_INPUT_CHARACTERS){ // Validates inputs
if(isValidInput(moistureCheckTextField.getText())){
err = true; err = true;
} }
......
.circleindicator-container { .circleindicator-container {
circleindicator-color: red; circleindicator-color: rgba(94, 33, 27, 1);
-fx-padding: 5.0; -fx-padding: 5.0;
-fx-background-color: -fx-background; -fx-background-color: -fx-background;
} }
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
-fx-inner-radius: 60.0; -fx-inner-radius: 60.0;
} }
.ringindicator-inner-circle { .ringindicator-inner-circle {
-fx-opacity: 0.55; -fx-opacity: 1.0;
-fx-stroke: circleindicator-color;
-fx-stroke: rgba(94, 33, 27, 1);
-fx-stroke-width: 8.0px; -fx-stroke-width: 8.0px;
-fx-fill: -fx-background; -fx-fill: -fx-background;
} }
...@@ -20,6 +21,6 @@ ...@@ -20,6 +21,6 @@
-fx-fill: -fx-background; -fx-fill: -fx-background;
} }
.indeterminate { .indeterminate {
-fx-opacity: 0.55; -fx-opacity: 1.0;
-fx-stroke: linear-gradient(from 0.0% 0.0% to 70.0% 70.0%, circleindicator-color 70.0%, white 75.0%, white); -fx-stroke: linear-gradient(from 0.0% 0.0% to 70.0% 70.0%, circleindicator-color 70.0%, white 75.0%, white);
} }
...@@ -51,6 +51,8 @@ ...@@ -51,6 +51,8 @@
-fx-pref-height: 25; -fx-pref-height: 25;
-fx-font-size: 16; -fx-font-size: 16;
-fx-font-weight: 200; -fx-font-weight: 200;
-fx-background-color: rgba(12, 76, 81, 1);
-fx-text-fill: white;
-fx-font-family: Arial; -fx-font-family: Arial;
} }
...@@ -61,7 +63,8 @@ ...@@ -61,7 +63,8 @@
-fx-pref-height: 25; -fx-pref-height: 25;
-fx-font-size: 20; -fx-font-size: 20;
-fx-font-family: Arial; -fx-font-family: Arial;
-fx-background-color: rgba(104, 229, 59, 1); -fx-background-color: rgba(12, 76, 81, 1);
-fx-text-fill: white;
} }
#sideBarButtonExit { #sideBarButtonExit {
...@@ -71,7 +74,12 @@ ...@@ -71,7 +74,12 @@
-fx-pref-height: 25; -fx-pref-height: 25;
-fx-font-size: 20; -fx-font-size: 20;
-fx-font-family: Arial; -fx-font-family: Arial;
/*
-fx-background-color: Red; -fx-background-color: Red;
-fx-text-fill: white;
*/
-fx-background-color: rgba(94, 33, 27, 1);
-fx-text-fill: white; -fx-text-fill: white;
} }
......
...@@ -10,19 +10,19 @@ ...@@ -10,19 +10,19 @@
} }
.default-color0.chart-earlier-data-line{-fx-stroke: black; -fx-opacity: 1.0} .default-color0.chart-earlier-data-line{-fx-stroke: black; -fx-opacity: 1.0}
.default-color1.chart-series-line{-fx-stroke: green; -fx-opacity: 1.0} .default-color1.chart-series-line{-fx-stroke: rgba(85,198,229,0.3); -fx-opacity: 1.0}
.default-color2.chart-series-line{-fx-stroke: red; -fx-opacity: 0.1} .default-color2.chart-series-line{-fx-stroke: rgba(94, 33, 27, 1); -fx-opacity: 0.1}
.default-color3.chart-earlier-data-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color3.chart-earlier-data-line{-fx-stroke: rgba(12, 76, 81, 1); -fx-opacity: 0.1}
.default-color4.chart-earlier-data-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color4.chart-earlier-data-line{-fx-stroke: rgba(12, 76, 81, 1); -fx-opacity: 0.1}
.default-color5.chart-earlier-data-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color5.chart-earlier-data-line{-fx-stroke: rgba(12, 76, 81, 1); -fx-opacity: 0.1}
.default-color6.chart-earlier-data-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color6.chart-earlier-data-line{-fx-stroke: rgba(12, 76, 81, 1); -fx-opacity: 0.1}
.default-color7.chart-earlier-data-line{-fx-stroke: rgba(0,168,355,0.3); -fx-opacity: 0.1} .default-color7.chart-earlier-data-line{-fx-stroke: rgba(12, 76, 81, 1); -fx-opacity: 0.1}
.default-color0.chart-line-symbol{-fx-background-color: black,white;} .default-color0.chart-line-symbol{-fx-background-color: black,white;}
.default-color1.chart-line-symbol{-fx-background-color: green,green;} .default-color1.chart-line-symbol{-fx-background-color: rgba(85,198,229,0.3),rgba(85,198,229,0.3);}
.default-color2.chart-line-symbol{-fx-background-color: red,red;} .default-color2.chart-line-symbol{-fx-background-color: rgba(94, 33, 27, 1),rgba(94, 33, 27, 1);}
.default-color3.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;} .default-color3.chart-line-symbol{-fx-background-color: rgba(12, 76, 81, 1),rgba(12, 76, 81, 1);}
.default-color4.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;} .default-color4.chart-line-symbol{-fx-background-color: rgba(12, 76, 81, 1),rgba(12, 76, 81, 1);}
.default-color5.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;} .default-color5.chart-line-symbol{-fx-background-color: rgba(12, 76, 81, 1),rgba(12, 76, 81, 1);}
.default-color6.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;} .default-color6.chart-line-symbol{-fx-background-color: rgba(12, 76, 81, 1),rgba(12, 76, 81, 1);}
.default-color7.chart-line-symbol{-fx-background-color: rgba(0,168,355,0.3),white;} .default-color7.chart-line-symbol{-fx-background-color: rgba(12, 76, 81, 1),rgba(12, 76, 81, 1);}
package com.application.DB;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import static com.application.DB.Settings.USERS_TABLE_NAME;
class AccountHandlerTest {
AccountHandlerTest(){
USERS_TABLE_NAME = "users_testing";
}
@Test
void logIn() throws Exception {
AccountHandler.deleteUser("loginTestAccount");
AccountHandler.addUser("test","test","+4712345678","loginTestAccount","test",false);
Assertions.assertEquals(1, AccountHandler.logIn("loginTestAccount","test").getTotalRows());
AccountHandler.deleteUser("loginTestAccount");
}
@Test
void logInFailed() throws Exception {
Assertions.assertEquals(0, AccountHandler.logIn("qefjdnweflkweoihde","test").getTotalRows());
}
@Test
void getAccount() throws Exception {
AccountHandler.deleteUser("testAccount");
AccountHandler.addUser("test","test","+4712345678","testAccount","test",false);
Assertions.assertEquals(1, AccountHandler.getAccount("testAccount").getTotalRows());
AccountHandler.deleteUser("testAccount");
}
//The test checks if the user is added
@Test
void addUser() throws Exception {
AccountHandler.deleteUser("testAccount");
AccountHandler.addUser("test","test","+4712345678","testAccount","test",false);
Assertions.assertEquals(1, AccountHandler.getAccount("testAccount").getTotalRows());
AccountHandler.deleteUser("testAccount");
}
//The test checks if the user is added
@Test
void addAlreadyExistingUser() throws Exception {
AccountHandler.deleteUser("testAccountAlready");
AccountHandler.addUser("test","test","+4712345678","testAccountAlready","test",false);
Assertions.assertFalse(AccountHandler.addUser("test","test","+4712345678","testAccountAlready","test",false));
AccountHandler.deleteUser("testAccountAlready");
}
@Test
void deleteUser() throws Exception {
AccountHandler.deleteUser("deleteTestAccount");
AccountHandler.addUser("test","test","+4712345678","deleteTestAccount","test",false);
AccountHandler.deleteUser("deleteTestAccount");
Assertions.assertEquals(0, AccountHandler.getAccount("deleteTestAccount").getTotalRows());
}
@Test
void deleteUserNonExistingUser() throws Exception {
Assertions.assertFalse(AccountHandler.deleteUser("erjfnerjkfwefbaekrørebf"));
}
}
\ No newline at end of file
package com.application.DB;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import static org.junit.jupiter.api.Assertions.*;
class DBTest {
DBTest(){
Constants.TREE_SPECIES = "Gran";
Constants.DIMENSIONS = "47x200";
Constants.SAWSET = "2ex";
Constants.MOISTURE_GOAL = "16";
Constants.CURRENT_DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
Constants.START_TIME = Constants.CURRENT_DATE;
Constants.STOP_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now());
}
@Test
void setInputParameters() throws Exception {
Assertions.assertEquals(2, DB.setInputParameters().size());
}
@Test
void getCurrentDrying() throws Exception {
Assertions.assertEquals(0, DB.getCurrentDrying().size());
}
}
\ No newline at end of file
.circleindicator-container { .circleindicator-container {
circleindicator-color: red; circleindicator-color: rgba(94, 33, 27, 1);
-fx-padding: 5.0; -fx-padding: 5.0;
-fx-background-color: -fx-background; -fx-background-color: -fx-background;
} }
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
-fx-inner-radius: 60.0; -fx-inner-radius: 60.0;
} }
.ringindicator-inner-circle { .ringindicator-inner-circle {
-fx-opacity: 0.55; -fx-opacity: 1.0;
-fx-stroke: circleindicator-color;
-fx-stroke: rgba(94, 33, 27, 1);
-fx-stroke-width: 8.0px; -fx-stroke-width: 8.0px;
-fx-fill: -fx-background; -fx-fill: -fx-background;
} }
...@@ -20,6 +21,6 @@ ...@@ -20,6 +21,6 @@
-fx-fill: -fx-background; -fx-fill: -fx-background;
} }
.indeterminate { .indeterminate {
-fx-opacity: 0.55; -fx-opacity: 1.0;
-fx-stroke: linear-gradient(from 0.0% 0.0% to 70.0% 70.0%, circleindicator-color 70.0%, white 75.0%, white); -fx-stroke: linear-gradient(from 0.0% 0.0% to 70.0% 70.0%, circleindicator-color 70.0%, white 75.0%, white);
} }