Compare commits
3 commits
d8a7c9a59c
...
5cf57bc05c
Author | SHA1 | Date | |
---|---|---|---|
|
5cf57bc05c | ||
|
f8fab95a07 | ||
|
fc4571106c |
12 changed files with 63 additions and 126 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="Database" uuid="5a5b8be1-080b-4129-b89d-42f1ea832b90">
|
||||
<data-source source="LOCAL" name="nursingHome.db" uuid="5a5b8be1-080b-4129-b89d-42f1ea832b90">
|
||||
<driver-ref>sqlite.xerial</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
<component name="SqlDialectMappings">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/patient/database/PatientDao.java" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/TreatmentDao.java" dialect="GenericSQL" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java/de/hitec/nhplus/treatment/database/NurseDao.java" dialect="GenericSQL" />
|
||||
<file url="PROJECT" dialect="SQLite" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
|
@ -40,14 +40,6 @@ public class NurseFixture implements Fixture<Nurse> {
|
|||
"Armout",
|
||||
"9876543210"
|
||||
));
|
||||
|
||||
nurses.add(new Nurse(
|
||||
"Björnd",
|
||||
"Heideberger",
|
||||
"69420",
|
||||
true
|
||||
));
|
||||
|
||||
NurseDao dao = DaoFactory.getInstance().createNurseDAO();
|
||||
for (Nurse nurse : nurses) {
|
||||
dao.create(nurse);
|
||||
|
|
|
@ -3,7 +3,6 @@ package de.hitec.nhplus.main;
|
|||
import de.hitec.nhplus.Main;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.SelectionModel;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
@ -24,30 +23,30 @@ public class MainWindowController {
|
|||
@FXML
|
||||
private Tab treatmentTab;
|
||||
@FXML
|
||||
private Tab nurseTab;
|
||||
@FXML
|
||||
private TabPane nurseTabPane;
|
||||
@FXML
|
||||
private AnchorPane activeNursePage;
|
||||
private AnchorPane nursePage;
|
||||
@FXML
|
||||
private Tab activeNurseTab;
|
||||
private Tab nurseTab;
|
||||
@FXML
|
||||
private AnchorPane lockedNursePage;
|
||||
@FXML
|
||||
private Tab lockedNurseTab;
|
||||
@FXML
|
||||
private AnchorPane activeNursePage;
|
||||
@FXML
|
||||
private Tab activeNurseTab;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
loadPatientPage();
|
||||
mainTabPane.getSelectionModel().select(patientTab);
|
||||
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
||||
|
||||
patientTab.setOnSelectionChanged(event -> loadPatientPage());
|
||||
treatmentTab.setOnSelectionChanged(event -> loadTreatmentsPage());
|
||||
nurseTab.setOnSelectionChanged(event -> loadNursePage());
|
||||
|
||||
|
||||
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
||||
|
||||
activeNurseTab.setOnSelectionChanged(event -> loadActiveNursePage());
|
||||
lockedNurseTab.setOnSelectionChanged(event -> loadLockedNursePage());
|
||||
}
|
||||
|
@ -83,18 +82,15 @@ public class MainWindowController {
|
|||
}
|
||||
|
||||
private void loadNursePage() {
|
||||
SelectionModel<Tab> selectionModel = nurseTabPane.getSelectionModel();
|
||||
Tab selectedTab = selectionModel.getSelectedItem();
|
||||
if(selectedTab == activeNurseTab){
|
||||
try {
|
||||
nurseTabPane.getSelectionModel().select(activeNurseTab);
|
||||
loadActiveNursePage();
|
||||
}
|
||||
if(selectedTab == lockedNurseTab){
|
||||
loadLockedNursePage();
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadActiveNursePage() {
|
||||
System.out.println("TODO: Active Nurse");
|
||||
try {
|
||||
BorderPane activeNursePane = FXMLLoader.load(
|
||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/AllNurseView.fxml"))
|
||||
|
@ -110,7 +106,6 @@ public class MainWindowController {
|
|||
}
|
||||
|
||||
private void loadLockedNursePage() {
|
||||
System.out.println("TODO: Locked Nurse");
|
||||
try {
|
||||
BorderPane lockedNursePane = FXMLLoader.load(
|
||||
Objects.requireNonNull(Main.class.getResource("/de/hitec/nhplus/nurse/LockedNurseView.fxml"))
|
||||
|
|
|
@ -78,7 +78,7 @@ public class AllNurseController {
|
|||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
||||
try {
|
||||
this.nurses.addAll(this.dao.readAllActive());
|
||||
this.nurses.addAll(this.dao.readAll());
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
@ -100,17 +100,14 @@ public class AllNurseController {
|
|||
@FXML
|
||||
public void handleLock(){
|
||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null){
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedItem != null){
|
||||
try {
|
||||
selectedItem.setLocked(true);
|
||||
this.dao.update(selectedItem);
|
||||
DaoFactory.getInstance().createNurseDAO().delete(selectedItem.getId());
|
||||
this.tableView.getItems().remove(selectedItem);
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
readAllAndShowInTableView();
|
||||
}
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
|
|
|
@ -36,9 +36,7 @@ public class LockedNurseController {
|
|||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||
private NurseDao dao;
|
||||
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
public void initialize(){
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
|
||||
|
||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
|
@ -50,47 +48,32 @@ public class LockedNurseController {
|
|||
this.columnDeleteDate.setCellValueFactory(new PropertyValueFactory<>("date"));
|
||||
this.columnDeleteDate.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.tableView.setItems(this.nurses);
|
||||
// this.tableView.setItems(this.nurses);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void readAllAndShowInTableView() {
|
||||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
||||
|
||||
@FXML
|
||||
public void handleDelete(){
|
||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem != null){
|
||||
try {
|
||||
this.nurses.addAll(this.dao.readAllLocked());
|
||||
} catch (SQLException exception) {
|
||||
DaoFactory.getInstance().createNurseDAO().delete(selectedItem.getId());
|
||||
this.tableView.getItems().remove(selectedItem);
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
public void changeLockStatus(){
|
||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.dao.delete(selectedItem.getId());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void changeUnlock() {
|
||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ( !selectedItem.getisLocked()){
|
||||
selectedItem.setLocked(true);
|
||||
} else if (selectedItem.getisLocked()) {
|
||||
selectedItem.setLocked(false);
|
||||
this.dao.update(selectedItem);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
readAllAndShowInTableView();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.StringJoiner;
|
|||
public class Nurse extends Person {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleStringProperty phoneNumber;
|
||||
private final SimpleBooleanProperty locked;
|
||||
private boolean isLocked;
|
||||
|
||||
|
||||
public Nurse(
|
||||
|
@ -20,30 +20,19 @@ public class Nurse extends Person {
|
|||
) {
|
||||
super(firstName, surName);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
this.locked = new SimpleBooleanProperty(false);
|
||||
}
|
||||
public Nurse(
|
||||
String firstName,
|
||||
String surName,
|
||||
String phoneNumber,
|
||||
Boolean isLocked
|
||||
) {
|
||||
super(firstName, surName);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
this.locked = new SimpleBooleanProperty(isLocked);
|
||||
this.isLocked = false;
|
||||
}
|
||||
|
||||
public Nurse(
|
||||
int id,
|
||||
String firstName,
|
||||
String surName,
|
||||
String phoneNumber,
|
||||
Boolean isLocked
|
||||
String phoneNumber
|
||||
) {
|
||||
super(firstName, surName);
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
this.locked = new SimpleBooleanProperty(isLocked);
|
||||
this.isLocked = false;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
|
@ -65,20 +54,16 @@ public class Nurse extends Person {
|
|||
public SimpleStringProperty phoneNumberProperty() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLocked() {
|
||||
return locked.get();
|
||||
public boolean getisLocked() {
|
||||
return isLocked;
|
||||
}
|
||||
|
||||
public SimpleBooleanProperty lockedProperty() {
|
||||
return locked;
|
||||
}
|
||||
|
||||
public void setLocked(boolean locked) {
|
||||
this.locked.set(locked);
|
||||
isLocked = locked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringJoiner(System.lineSeparator())
|
||||
|
|
|
@ -19,14 +19,13 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException {
|
||||
final String SQL = """
|
||||
INSERT INTO nurse
|
||||
(firstName, surName, phoneNumber, isLocked)
|
||||
VALUES (?, ?, ?, ?)
|
||||
(firstName, surName, phoneNumber)
|
||||
VALUES (?, ?, ?)
|
||||
""";
|
||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||
statement.setString(1, nurse.getFirstName());
|
||||
statement.setString(2, nurse.getSurName());
|
||||
statement.setString(3, nurse.getPhoneNumber());
|
||||
statement.setBoolean(4, nurse.isLocked());
|
||||
return statement;
|
||||
}
|
||||
|
||||
|
@ -44,8 +43,7 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
result.getInt(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
result.getString(4),
|
||||
result.getBoolean(5)
|
||||
result.getString(4)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -64,32 +62,20 @@ public class NurseDao extends DaoImp<Nurse> {
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<Nurse> readAllActive() throws SQLException {
|
||||
final String SQL = "SELECT * FROM nurse WHERE isLocked=false";
|
||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||
}
|
||||
|
||||
public List<Nurse> readAllLocked() throws SQLException {
|
||||
final String SQL = "SELECT * FROM nurse WHERE isLocked=true";
|
||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException {
|
||||
final String SQL = """
|
||||
UPDATE nurse SET
|
||||
firstName = ?,
|
||||
surName = ?,
|
||||
phoneNumber = ?,
|
||||
isLocked = ?
|
||||
phoneNumber = ?
|
||||
WHERE id = ?
|
||||
""";
|
||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||
statement.setString(1, nurse.getFirstName());
|
||||
statement.setString(2, nurse.getSurName());
|
||||
statement.setString(3, nurse.getPhoneNumber());
|
||||
statement.setBoolean(4, nurse.isLocked());
|
||||
statement.setInt(5, nurse.getId());
|
||||
statement.setInt(4, nurse.getId());
|
||||
return statement;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
<AnchorPane fx:id="treatmentPage"/>
|
||||
</Tab>
|
||||
<Tab fx:id="nurseTab" text="Pfleger">
|
||||
<TabPane fx:id="nurseTabPane" tabClosingPolicy="UNAVAILABLE">
|
||||
<TabPane fx:id="nurseTabPane">
|
||||
<Tab fx:id="activeNurseTab" text="Pfleger">
|
||||
<AnchorPane fx:id="activeNursePage"/>
|
||||
</Tab>
|
||||
<Tab fx:id="lockedNurseTab" text="Gesperrte Pfleger">
|
||||
<Tab fx:id="lockedNurseTab" text="Gesperrt">
|
||||
<AnchorPane fx:id="lockedNursePage"/>
|
||||
</Tab>
|
||||
</TabPane>
|
||||
|
|
|
@ -56,13 +56,7 @@
|
|||
<right>
|
||||
<HBox>
|
||||
<spacing>8.0</spacing>
|
||||
<Button
|
||||
fx:id="buttonUnlock"
|
||||
mnemonicParsing="false"
|
||||
onAction="#changeUnlock"
|
||||
prefWidth="90.0"
|
||||
text="Entsperren"
|
||||
/>
|
||||
|
||||
<Button
|
||||
fx:id="buttonDelete"
|
||||
mnemonicParsing="false"
|
||||
|
@ -70,6 +64,13 @@
|
|||
prefWidth="90.0"
|
||||
text="Löschen"
|
||||
/>
|
||||
<Button
|
||||
fx:id="buttonUnlock"
|
||||
mnemonicParsing="false"
|
||||
onAction="#changeLockStatus"
|
||||
prefWidth="90.0"
|
||||
text="Entsperren"
|
||||
/>
|
||||
</HBox>
|
||||
</right>
|
||||
</BorderPane>
|
||||
|
|
|
@ -3,6 +3,5 @@ CREATE TABLE nurse
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
firstName TEXT NOT NULL,
|
||||
surName TEXT NOT NULL,
|
||||
phoneNumber TEXT NOT NULL,
|
||||
isLocked BOOLEAN NOT NULL DEFAULT false
|
||||
phoneNumber TEXT NOT NULL
|
||||
)
|
Loading…
Reference in a new issue