#24: Javadoc & Cleanup
All checks were successful
Quality Check / Linting Check (push) Successful in 18s
Quality Check / Linting Check (pull_request) Successful in 23s
Quality Check / Javadoc Check (push) Successful in 39s
Quality Check / Javadoc Check (pull_request) Successful in 37s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dorian Nemec 2024-05-21 08:39:58 +02:00 committed by Dominik Säume
parent 02232cd27f
commit db572dfa95
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C
4 changed files with 46 additions and 1 deletions

Binary file not shown.

View file

@ -7,6 +7,8 @@ import java.util.stream.Collectors;
import de.hitec.nhplus.Main;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.login.Permissions;
import de.hitec.nhplus.main.MainWindowController;
import de.hitec.nhplus.medication.database.MedicationDao;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.patient.Patient;
@ -15,6 +17,7 @@ import de.hitec.nhplus.treatment.TreatmentModalController;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
@ -51,15 +54,23 @@ public class AllMedicationController {
private TableColumn<Medication, Integer> columnCurrentStock;
@FXML
public Button buttonChangeAvailable;
@FXML
public Button buttonAdd;
@FXML
public Button buttonDelete;
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao;
private boolean hasEditPermissions;
/**
* Initialization method that is called after the binding of all the fields.
*/
@FXML
public void initialize() {
int editPermissions = Permissions.MANAGEMENT | Permissions.OWNER;
int userPermissions = MainWindowController.getInstance().getUser().getPermissions();
hasEditPermissions = (userPermissions & editPermissions) != 0;
this.readAllAndShowInTableView();
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
@ -86,6 +97,12 @@ public class AllMedicationController {
this.tableView.setItems(this.medications);
if (!hasEditPermissions) {
this.buttonAdd.setDisable(true);
this.buttonDelete.setDisable(true);
this.buttonChangeAvailable.setDisable(true);
}
}
/**
@ -140,6 +157,22 @@ public class AllMedicationController {
this.readAllAndShowInTableView();
}
@FXML
public void handleDelete() {
Medication selectedItem = this.tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
return;
}
try {
this.dao.delete(selectedItem.getId());
} catch (SQLException exception) {
exception.printStackTrace();
}
this.readAllAndShowInTableView();
}
/**
* Internal method to create a {@link MedicationModalController MedicationModal}.
*
@ -184,4 +217,5 @@ public class AllMedicationController {
}
});
}
}

View file

@ -15,6 +15,12 @@ import java.sql.SQLException;
import java.util.List;
import java.util.stream.Collectors;
/**
* The controller for viewing all deprecated {@link Medication}s.
*
* @author Armin Ribic
* @author Dorian Nemec
*/
public class DeprecatedMedicationController {
@FXML
private TableView<Medication> tableView;
@ -38,6 +44,9 @@ public class DeprecatedMedicationController {
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
private MedicationDao dao;
/**
* Initialization method that is called after the binding of all the fields.
*/
public void initialize() {
this.readAllAndShowInTableView();
@ -79,8 +88,9 @@ public class DeprecatedMedicationController {
exception.printStackTrace();
}
}
@FXML
public void handleChangeAvailable(){
public void handleChangeAvailable() {
Medication selectedItem = tableView.getSelectionModel().getSelectedItem();
if (selectedItem == null) {
return;

View file

@ -73,6 +73,7 @@
fx:id="buttonDelete"
mnemonicParsing="false"
prefWidth="90.0"
onAction="#handleDelete"
text="Löschen"
/>
<Button