From e5d32a3eb679eac8855d437bdfa3fa5835c3c113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Mon, 29 Apr 2024 17:28:58 +0200 Subject: [PATCH] NOTICKET: CLeanup ToString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- src/main/java/de/hitec/nhplus/nurse/Nurse.java | 13 ++++++++----- .../java/de/hitec/nhplus/patient/Patient.java | 17 ++++++++++------- .../de/hitec/nhplus/treatment/Treatment.java | 18 +++++++++++------- .../hitec/nhplus/treatment/TreatmentDao.java | 4 ++-- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/hitec/nhplus/nurse/Nurse.java b/src/main/java/de/hitec/nhplus/nurse/Nurse.java index 2d7f6ec..7243cc0 100644 --- a/src/main/java/de/hitec/nhplus/nurse/Nurse.java +++ b/src/main/java/de/hitec/nhplus/nurse/Nurse.java @@ -4,6 +4,8 @@ import de.hitec.nhplus.main.Person; import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleStringProperty; +import java.util.StringJoiner; + public class Nurse extends Person { private SimpleIntegerProperty id; private final SimpleStringProperty phoneNumber; @@ -50,11 +52,12 @@ public class Nurse extends Person { @Override public String toString() { - return new StringBuilder() - .append("Nurse").append(System.lineSeparator()) - .append("Firstname: ").append(this.getFirstName()).append(System.lineSeparator()) - .append("Surname: ").append(this.getSurname()).append(System.lineSeparator()) - .append("PhoneNumber: ").append(this.getPhoneNumber()).append(System.lineSeparator()) + return new StringJoiner(System.lineSeparator()) + .add("NURSE") + .add("ID: " + this.getId()) + .add("Firstname: " + this.getFirstName()) + .add("Surname: " + this.getSurname()) + .add("PhoneNumber: " + this.getPhoneNumber()) .toString(); } diff --git a/src/main/java/de/hitec/nhplus/patient/Patient.java b/src/main/java/de/hitec/nhplus/patient/Patient.java index accabc5..1b9928d 100644 --- a/src/main/java/de/hitec/nhplus/patient/Patient.java +++ b/src/main/java/de/hitec/nhplus/patient/Patient.java @@ -9,6 +9,7 @@ import javafx.beans.property.SimpleStringProperty; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.StringJoiner; public class Patient extends Person { private SimpleIntegerProperty id; @@ -99,12 +100,14 @@ public class Patient extends Person { } public String toString() { - return "Patient" + "\nMNID: " + this.id + - "\nFirstname: " + this.getFirstName() + - "\nSurname: " + this.getSurname() + - "\nBirthday: " + this.dateOfBirth + - "\nCarelevel: " + this.careLevel + - "\nRoomnumber: " + this.roomNumber + - "\n"; + return new StringJoiner(System.lineSeparator()) + .add("PATIENT") + .add("ID: " + this.getId()) + .add("Firstname: " + this.getFirstName()) + .add("Surname: " + this.getSurname()) + .add("Birthday: " + this.getDateOfBirth()) + .add("Carelevel: " + this.getCareLevel()) + .add("RoomNumber: " + this.getRoomNumber()) + .toString(); } } diff --git a/src/main/java/de/hitec/nhplus/treatment/Treatment.java b/src/main/java/de/hitec/nhplus/treatment/Treatment.java index df6b831..87f0171 100644 --- a/src/main/java/de/hitec/nhplus/treatment/Treatment.java +++ b/src/main/java/de/hitec/nhplus/treatment/Treatment.java @@ -4,6 +4,7 @@ import de.hitec.nhplus.utils.DateConverter; import java.time.LocalDate; import java.time.LocalTime; +import java.util.StringJoiner; public class Treatment { private int id; @@ -84,12 +85,15 @@ public class Treatment { } public String toString() { - return "\nBehandlung" + "\nID: " + this.id + - "\nPatient ID: " + this.patientId + - "\nDate: " + this.date + - "\nBegin: " + this.begin + - "\nEnd: " + this.end + - "\nDescription: " + this.description + - "\nRemarks: " + this.remarks + "\n"; + return new StringJoiner(System.lineSeparator()) + .add("TREATMENT") + .add("ID: " + this.getId()) + .add("PatientID: " + this.getPatientId()) + .add("Date: " + this.getDate()) + .add("Begin: " + this.getBegin()) + .add("End: " + this.getEnd()) + .add("Description: " + this.getDescription()) + .add("Remarks: " + this.getRemarks()) + .toString(); } } diff --git a/src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java b/src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java index 6d5d5b7..fee4640 100644 --- a/src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java +++ b/src/main/java/de/hitec/nhplus/treatment/TreatmentDao.java @@ -120,7 +120,7 @@ public class TreatmentDao extends DaoImp { "end = ?, " + "description = ?, " + "remark = ? " + - "WHERE tid = ?"; + "WHERE id = ?"; preparedStatement = this.connection.prepareStatement(SQL); preparedStatement.setInt(1, treatment.getPatientId()); preparedStatement.setString(2, treatment.getDate()); @@ -140,7 +140,7 @@ public class TreatmentDao extends DaoImp { PreparedStatement preparedStatement = null; try { final String SQL = - "DELETE FROM treatment WHERE tid = ?"; + "DELETE FROM treatment WHERE id = ?"; preparedStatement = this.connection.prepareStatement(SQL); preparedStatement.setInt(1, id); } catch (SQLException exception) {