#7 Nicht fertig: Locked Treatment UI
Some checks failed
Quality Check / Linting Check (push) Failing after 12s
Quality Check / Javadoc Check (push) Successful in 21s

This commit is contained in:
Dorian Nemec 2024-05-16 16:20:05 +02:00
parent b05f4bcf59
commit ca30c413a5
3 changed files with 79 additions and 0 deletions

View file

@ -0,0 +1,72 @@
package de.hitec.nhplus.treatment;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.nurse.LockedNurseController;
import de.hitec.nhplus.nurse.Nurse;
import de.hitec.nhplus.nurse.database.NurseDao;
import de.hitec.nhplus.patient.database.PatientDao;
import de.hitec.nhplus.treatment.database.TreatmentDao;
import de.hitec.nhplus.utils.DateConverter;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;
import java.sql.SQLException;
/**
* Controller for all locked treatments.
* @author Armin Ribic
* @author Dorian Nemec
*/
public class LockedTreatmentController {
@FXML
public Button buttonUnlock;
@FXML
public TableColumn<Treatment, Long> columnId;
@FXML
public TableColumn<Treatment, String> columnFirstName;
@FXML
public TableColumn<Treatment, String> columnSurName;
@FXML
public TableColumn<Treatment, String> columnDeleteDate;
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
private NurseDao nurseDao;
private TreatmentDao treatmentDao;
private PatientDao patientDao;
/**
* This method allows initializing a {@link LockedNurseController} object
* that is called after the binding of all the fields.
*/
public void initialize(){
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
this.columnDeleteDate.setCellValueFactory(cellData -> new SimpleStringProperty("coming soon"));
}
private void readAllAndShowInTableView() {
this.treatments.clear();
this.treatmentDao = DaoFactory.getInstance().createTreatmentDao();
try {
this.treatments.addAll(this.treatmentDao.readAllLocked());
} catch (SQLException exception) {
exception.printStackTrace();
}
}
}
/*
Button zum entsperren
Column fürs Datum, wann es gesperrt wird, ID(zum später löschen)
*/

View file

@ -142,4 +142,10 @@ public class TreatmentDao extends DaoImp<Treatment> {
statement.setInt(1, id); statement.setInt(1, id);
return statement; return statement;
} }
public List<Treatment> readAllLocked() throws SQLException {
final String SQL = "SELECT * FROM treatment WHERE isLocked=true";
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
}
} }

View file

@ -8,6 +8,7 @@ CREATE TABLE treatment
end TEXT NOT NULL, end TEXT NOT NULL,
description TEXT NOT NULL, description TEXT NOT NULL,
remark TEXT NOT NULL, remark TEXT NOT NULL,
isLocked BOOLEAN NOT NULL DEFAULT FALSE,
FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE, FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE,
FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL
) )