Compare commits
6 commits
dba043ec1b
...
fcca90288c
Author | SHA1 | Date | |
---|---|---|---|
fcca90288c | |||
765d0c8dd2 | |||
8cb52b4162 | |||
1cbe39b481 | |||
b83f3e3ccd | |||
1ebd9ee318 |
10 changed files with 43 additions and 348 deletions
Binary file not shown.
|
@ -1,6 +1,5 @@
|
|||
package de.hitec.nhplus.datastorage;
|
||||
|
||||
import de.hitec.nhplus.nurse.NurseDao;
|
||||
import de.hitec.nhplus.patient.PatientDao;
|
||||
import de.hitec.nhplus.treatment.TreatmentDao;
|
||||
|
||||
|
@ -25,8 +24,4 @@ public class DaoFactory {
|
|||
public PatientDao createPatientDAO() {
|
||||
return new PatientDao(ConnectionBuilder.getConnection());
|
||||
}
|
||||
|
||||
public NurseDao createNurseDAO() {
|
||||
return new NurseDao(ConnectionBuilder.getConnection());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,6 @@ public class Fixtures
|
|||
treatmentFixture.dropTable(connection);
|
||||
treatmentFixture.setupTable(connection);
|
||||
treatmentFixture.load();
|
||||
|
||||
NurseFixture nurseFixture = new NurseFixture();
|
||||
nurseFixture.dropTable(connection);
|
||||
nurseFixture.setupTable(connection);
|
||||
nurseFixture.load();
|
||||
|
||||
} catch (Exception exception){
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package de.hitec.nhplus.fixtures;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.nurse.NurseDao;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NurseFixture implements Fixture<Nurse> {
|
||||
@Override
|
||||
public void dropTable(Connection connection) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("DROP TABLE nurse");
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupTable(Connection connection) {
|
||||
final String SQL = "CREATE TABLE IF NOT EXISTS nurse (" +
|
||||
"tid INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
"firstname TEXT NOT NULL, " +
|
||||
"surname TEXT NOT NULL, " +
|
||||
"phoneNumber TEXT NOT NULL" +
|
||||
");";
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute(SQL);
|
||||
} catch (SQLException exception) {
|
||||
System.out.println(exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Nurse> load() throws SQLException {
|
||||
List<Nurse> nurses = new ArrayList<>();
|
||||
|
||||
nurses.add(new Nurse(
|
||||
"Ole",
|
||||
"Kück",
|
||||
"0123456789"
|
||||
));
|
||||
|
||||
nurses.add(new Nurse(
|
||||
"Armin",
|
||||
"Armout",
|
||||
"9876543210"
|
||||
));
|
||||
NurseDao dao = DaoFactory.getDaoFactory().createNurseDAO();
|
||||
for(Nurse nurse : nurses){
|
||||
dao.create(nurse);
|
||||
}
|
||||
Map<String, Nurse> nursesByName = new HashMap<>();
|
||||
for (Nurse nurse : dao.readAll()){
|
||||
nursesByName.put(nurse.getFirstName(), nurse);
|
||||
}
|
||||
return nursesByName;
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package de.hitec.nhplus.nurse;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.cell.TextFieldTableCell;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class AllNurseController {
|
||||
|
||||
@FXML
|
||||
private TableView<Nurse> tableView;
|
||||
@FXML
|
||||
private TableColumn<Nurse, Long> columnId;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnFirstName;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnSurname;
|
||||
@FXML
|
||||
private TableColumn<Nurse, String> columnPhoneNumber;
|
||||
|
||||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||
private NurseDao dao;
|
||||
|
||||
public void initialize() {
|
||||
this.readAllAndSHowInTableView();
|
||||
|
||||
this.columnId.setCellValueFactory(new PropertyValueFactory<>("nid"));
|
||||
|
||||
this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));
|
||||
this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname"));
|
||||
this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
|
||||
this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber"));
|
||||
this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn());
|
||||
|
||||
this.tableView.setItems(this.nurses);
|
||||
}
|
||||
|
||||
private void readAllAndSHowInTableView(){
|
||||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getDaoFactory().createNurseDAO();
|
||||
try {
|
||||
this.nurses.addAll(this.dao.readAll());
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package de.hitec.nhplus.nurse;
|
||||
|
||||
import de.hitec.nhplus.main.Person;
|
||||
import javafx.beans.property.SimpleLongProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class Nurse extends Person {
|
||||
private SimpleLongProperty nid;
|
||||
private final SimpleStringProperty phoneNumber;
|
||||
|
||||
public Nurse(
|
||||
String firstName,
|
||||
String surname,
|
||||
String phoneNumber
|
||||
) {
|
||||
super(firstName, surname);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
}
|
||||
|
||||
public Nurse(
|
||||
long nid,
|
||||
String firstName,
|
||||
String surname,
|
||||
String phoneNumber
|
||||
) {
|
||||
super(firstName, surname);
|
||||
this.nid = new SimpleLongProperty(nid);
|
||||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber.set(phoneNumber);
|
||||
}
|
||||
|
||||
public long getNid() {
|
||||
return nid.get();
|
||||
}
|
||||
|
||||
public SimpleLongProperty nidProperty() {
|
||||
return nid;
|
||||
}
|
||||
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber.get();
|
||||
}
|
||||
|
||||
public SimpleStringProperty phoneNumberProperty() {
|
||||
return phoneNumber;
|
||||
}
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
package de.hitec.nhplus.nurse;
|
||||
|
||||
import de.hitec.nhplus.datastorage.DaoImp;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NurseDao extends DaoImp<Nurse> {
|
||||
public NurseDao(Connection connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getCreateStatement(Nurse nurse) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "INSERT INTO nurse (firstname, surname, phoneNumber)" +
|
||||
"VALUES (?, ?, ?)";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, nurse.getFirstName());
|
||||
preparedStatement.setString(2, nurse.getSurname());
|
||||
preparedStatement.setString(3, nurse.getPhoneNumber());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getReadByIDStatement(int nid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM nurse WHERE nid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, nid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||
return new Nurse(
|
||||
result.getLong(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
result.getString(4)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getReadAllStatement() {
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
final String SQL = "SELECT * FROM nurse";
|
||||
statement = this.connection.prepareStatement(SQL);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return statement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ArrayList<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
|
||||
ArrayList<Nurse> list = new ArrayList<>();
|
||||
while (result.next()) {
|
||||
list.add(new Nurse(
|
||||
result.getLong(1),
|
||||
result.getString(2),
|
||||
result.getString(3),
|
||||
result.getString(4)
|
||||
));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getUpdateStatement(Nurse nurse) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL =
|
||||
"UPDATE nurse SET " +
|
||||
"firstname = ?, " +
|
||||
"surname = ?, " +
|
||||
"phoneNumber = ?, " +
|
||||
"WHERE nid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setString(1, nurse.getFirstName());
|
||||
preparedStatement.setString(2, nurse.getSurname());
|
||||
preparedStatement.setString(3, nurse.getPhoneNumber());
|
||||
preparedStatement.setLong(4, nurse.getNid());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PreparedStatement getDeleteStatement(int nid) {
|
||||
PreparedStatement preparedStatement = null;
|
||||
try {
|
||||
final String SQL = "DELETE FROM nurse WHERE nid = ?";
|
||||
preparedStatement = this.connection.prepareStatement(SQL);
|
||||
preparedStatement.setInt(1, nid);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
return preparedStatement;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,4 @@ module de.hitec.nhplus {
|
|||
|
||||
exports de.hitec.nhplus.treatment;
|
||||
opens de.hitec.nhplus.treatment to javafx.base, javafx.fxml;
|
||||
|
||||
exports de.hitec.nhplus.nurse;
|
||||
opens de.hitec.nhplus.nurse to javafx.base, javafx.fxml;
|
||||
}
|
||||
|
|
43
src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml
Normal file
43
src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="colID" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID" />
|
||||
<TableColumn fx:id="colSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname" />
|
||||
<TableColumn fx:id="colFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname" />
|
||||
<TableColumn fx:id="colTelephone" maxWidth="7500.0" prefWidth="75.0" text="Telefon" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname" />
|
||||
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname" />
|
||||
<TextField fx:id="txfTelephone" prefWidth="160.0" promptText="Telefonnummer" />
|
||||
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen" />
|
||||
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen" />
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0" />
|
||||
</padding>
|
||||
</AnchorPane>
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<AnchorPane prefHeight="500.0" prefWidth="855.0" xmlns="http://javafx.com/javafx/10.0.2-internal"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.hitec.nhplus.nurse.AllNurseController">
|
||||
<children>
|
||||
<TableView fx:id="tableView" editable="true" layoutX="31.0" layoutY="40.0" AnchorPane.bottomAnchor="70.0"
|
||||
AnchorPane.leftAnchor="15.0" AnchorPane.rightAnchor="15.0" AnchorPane.topAnchor="80.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="columnId" maxWidth="1200.0" minWidth="5.0" prefWidth="5.0" text="ID"/>
|
||||
<TableColumn fx:id="columnSurname" maxWidth="7500.0" minWidth="20.0" prefWidth="100.0" text="Nachname"/>
|
||||
<TableColumn fx:id="columnFirstName" maxWidth="7500.0" prefWidth="75.0" text="Vorname"/>
|
||||
<TableColumn fx:id="columnPhoneNumber" maxWidth="7500.0" prefWidth="75.0" text="Telefonnummer"/>
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/>
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
<HBox layoutX="420.0" layoutY="450.0" spacing="10.0" AnchorPane.bottomAnchor="15.0" AnchorPane.leftAnchor="15.0"
|
||||
AnchorPane.rightAnchor="15.0">
|
||||
<children>
|
||||
<TextField fx:id="txfSurname" prefHeight="26.0" prefWidth="220.0" promptText="Nachname"/>
|
||||
<TextField fx:id="txfFirstname" prefHeight="26.0" prefWidth="220.0" promptText="Vorname"/>
|
||||
<TextField fx:id="txfPhoneNumber" prefWidth="160.0" promptText="Telefonnummer"/>
|
||||
<Button fx:id="btnAdd" mnemonicParsing="false" prefWidth="90.0" text="Hinzufügen"/>
|
||||
<Button fx:id="btnDelete" mnemonicParsing="false" prefWidth="90.0" text="Löschen"/>
|
||||
</children>
|
||||
</HBox>
|
||||
<HBox alignment="TOP_CENTER" layoutX="10.0" layoutY="10.0" prefWidth="200.0" spacing="25.0"
|
||||
AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0">
|
||||
<children>
|
||||
<Label alignment="CENTER" contentDisplay="CENTER" minWidth="400.0" text="Pfleger/innen"
|
||||
textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="36.0"/>
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets top="10.0"/>
|
||||
</padding>
|
||||
</AnchorPane>
|
Loading…
Reference in a new issue