#10 story/pfleger-modul-sperren-und-loschen-von-pflegern #37

Merged
SZUT-Dorian merged 11 commits from story/pfleger-modul-sperren-und-loschen-von-pflegern into main 2024-05-16 11:57:12 +00:00
2 changed files with 22 additions and 19 deletions
Showing only changes of commit d8de1e17fa - Show all commits

View file

@ -8,17 +8,14 @@ import de.hitec.nhplus.utils.DateConverter;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.collections.ObservableMap;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView; import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -50,18 +47,12 @@ public class LockedNurseController {
this.readAllAndShowInTableView(); this.readAllAndShowInTableView();
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName")); this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName")); this.columnSurName.setCellValueFactory(new PropertyValueFactory<>("surName"));
this.columnSurName.setCellFactory(TextFieldTableCell.forTableColumn());
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber")); this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn()); this.columnDeleteDate.setCellValueFactory(cellData -> new SimpleStringProperty(
DateConverter.convertLocalDateToString(cellData.getValue().calculateDeleteDate()))
this.columnDeleteDate.setCellValueFactory(cellData -> new SimpleStringProperty(cellData.getValue().calculateDeleteDate(treatmentsPerNurse.get(cellData.getValue())))); );
//this.columnDeleteDate.setCellFactory(TextFieldTableCell.forTableColumn());
buttonDelete.setDisable(true); buttonDelete.setDisable(true);
@ -110,7 +101,8 @@ public class LockedNurseController {
@FXML @FXML
public void handleMouseClick() { public void handleMouseClick() {
Nurse nurse = tableView.getSelectionModel().getSelectedItem(); Nurse nurse = tableView.getSelectionModel().getSelectedItem();
buttonDelete.setDisable(!(DateConverter.convertStringToLocalDate(nurse.calculateDeleteDate(treatmentsPerNurse.get(nurse))).isBefore(LocalDate.now()))); boolean canBeDeleted = nurse.calculateDeleteDate().isBefore(LocalDate.now());
buttonDelete.setDisable(!canBeDeleted);
} }
@FXML @FXML

View file

@ -1,5 +1,6 @@
package de.hitec.nhplus.nurse; package de.hitec.nhplus.nurse;
import de.hitec.nhplus.datastorage.DaoFactory;
import de.hitec.nhplus.main.Person; import de.hitec.nhplus.main.Person;
import de.hitec.nhplus.treatment.Treatment; import de.hitec.nhplus.treatment.Treatment;
import de.hitec.nhplus.utils.DateConverter; import de.hitec.nhplus.utils.DateConverter;
@ -7,6 +8,7 @@ import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleIntegerProperty; import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleStringProperty; import javafx.beans.property.SimpleStringProperty;
import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
@ -66,17 +68,26 @@ public class Nurse extends Person {
this.locked = new SimpleBooleanProperty(isLocked); this.locked = new SimpleBooleanProperty(isLocked);
} }
public String calculateDeleteDate(List<Treatment> treatments) { public LocalDate calculateDeleteDate() {
SZUT-Dominik marked this conversation as resolved Outdated
  • Missing Javadoc
- [x] Missing Javadoc
LocalDate today = LocalDate.now(); List<Treatment> treatments;
try {
treatments = DaoFactory.getInstance().createTreatmentDao().readTreatmentsByNurse(this.getId());
}catch (SQLException exception){
treatments = null;
}
if(treatments == null){
SZUT-Dominik marked this conversation as resolved Outdated
  • Nutzt Link Tags, auch wenn es selbst Referenzen sind, um die Generierte Javadoc besser lesbar zu machen.
    - nurse
    + {@link Nurse}`
    
- [x] Nutzt Link Tags, auch wenn es selbst Referenzen sind, um die Generierte Javadoc besser lesbar zu machen. ```diff - nurse + {@link Nurse}` ```
return LocalDate.now().plusDays(1);
}
LocalDate newestDate = LocalDate.of(1980, 1, 1); LocalDate newestDate = LocalDate.of(1980, 1, 1);
for (Treatment treatment : treatments) { for (Treatment treatment : treatments) {
if (DateConverter.convertStringToLocalDate(treatment.getDate()).isAfter(newestDate)) { LocalDate date = DateConverter.convertStringToLocalDate(treatment.getDate());
newestDate = DateConverter.convertStringToLocalDate(treatment.getDate()); if (date.isAfter(newestDate)) {
newestDate = date;
} }
} }
return newestDate.plusYears(10);
return DateConverter.convertLocalDateToString(newestDate.plusYears(10));
} }
public void setPhoneNumber(String phoneNumber) { public void setPhoneNumber(String phoneNumber) {