Compare commits

..

2 commits

Author SHA1 Message Date
e17f2e44dd
NOTICKET: Finishing Javadoc
Some checks failed
Quality Check / Linting Check (push) Failing after 16s
Quality Check / Linting Check (pull_request) Failing after 21s
Quality Check / Javadoc Check (push) Successful in 34s
Quality Check / Javadoc Check (pull_request) Successful in 32s
2024-05-15 00:19:36 +02:00
af6ad9de15
NOTICKET: Javadoc Cleanup 2024-05-14 23:26:13 +02:00
14 changed files with 212 additions and 137 deletions

View file

@ -15,6 +15,7 @@ import java.util.*;
/**
* {@link Fixture} for {@link Medication}.
*
* @author Dominik Säume
*/
public class MedicationFixture implements Fixture<Medication> {

View file

@ -14,6 +14,7 @@ import java.util.*;
/**
* {@link Fixture} for {@link Nurse}.
*
* @author Dominik Säume
*/
public class NurseFixture implements Fixture<Nurse> {

View file

@ -16,6 +16,7 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
/**
* {@link Fixture} for {@link Patient}.
*
* @author Dominik Säume
*/
public class PatientFixture implements Fixture<Patient> {

View file

@ -18,6 +18,7 @@ import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
/**
* {@link Fixture} for {@link Treatment}.
*
* @author Dominik Säume
*/
public class TreatmentFixture implements Fixture<Treatment> {

View file

@ -13,6 +13,7 @@ import java.util.Objects;
/**
* Controller for the main window of the application, which holds all tabs.
*
* @author Bernd Heideman
* @author Dominik Säume
*/
@ -36,9 +37,6 @@ public class MainWindowController {
@FXML
private Tab medicationTab;
/**
* @implSpec Method that should be called from the outside to initialize the controller.
*/
@FXML
public void initialize() {
loadPatientPage();

View file

@ -13,6 +13,11 @@ import javafx.scene.control.cell.PropertyValueFactory;
import java.sql.SQLException;
import java.util.stream.Collectors;
/**
* The controller for viewing all {@link Medication}s.
*
* @author Dominik Säume
*/
public class AllMedicationController {
@FXML
private TableView<Medication> tableView;
@ -34,6 +39,10 @@ public class AllMedicationController {
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() {
readAllAndShowInTableView();
@ -41,16 +50,14 @@ public class AllMedicationController {
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
this.columnIngredient.setCellValueFactory(
cellData -> {
return new SimpleStringProperty(
cellData
.getValue()
.getIngredients()
.stream()
.map(ingredient -> ingredient.getName())
.collect(Collectors.joining("\n"))
);
});
cellData -> new SimpleStringProperty(
cellData
.getValue()
.getIngredients()
.stream()
.map(ingredient -> ingredient.getName())
.collect(Collectors.joining("\n"))
));
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
@ -58,6 +65,9 @@ public class AllMedicationController {
this.tableView.setItems(this.medications);
}
/**
* Internal method to read all data and set it to the table view.
*/
public void readAllAndShowInTableView() {
this.dao = DaoFactory.getInstance().createMedicationDAO();
try {

View file

@ -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<Nurse> 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();
}
}

View file

@ -19,6 +19,13 @@ import java.time.LocalDate;
import static de.hitec.nhplus.utils.Validator.*;
/**
* The controller for viewing all {@link Patient}s.
*
* @author Bernd Heideman
* @author Dominik Säume
* @author Armin Ribic
*/
public class AllPatientController {
@FXML
@ -53,6 +60,10 @@ public class AllPatientController {
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
private PatientDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() {
this.readAllAndShowInTableView();
@ -104,6 +115,41 @@ public class AllPatientController {
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener);
}
/**
* Internal method to read all data and set it to the table view.
*/
private void readAllAndShowInTableView() {
this.patients.clear();
this.dao = DaoFactory.getInstance().createPatientDAO();
try {
this.patients.setAll(this.dao.readAll());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Internal method that stores the changes in the database.
*/
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
try {
this.dao.update(event.getRowValue());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Internal method that clears the text fields used for creating a new {@link Patient}.
*/
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldDateOfBirth.clear();
this.textFieldCareLevel.clear();
this.textFieldRoomNumber.clear();
}
@FXML
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
String newFirstName = event.getNewValue();
@ -164,25 +210,6 @@ public class AllPatientController {
this.doUpdate(event);
}
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
try {
this.dao.update(event.getRowValue());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
private void readAllAndShowInTableView() {
this.patients.clear();
this.dao = DaoFactory.getInstance().createPatientDAO();
try {
this.patients.addAll(this.dao.readAll());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML
public void handleDelete() {
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
@ -212,12 +239,4 @@ public class AllPatientController {
readAllAndShowInTableView();
clearTextfields();
}
private void clearTextfields() {
this.textFieldFirstName.clear();
this.textFieldSurName.clear();
this.textFieldDateOfBirth.clear();
this.textFieldCareLevel.clear();
this.textFieldRoomNumber.clear();
}
}

View file

@ -28,6 +28,7 @@ public class Patient extends Person {
/**
* This constructor allows instantiating a {@link Patient} object,
* before it is stored in the database, by omitting the {@link Patient#id ID} value.
*
* @implSpec Instances created with this constructor can be directly passed to
* {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}.
*/

View file

@ -20,6 +20,12 @@ import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
/**
* The controller for viewing all {@link Treatment}s.
*
* @author Bernd Heideman
* @author Dominik Säume
*/
public class AllTreatmentController {
@FXML
@ -54,6 +60,10 @@ public class AllTreatmentController {
private final ObservableList<String> patientSelection = FXCollections.observableArrayList();
private ArrayList<Patient> patientList;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() {
readAllAndShowInTableView();
comboBoxPatientSelection.setItems(patientSelection);
@ -61,7 +71,7 @@ public class AllTreatmentController {
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnPatientName.setCellValueFactory(
cellData -> {
cellData -> {
Patient patient = cellData.getValue().getPatient();
return new SimpleStringProperty(patient.getSurName() + ", " + patient.getFirstName());
}
@ -83,6 +93,9 @@ public class AllTreatmentController {
this.createComboBoxData();
}
/**
* Internal method to read all data and set it to the table view.
*/
public void readAllAndShowInTableView() {
comboBoxPatientSelection.getSelectionModel().select(0);
this.dao = DaoFactory.getInstance().createTreatmentDao();
@ -93,6 +106,9 @@ public class AllTreatmentController {
}
}
/**
* Internal method to create the data set for the combobox that is used for creating a new {@link Treatment}.
*/
private void createComboBoxData() {
PatientDao dao = DaoFactory.getInstance().createPatientDAO();
try {
@ -106,6 +122,78 @@ public class AllTreatmentController {
}
}
/**
* Internal method to get the {@link Patient} object by its surname.
*
* @see AllTreatmentController#handleComboBox
* @see AllTreatmentController#handleNewTreatment
*/
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurName().equals(surname)) {
return patient;
}
}
return null;
}
/**
* Internal method to create a {@link TreatmentModalController TreatmentModal}.
*
* @param treatment The {@link Treatment} which should be edited. Set null to create a new one.
* @param title The Title of the created modal.
* @param patient The {@link Patient} whose {@link Treatment} this is.
*/
public void treatmentWindow(Treatment treatment, String title, Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
controller.initialize(
this,
stage,
treatment,
patient
);
stage.setScene(scene);
stage.setTitle(title);
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException exception) {
exception.printStackTrace();
}
}
/**
* Method to create a new {@link Treatment}.
*/
protected void createTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.create(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
/**
* Method to save the changes to a {@link Treatment}.
*/
protected void updateTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.update(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
@FXML
public void handleComboBox() {
@ -131,14 +219,6 @@ public class AllTreatmentController {
}
}
private Patient searchInList(String surname) {
for (Patient patient : this.patientList) {
if (patient.getSurName().equals(surname)) {
return patient;
}
}
return null;
}
@FXML
public void handleDelete() {
@ -157,7 +237,7 @@ public class AllTreatmentController {
try {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
Patient patient = searchInList(selectedPatient);
newTreatmentWindow(patient);
treatmentWindow(null, "NHPlus - Neue Behandlung", patient);
} catch (NullPointerException exception) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information");
@ -174,81 +254,18 @@ public class AllTreatmentController {
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
int index = this.tableView.getSelectionModel().getSelectedIndex();
Treatment treatment = this.treatments.get(index);
treatmentWindow(treatment);
try {
treatmentWindow(
treatment,
"NHPlus - Behandlung",
DaoFactory.getInstance().createPatientDAO().read(
treatment.getPatient().getId()
)
);
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
});
}
public void newTreatmentWindow(Patient patient) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
controller.initialize(
this,
stage,
null,
patient
);
stage.setScene(scene);
stage.setTitle("NHPlus - Neue Behandlung");
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException exception) {
exception.printStackTrace();
}
}
public void treatmentWindow(Treatment treatment) {
try {
FXMLLoader loader = new FXMLLoader(
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
);
BorderPane pane = loader.load();
Scene scene = new Scene(pane);
Stage stage = new Stage();
TreatmentModalController controller = loader.getController();
PatientDao pDao = DaoFactory.getInstance().createPatientDAO();
controller.initialize(
this,
stage,
treatment,
pDao.read(treatment.getPatient().getId())
);
stage.setScene(scene);
stage.setTitle("NHPlus - Behandlung");
stage.setResizable(true);
stage.setAlwaysOnTop(true);
stage.showAndWait();
} catch (IOException | SQLException exception) {
exception.printStackTrace();
}
}
public void createTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.create(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
public void updateTreatment(Treatment treatment) {
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
try {
dao.update(treatment);
} catch (SQLException exception) {
exception.printStackTrace();
}
}
}

View file

@ -13,6 +13,11 @@ import java.time.LocalTime;
import static de.hitec.nhplus.utils.Validator.*;
/**
* The controller for creating and editing a specific {@link Treatment}.
*
* @author Dominik Säume
*/
public class TreatmentModalController {
@FXML
private Label labelFirstName;
@ -36,6 +41,10 @@ public class TreatmentModalController {
private Treatment treatment;
private boolean isNewTreatment = false;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize(AllTreatmentController controller, Stage stage, Treatment treatment, Patient patient) {
this.controller = controller;
this.stage = stage;
@ -96,7 +105,9 @@ public class TreatmentModalController {
});
}
/**
* Internal method to show the data in the view.
*/
private void showData() {
this.labelFirstName.setText(patient.getFirstName());
this.labelSurName.setText(patient.getSurName());
@ -136,8 +147,4 @@ public class TreatmentModalController {
public void handleCancel() {
stage.close();
}
public Treatment getTreatment() {
return treatment;
}
}

View file

@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter;
/**
* A utility class that holds utility methods for date conversion.
*
* @author Bernd Heideman
*/
public class DateConverter {