From 817447239fa9fc3e90f79e36da9de3eae9b56236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Tue, 14 May 2024 23:22:31 +0200 Subject: [PATCH] NOTICKET: Javadoc for Dao Implementations --- .../medication/database/MedicationDao.java | 13 ++++++++++++ .../hitec/nhplus/nurse/database/NurseDao.java | 5 +++++ .../nhplus/patient/database/PatientDao.java | 6 ++++++ .../treatment/database/TreatmentDao.java | 20 ++++++++++++++----- 4 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java b/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java index 4170582..0c2c10b 100644 --- a/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java +++ b/src/main/java/de/hitec/nhplus/medication/database/MedicationDao.java @@ -13,6 +13,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +/** + * The {@link MedicationDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao} for the {@link Medication} model. + * + * @author Bernd Heidemann + * @author Dominik Säume + */ public class MedicationDao implements Dao { protected final Connection connection; @@ -153,6 +159,13 @@ public class MedicationDao implements Dao { preparedStatement.executeUpdate(); } + /** + * Constructs a {@link Medication} object from the {@link ResultSet} obtained after executing a database query. + * This method is used internally to map the {@link ResultSet} data to a {@link Medication} object. + * + * @param result The {@link ResultSet} containing the data retrieved from the database. + * @return A {@link Medication} object constructed from the {@link ResultSet} data. + */ private Medication getInstanceFromResultSet(ResultSet result) throws SQLException { Medication medication = new Medication( result.getInt(1), 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); diff --git a/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java b/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java index 90ba560..1880005 100644 --- a/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java +++ b/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java @@ -11,6 +11,12 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +/** + * The {@link PatientDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao} for the {@link Patient} model. + * + * @author Bernd Heidemann + * @author Dominik Säume + */ public class PatientDao extends DaoImp { public PatientDao(Connection connection) { diff --git a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java index 51ccde3..c821e7b 100644 --- a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java +++ b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java @@ -2,6 +2,7 @@ package de.hitec.nhplus.treatment.database; import de.hitec.nhplus.datastorage.DaoFactory; import de.hitec.nhplus.datastorage.DaoImp; +import de.hitec.nhplus.patient.Patient; import de.hitec.nhplus.treatment.Treatment; import de.hitec.nhplus.utils.DateConverter; @@ -12,6 +13,12 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +/** + * The {@link TreatmentDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao} for the {@link Treatment} model. + * + * @author Bernd Heidemann + * @author Dominik Säume + */ public class TreatmentDao extends DaoImp { public TreatmentDao(Connection connection) { @@ -71,15 +78,18 @@ public class TreatmentDao extends DaoImp { return list; } - private PreparedStatement getReadAllTreatmentsOfOnePatientByPid(int patientId) throws SQLException { + /** + * Retrieves a list of {@link Treatment}s associated with a specific {@link Patient#id patient ID} from the database. + * + * @param patientId The {@link Patient#id ID} of the {@link Patient} whose {@link Treatment}s are to be retrieved. + * @return A {@link List} of {@link Treatment} objects associated with the specified {@link Patient} ID. + */ + public List readTreatmentsByPid(int patientId) throws SQLException { final String SQL = "SELECT * FROM treatment WHERE patientId = ?"; PreparedStatement statement = this.connection.prepareStatement(SQL); statement.setInt(1, patientId); - return statement; - } - public List readTreatmentsByPid(int patientId) throws SQLException { - ResultSet result = getReadAllTreatmentsOfOnePatientByPid(patientId).executeQuery(); + ResultSet result = statement.executeQuery(); return getListFromResultSet(result); }