#10 story/pfleger-modul-sperren-und-loschen-von-pflegern #37
4 changed files with 15 additions and 46 deletions
|
@ -18,6 +18,8 @@ import java.util.Objects;
|
||||||
*
|
*
|
||||||
* @author Bernd Heidemann
|
* @author Bernd Heidemann
|
||||||
* @author Dominik Säume
|
* @author Dominik Säume
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
*/
|
*/
|
||||||
public class MainWindowController {
|
public class MainWindowController {
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -48,7 +50,7 @@ public class MainWindowController {
|
||||||
private Tab medicationTab;
|
private Tab medicationTab;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SZUT-Dominik marked this conversation as resolved
|
|||||||
* This method allows instantiating a {@link MainWindowController} object.
|
* Initialization method that is called after the binding of all the fields.
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
@ -118,7 +120,7 @@ public class MainWindowController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Active Nurse page into its tab.
|
* Loads the active Nurse page into its tab.
|
||||||
*/
|
*/
|
||||||
private void loadActiveNursePage() {
|
private void loadActiveNursePage() {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -20,6 +20,10 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
|
*/
|
||||||
SZUT-Dominik marked this conversation as resolved
SZUT-Dominik
commented
- [x] Author alleine reicht Heidemann hier nicht, kurze Beschreibung wie bei den anderen Controllern hier hin, muss nix Langes sein.
|
|||||||
public class LockedNurseController {
|
public class LockedNurseController {
|
||||||
@FXML
|
@FXML
|
||||||
public Button buttonDelete;
|
public Button buttonDelete;
|
||||||
|
@ -89,9 +93,6 @@ public class LockedNurseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes a locked nurse.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleDelete() {
|
public void handleDelete() {
|
||||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
@ -108,10 +109,6 @@ public class LockedNurseController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* On clicking a locked nurse, updates the delete button based on if they
|
|
||||||
* can be deleted.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void handleMouseClick() {
|
public void handleMouseClick() {
|
||||||
Nurse nurse = tableView.getSelectionModel().getSelectedItem();
|
Nurse nurse = tableView.getSelectionModel().getSelectedItem();
|
||||||
|
@ -119,9 +116,6 @@ public class LockedNurseController {
|
||||||
buttonDelete.setDisable(!canBeDeleted);
|
buttonDelete.setDisable(!canBeDeleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unlocks a locked nurse.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
public void unlockNurse() {
|
public void unlockNurse() {
|
||||||
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
Nurse selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
|
|
@ -18,6 +18,8 @@ import java.util.StringJoiner;
|
||||||
* The model for a {@link Nurse}.
|
* The model for a {@link Nurse}.
|
||||||
*
|
*
|
||||||
* @author Dominik Säume
|
* @author Dominik Säume
|
||||||
|
* @author Armin Ribic
|
||||||
|
* @author Dorian Nemec
|
||||||
*/
|
*/
|
||||||
public class Nurse extends Person {
|
public class Nurse extends Person {
|
||||||
private SimpleIntegerProperty id;
|
private SimpleIntegerProperty id;
|
||||||
|
@ -27,9 +29,8 @@ public class Nurse extends Person {
|
||||||
/**
|
/**
|
||||||
* This constructor allows instantiating a {@link Nurse} object,
|
* This constructor allows instantiating a {@link Nurse} object,
|
||||||
* before it is stored in the database, by omitting the {@link Nurse#id ID} value.
|
* before it is stored in the database, by omitting the {@link Nurse#id ID} value.
|
||||||
*
|
* It includes the locked Property.
|
||||||
* @implSpec Instances created with this constructor can be directly passed to
|
* @implSpec This was added for usage in the {@link de.hitec.nhplus.fixtures.NurseFixture NurseFixture}.
|
||||||
* {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}.
|
|
||||||
*/
|
*/
|
||||||
public Nurse(
|
public Nurse(
|
||||||
String firstName,
|
String firstName,
|
||||||
|
@ -73,7 +74,7 @@ public class Nurse extends Person {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the date when the nurse can be deleted.
|
* Calculates the date when the {@link Nurse} can be deleted.
|
||||||
*/
|
*/
|
||||||
public LocalDate calculateDeleteDate() {
|
public LocalDate calculateDeleteDate() {
|
||||||
List<Treatment> treatments;
|
List<Treatment> treatments;
|
||||||
|
@ -130,9 +131,6 @@ public class Nurse extends Person {
|
||||||
this.locked.set(locked);
|
this.locked.set(locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string representation of the nurse with each field on a new line.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new StringJoiner(System.lineSeparator())
|
return new StringJoiner(System.lineSeparator())
|
||||||
|
@ -141,6 +139,7 @@ public class Nurse extends Person {
|
||||||
.add("FirstName: " + this.getFirstName())
|
.add("FirstName: " + this.getFirstName())
|
||||||
.add("SurName: " + this.getSurName())
|
.add("SurName: " + this.getSurName())
|
||||||
.add("PhoneNumber: " + this.getPhoneNumber())
|
.add("PhoneNumber: " + this.getPhoneNumber())
|
||||||
|
.add("IsLocked: ") + this.isLocked()
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,10 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class NurseDao extends DaoImp<Nurse> {
|
public class NurseDao extends DaoImp<Nurse> {
|
||||||
|
|
||||||
/**
|
|
||||||
* This takes the same connection value from its parent class.
|
|
||||||
*/
|
|
||||||
public NurseDao(Connection connection) {
|
public NurseDao(Connection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
SZUT-Dominik marked this conversation as resolved
SZUT-Dominik
commented
- [ ] Wenn es nur einen Grundkonstruktor gibt, welcher nichts Besonderes macht, braucht der laut heidemann auch keine Javadoc.
|
|||||||
/**
|
|
||||||
* Insert values into nurse SQL table.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException {
|
protected PreparedStatement getCreateStatement(Nurse nurse) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
|
@ -43,9 +37,6 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Show data of nurse with given id.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
protected PreparedStatement getReadByIDStatement(int id) throws SQLException {
|
||||||
final String SQL = "SELECT * FROM nurse WHERE id = ?";
|
final String SQL = "SELECT * FROM nurse WHERE id = ?";
|
||||||
|
@ -54,9 +45,6 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a Nurse instance from the given ResultSet.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException {
|
protected Nurse getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||||
SZUT-Dominik marked this conversation as resolved
SZUT-Dominik
commented
- [ ] Javadoc ist bereits im `DaoImp<T>` und wird vererbt, bitte hier weglassen
|
|||||||
return new Nurse(
|
return new Nurse(
|
||||||
|
@ -68,18 +56,11 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares a SQL statement to select all rows from the nurse table.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
protected PreparedStatement getReadAllStatement() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM nurse";
|
final String SQL = "SELECT * FROM nurse";
|
||||||
return this.connection.prepareStatement(SQL);
|
return this.connection.prepareStatement(SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts a list of Nurse instances from the given ResultSet.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
|
protected List<Nurse> getListFromResultSet(ResultSet result) throws SQLException {
|
||||||
ArrayList<Nurse> list = new ArrayList<>();
|
ArrayList<Nurse> list = new ArrayList<>();
|
||||||
|
@ -98,17 +79,13 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SZUT-Dominik marked this conversation as resolved
SZUT-Dominik
commented
- [ ] Javadoc ist bereits im `DaoImp<T>` und wird vererbt, bitte hier weglassen
|
|||||||
* Retrieves a list of locked Nurse instances from the database.
|
* Read all database entries of locked {@link Nurse}s into a {@link List} of model instances.
|
||||||
*/
|
*/
|
||||||
public List<Nurse> readAllLocked() throws SQLException {
|
public List<Nurse> readAllLocked() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM nurse WHERE isLocked=true";
|
final String SQL = "SELECT * FROM nurse WHERE isLocked=true";
|
||||||
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
return getListFromResultSet(this.connection.prepareStatement(SQL).executeQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares a SQL statement to update a Nurse instance in the database.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException {
|
protected PreparedStatement getUpdateStatement(Nurse nurse) throws SQLException {
|
||||||
final String SQL = """
|
final String SQL = """
|
||||||
|
@ -128,9 +105,6 @@ public class NurseDao extends DaoImp<Nurse> {
|
||||||
return statement;
|
return statement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares a SQL statement to delete a Nurse instance from the database by its ID.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getDeleteStatement(int id) throws SQLException {
|
protected PreparedStatement getDeleteStatement(int id) throws SQLException {
|
||||||
final String SQL = "DELETE FROM nurse WHERE id = ?";
|
final String SQL = "DELETE FROM nurse WHERE id = ?";
|
||||||
|
|
Loading…
Reference in a new issue
Ist technisch falsch, technisch korrekt wäre:
Weil Initalize & Instanciate nicht dasselbe sind.
Initalize ist eine Methode, die im Hintergrund von JavaFx, nach dem Instaciating & Binding aufgerufen wird.