From eeb3630229f8996035a1871ec894aa4c2deb0e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Wed, 15 May 2024 00:27:32 +0200 Subject: [PATCH] NOTICKET: Add Nurse Module Javadoc --- .../nhplus/nurse/AllNurseController.java | 30 +++++++++++++++---- .../java/de/hitec/nhplus/nurse/Nurse.java | 15 ++++++++++ .../hitec/nhplus/nurse/database/NurseDao.java | 5 ++++ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java b/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java index 7f69645..86eccbd 100644 --- a/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java +++ b/src/main/java/de/hitec/nhplus/nurse/AllNurseController.java @@ -17,6 +17,12 @@ import javafx.scene.control.cell.TextFieldTableCell; import java.sql.SQLException; +/** + * The controller for viewing all {@link Nurse}s. + * + * @author Dominik Säume + * @author Ole Kück + */ public class AllNurseController { @FXML public TextField textFieldSurName; @@ -40,6 +46,10 @@ public class AllNurseController { private final ObservableList nurses = FXCollections.observableArrayList(); private NurseDao dao; + /** + * Initialization method that is called after the binding of all the fields. + */ + @FXML public void initialize() { this.readAllAndShowInTableView(); @@ -72,15 +82,28 @@ public class AllNurseController { this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener); } + /** + * Internal method to read all data and set it to the table view. + */ private void readAllAndShowInTableView(){ this.nurses.clear(); this.dao = DaoFactory.getInstance().createNurseDAO(); try { - this.nurses.addAll(this.dao.readAll()); + this.nurses.setAll(this.dao.readAll()); }catch (SQLException exception){ exception.printStackTrace(); } } + + /** + * Internal method that clears the text fields used for creating a new {@link Nurse}. + */ + private void clearTextfields() { + this.textFieldFirstName.clear(); + this.textFieldSurName.clear(); + this.textFieldPhoneNumber.clear(); + } + @FXML public void handleAdd(){ String surname=this.textFieldSurName.getText(); @@ -96,10 +119,5 @@ public class AllNurseController { clearTextfields(); } - private void clearTextfields() { - this.textFieldFirstName.clear(); - this.textFieldSurName.clear(); - this.textFieldPhoneNumber.clear(); - } } diff --git a/src/main/java/de/hitec/nhplus/nurse/Nurse.java b/src/main/java/de/hitec/nhplus/nurse/Nurse.java index 18e87f1..9afab12 100644 --- a/src/main/java/de/hitec/nhplus/nurse/Nurse.java +++ b/src/main/java/de/hitec/nhplus/nurse/Nurse.java @@ -6,10 +6,22 @@ import javafx.beans.property.SimpleStringProperty; import java.util.StringJoiner; +/** + * The model for a {@link Nurse}. + * + * @author Dominik Säume + */ public class Nurse extends Person { private SimpleIntegerProperty id; private final SimpleStringProperty phoneNumber; + /** + * This constructor allows instantiating a {@link Nurse} object, + * before it is stored in the database, by omitting the {@link Nurse#id ID} value. + * + * @implSpec Instances created with this constructor can be directly passed to + * {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}. + */ public Nurse( String firstName, String surName, @@ -19,6 +31,9 @@ public class Nurse extends Person { this.phoneNumber = new SimpleStringProperty(phoneNumber); } + /** + * This constructor allows instantiating a {@link Nurse} object with all existing fields. + */ public Nurse( int id, String firstName, 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 a86fcbd..363d4c2 100644 --- a/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java +++ b/src/main/java/de/hitec/nhplus/nurse/database/NurseDao.java @@ -10,6 +10,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +/** + * The {@link NurseDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao} for the {@link Nurse} model. + * + * @author Dominik Säume + */ public class NurseDao extends DaoImp { public NurseDao(Connection connection) { super(connection);