diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml index fed79a7..98f48a2 100644 --- a/.idea/dataSources.xml +++ b/.idea/dataSources.xml @@ -1,7 +1,7 @@ - + sqlite.xerial true org.sqlite.JDBC diff --git a/src/main/java/de/hitec/nhplus/main/MainWindowController.java b/src/main/java/de/hitec/nhplus/main/MainWindowController.java index af7b2f0..40d3cce 100644 --- a/src/main/java/de/hitec/nhplus/main/MainWindowController.java +++ b/src/main/java/de/hitec/nhplus/main/MainWindowController.java @@ -1,6 +1,7 @@ package de.hitec.nhplus.main; import de.hitec.nhplus.Main; +import de.hitec.nhplus.nurse.Nurse; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.control.SelectionModel; @@ -46,6 +47,9 @@ public class MainWindowController { @FXML private Tab medicationTab; + /** + * This method allows instantiating a {@link MainWindowController} object. + */ @FXML public void initialize() { loadPatientPage(); @@ -113,6 +117,9 @@ public class MainWindowController { } } + /** + * Loads the Active Nurse page into its tab. + */ private void loadActiveNursePage() { try { BorderPane activeNursePane = FXMLLoader.load( @@ -128,6 +135,9 @@ public class MainWindowController { } } + /** + * Loads the locked nurse page into its tab. + */ private void loadLockedNursePage() { try { BorderPane lockedNursePane = FXMLLoader.load( diff --git a/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java b/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java index f1f5187..d5bf0fa 100644 --- a/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java +++ b/src/main/java/de/hitec/nhplus/nurse/LockedNurseController.java @@ -43,6 +43,9 @@ public class LockedNurseController { private NurseDao dao; private TreatmentDao treatmentDao; + /** + * This method allows instantiating a {@link LockedNurseController} object. + */ public void initialize() { this.readAllAndShowInTableView(); @@ -60,6 +63,9 @@ public class LockedNurseController { } + /** + * Reads all locked nurse data and shows it in the table. + */ private void readAllAndShowInTableView() { this.nurses.clear(); this.treatmentsPerNurse.clear(); @@ -82,6 +88,9 @@ public class LockedNurseController { } } + /** + * Deletes a locked nurse. + */ @FXML public void handleDelete() { Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem(); @@ -98,6 +107,10 @@ public class LockedNurseController { } + /** + * On clicking a locked nurse, updates the delete button based on if they + * can be deleted. + */ @FXML public void handleMouseClick() { Nurse nurse = tableView.getSelectionModel().getSelectedItem(); @@ -105,8 +118,11 @@ public class LockedNurseController { buttonDelete.setDisable(!canBeDeleted); } + /** + * Unlocks a locked nurse. + */ @FXML - public void changeUnlock() { + public void unlockNurse() { Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { return; diff --git a/src/main/java/de/hitec/nhplus/nurse/Nurse.java b/src/main/java/de/hitec/nhplus/nurse/Nurse.java index 4cfca53..fb5a878 100644 --- a/src/main/java/de/hitec/nhplus/nurse/Nurse.java +++ b/src/main/java/de/hitec/nhplus/nurse/Nurse.java @@ -41,6 +41,10 @@ public class Nurse extends Person { this.locked = new SimpleBooleanProperty(false); } + /** + * This constructor allows instantiating a {@link Nurse} object with + * specifying if the nurse is locked or not. + */ public Nurse( String firstName, String surName, @@ -68,6 +72,9 @@ public class Nurse extends Person { this.locked = new SimpleBooleanProperty(isLocked); } + /** + * Calculates the date when the nurse can be deleted. + */ public LocalDate calculateDeleteDate() { List treatments; try { @@ -123,6 +130,9 @@ public class Nurse extends Person { this.locked.set(locked); } + /** + * Returns a string representation of the nurse with each field on a new line. + */ @Override public String toString() { return new StringJoiner(System.lineSeparator()) diff --git a/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java b/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java index 6c7f7da..49feb42 100644 --- a/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java +++ b/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java @@ -17,10 +17,17 @@ import java.util.List; * @author Dominik Säume */ public class NurseDao extends DaoImp { + + /** + * This takes the same connection value from its parent class. + */ public NurseDao(Connection connection) { super(connection); } + /** + * Insert values into nurse SQL table. + */ @Override protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException { final String SQL = """ @@ -36,6 +43,9 @@ public class NurseDao extends DaoImp { return statement; } + /** + * Show data of nurse with given id. + */ @Override protected PreparedStatement getReadByIDStatement(int id) throws SQLException { final String SQL = "SELECT * FROM nurse WHERE id = ?"; @@ -44,6 +54,9 @@ public class NurseDao extends DaoImp { return statement; } + /** + * Creates a Nurse instance from the given ResultSet. + */ @Override protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException { return new Nurse( @@ -55,12 +68,18 @@ public class NurseDao extends DaoImp { ); } + /** + * Prepares a SQL statement to select all rows from the nurse table. + */ @Override protected PreparedStatement getReadAllStatement() throws SQLException { final String SQL = "SELECT * FROM nurse"; return this.connection.prepareStatement(SQL); } + /** + * Extracts a list of Nurse instances from the given ResultSet. + */ @Override protected List getListFromResultSet(ResultSet result) throws SQLException { ArrayList list = new ArrayList<>(); @@ -70,17 +89,27 @@ public class NurseDao extends DaoImp { return list; } + /** + * Reads all active nurses. + */ public List readAllActive() throws SQLException { final String SQL = "SELECT * FROM nurse WHERE isLocked=false"; return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery()); } + /** + * Retrieves a list of locked Nurse instances from the database. + */ public List readAllLocked() throws SQLException { final String SQL = "SELECT * FROM nurse WHERE isLocked=true"; return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery()); } - @Override +/** + * Prepares a SQL statement to update a Nurse instance in the database. + * + */ + @Override protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException { final String SQL = """ UPDATE nurse SET @@ -99,6 +128,9 @@ public class NurseDao extends DaoImp { return statement; } + /** + * Prepares a SQL statement to delete a Nurse instance from the database by its ID. + */ @Override protected PreparedStatement getDeleteStatement(int id) throws SQLException { final String SQL = "DELETE FROM nurse WHERE id = ?"; diff --git a/src/main/resources/de/hitec/nhplus/nurse/LockedNurseView.fxml b/src/main/resources/de/hitec/nhplus/nurse/LockedNurseView.fxml index c17e83c..23f2c6d 100644 --- a/src/main/resources/de/hitec/nhplus/nurse/LockedNurseView.fxml +++ b/src/main/resources/de/hitec/nhplus/nurse/LockedNurseView.fxml @@ -64,7 +64,7 @@