diff --git a/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java new file mode 100644 index 0000000..e79490a --- /dev/null +++ b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java @@ -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 columnId; + @FXML + public TableColumn columnFirstName; + @FXML + public TableColumn columnSurName; + @FXML + public TableColumn columnDeleteDate; + + private final ObservableList 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) + */ \ No newline at end of file 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 d4f6b15..ea3527e 100644 --- a/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java +++ b/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java @@ -142,4 +142,10 @@ public class TreatmentDao extends DaoImp { statement.setInt(1, id); return statement; } + + public List readAllLocked() throws SQLException { + final String SQL = "SELECT * FROM treatment WHERE isLocked=true"; + return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery()); + } + } diff --git a/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql b/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql index 75b7af1..c5f7bc9 100644 --- a/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql +++ b/src/main/resources/de/hitec/nhplus/treatment/database/Treatment.sql @@ -8,6 +8,7 @@ CREATE TABLE treatment end TEXT NOT NULL, description TEXT NOT NULL, remark TEXT NOT NULL, + isLocked BOOLEAN NOT NULL DEFAULT FALSE, FOREIGN KEY (patientId) REFERENCES patient (id) ON DELETE CASCADE, FOREIGN KEY (nurseId) REFERENCES nurse (id) ON DELETE SET NULL ) \ No newline at end of file