Compare commits
No commits in common. "192c14eb0dced7877c276cfdc7efdafe44b1272f" and "cc59218a418fc64c7c85dcd0eed2e896fb4445d8" have entirely different histories.
192c14eb0d
...
cc59218a41
29 changed files with 240 additions and 632 deletions
|
@ -1,6 +1,7 @@
|
|||
package de.hitec.nhplus;
|
||||
|
||||
import de.hitec.nhplus.datastorage.ConnectionBuilder;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
|
@ -11,35 +12,18 @@ import javafx.stage.Stage;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* The application main class, holding the {@link #main} entrypoint.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @author dominik.saeume@hmmh.ag
|
||||
*/
|
||||
public class Main extends Application {
|
||||
|
||||
private Stage primaryStage;
|
||||
|
||||
/**
|
||||
* The main entry point.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of the JavaFX start hook.
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
this.primaryStage = primaryStage;
|
||||
executeMainApplication();
|
||||
mainWindow();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the main application.
|
||||
*/
|
||||
private void executeMainApplication() {
|
||||
public void mainWindow() {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/main/MainWindowView.fxml"));
|
||||
TabPane pane = loader.load();
|
||||
|
@ -60,4 +44,7 @@ public class Main extends Application {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ import java.sql.DriverManager;
|
|||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* The {@link DaoFactory} allows a safe connection to the database.
|
||||
* The {@link DaoFactory} allows a safe connection to the Database.
|
||||
*
|
||||
* @author Bernd Heidemannn
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -21,7 +21,7 @@ public class ConnectionBuilder {
|
|||
private static Connection connection;
|
||||
|
||||
/**
|
||||
* @return A thread-safe {@link Connection} to the database.
|
||||
* @return A Thread-safe {@link Connection} to the Database.
|
||||
*/
|
||||
synchronized public static Connection getConnection() {
|
||||
try {
|
||||
|
@ -38,7 +38,7 @@ public class ConnectionBuilder {
|
|||
}
|
||||
|
||||
/**
|
||||
* Closes the connection to the database.
|
||||
* Closes the Connection to the Database.
|
||||
*/
|
||||
synchronized public static void closeConnection() {
|
||||
try {
|
||||
|
|
|
@ -4,48 +4,47 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link Dao} is the abbreviation for Data-Access-Object.
|
||||
* This interface has the Basic Methods that are needed on any {@link Dao} to work as expected.
|
||||
* {@link Dao} is the Abbreviation of Data-Access-Object.
|
||||
* This Interface has the Basic Methods which are needed on any {@link Dao} to work as expected.
|
||||
*
|
||||
* @param <T> The model for which that {@link Dao} is implemented.
|
||||
* @author Bernd Heidemannn
|
||||
* @param <T> The Model for which that {@link Dao} is implemented.
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
* @implSpec The implementations should be added to the {@link DaoFactory}.
|
||||
* @implSpec The Implementations should be added to the {@link DaoFactory}.
|
||||
*/
|
||||
public interface Dao<T> {
|
||||
|
||||
/**
|
||||
* Create a database entry from a model object.
|
||||
* Create a Database Entry from a Model object.
|
||||
*
|
||||
* @param t The model instance.
|
||||
* @param t The Model instance.
|
||||
*/
|
||||
void create(T t) throws SQLException;
|
||||
|
||||
/**
|
||||
* Read a database entry to a model object.
|
||||
* Read a Database Entry to a Model object.
|
||||
*
|
||||
* @param id The ID of the element in the database.
|
||||
* @return a model instance of {@link T}.
|
||||
* @param id The ID of the Element in the Database.
|
||||
*/
|
||||
T read(int id) throws SQLException;
|
||||
|
||||
/**
|
||||
* @return All database entries as a {@link List} of model instances.
|
||||
* @return All Database Entries as a {@link List} of Model instances
|
||||
*/
|
||||
List<T> readAll() throws SQLException;
|
||||
|
||||
/**
|
||||
* Update the database according to the values of the model object.
|
||||
* Update the Database according to the Values of the Model object.
|
||||
*
|
||||
* @param t The model instance.
|
||||
* @param t The Model instance.
|
||||
*/
|
||||
void update(T t) throws SQLException;
|
||||
|
||||
/**
|
||||
* Delete a database entry.
|
||||
* Delete a Database Entry.
|
||||
*
|
||||
* @param id The ID of the element in the database.
|
||||
* @param id The ID of the Element in the Database.
|
||||
*/
|
||||
void delete(int id) throws SQLException;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ import de.hitec.nhplus.patient.database.PatientDao;
|
|||
import de.hitec.nhplus.treatment.database.TreatmentDao;
|
||||
|
||||
/**
|
||||
* The {@link DaoFactory} is a singleton({@link #getInstance}) that should be used to get {@link Dao}s.
|
||||
* The {@link DaoFactory} is a Singleton({@link #getInstance}) which should be used to get {@link Dao}s.
|
||||
*
|
||||
* @author Bernd Heidemannn
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
*/
|
||||
|
@ -17,13 +17,13 @@ public class DaoFactory {
|
|||
private static DaoFactory instance;
|
||||
|
||||
/**
|
||||
* A private constructor according to the singleton pattern.
|
||||
* A Private Constructor according to the Singleton Pattern.
|
||||
*/
|
||||
private DaoFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The singleton instance of {@link DaoFactory}.
|
||||
* @return The Singleton Instance.
|
||||
*/
|
||||
public static DaoFactory getInstance() {
|
||||
if (DaoFactory.instance == null) {
|
||||
|
@ -33,7 +33,7 @@ public class DaoFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return A new {@link TreatmentDao} instance with a database connection.
|
||||
* @return A new {@link TreatmentDao} Instance with a Database Connection.
|
||||
* @see de.hitec.nhplus.treatment.Treatment Treatment
|
||||
*/
|
||||
public TreatmentDao createTreatmentDao() {
|
||||
|
@ -41,7 +41,7 @@ public class DaoFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return A new {@link PatientDao} instance with a database connection.
|
||||
* @return A new {@link PatientDao} Instance with a Database Connection.
|
||||
* @see de.hitec.nhplus.patient.Patient Patient
|
||||
*/
|
||||
public PatientDao createPatientDAO() {
|
||||
|
@ -49,7 +49,7 @@ public class DaoFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return A new {@link NurseDao} instance with a database connection.
|
||||
* @return A new {@link NurseDao} Instance with a Database Connection.
|
||||
* @see de.hitec.nhplus.nurse.Nurse Nurse
|
||||
*/
|
||||
public NurseDao createNurseDAO() {
|
||||
|
@ -57,7 +57,7 @@ public class DaoFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return A new {@link MedicationDao} instance with a database connection.
|
||||
* @return A new {@link MedicationDao} Instance with a Database Connection.
|
||||
* @see de.hitec.nhplus.medication.Medication Medication
|
||||
*/
|
||||
public MedicationDao createMedicationDAO() {
|
||||
|
|
|
@ -7,30 +7,30 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The {@link DaoImp} is a generic base implementation of the {@link Dao},
|
||||
* that should fit most use cases.
|
||||
* The {@link DaoImp} is a Generic Base Implementation of the {@link Dao},
|
||||
* which should fit most use cases.
|
||||
*
|
||||
* @param <T> The model for which that {@link Dao} is implemented.
|
||||
* @author Bernd Heidemannn
|
||||
* @param <T> The Model for which that {@link Dao} is implemented.
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
* @implSpec The implementations should be added to the {@link DaoFactory}.
|
||||
* @implSpec The Implementations should be added to the {@link DaoFactory}.
|
||||
*/
|
||||
public abstract class DaoImp<T> implements Dao<T> {
|
||||
protected final Connection connection;
|
||||
|
||||
/**
|
||||
* @param connection The database {@link Connection} to use.
|
||||
* @implSpec The {@link Connection} should be received from the {@link ConnectionBuilder}.
|
||||
* @param connection The Database Connection to use
|
||||
* @implSpec The Connection should be Received from the {@link ConnectionBuilder}.
|
||||
*/
|
||||
public DaoImp(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new database entry from a model object.
|
||||
* Creates a new Database Entry from a Model object.
|
||||
*
|
||||
* @param t The model instance.
|
||||
* @param t The Model instance.
|
||||
*/
|
||||
@Override
|
||||
public void create(T t) throws SQLException {
|
||||
|
@ -38,10 +38,9 @@ public abstract class DaoImp<T> implements Dao<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read a database entry to a model object.
|
||||
* Read a Database Entry to a Model object.
|
||||
*
|
||||
* @param id The ID of the element in the database.
|
||||
* @return the model instance of type {@link T}, which was read.
|
||||
* @param id The ID of the Element in the Database.
|
||||
*/
|
||||
@Override
|
||||
public T read(int id) throws SQLException {
|
||||
|
@ -54,9 +53,7 @@ public abstract class DaoImp<T> implements Dao<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read all database entries to a {@link List} of model objects.
|
||||
*
|
||||
* @return a {@link List} of type {@link T} holding all database entries as model instances.
|
||||
* Read all Database Entries to a {@link List} of Model objects.
|
||||
*/
|
||||
@Override
|
||||
public List<T> readAll() throws SQLException {
|
||||
|
@ -64,9 +61,9 @@ public abstract class DaoImp<T> implements Dao<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Update the database according to the values of the model object.
|
||||
* Update the Database according to the Values of the Model object.
|
||||
*
|
||||
* @param t The model instance.
|
||||
* @param t The Model instance.
|
||||
*/
|
||||
@Override
|
||||
public void update(T t) throws SQLException {
|
||||
|
@ -74,62 +71,26 @@ public abstract class DaoImp<T> implements Dao<T> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete a database entry.
|
||||
* Delete a Database Entry.
|
||||
*
|
||||
* @param id The ID of the element in the database.
|
||||
* @param id The ID of the Element in the Database.
|
||||
*/
|
||||
@Override
|
||||
public void delete(int id) throws SQLException {
|
||||
getDeleteStatement(id).executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param result The {@link ResultSet} from execution of the statement received from {@link #getReadByIDStatement}.
|
||||
* @return The model instance of type {@link T}.
|
||||
* @implSpec This will be called in {@link #read}.
|
||||
*/
|
||||
protected abstract T getInstanceFromResultSet(ResultSet result) throws SQLException;
|
||||
|
||||
/**
|
||||
* @param id The ID of the database entry to read.
|
||||
* @return A {@link PreparedStatement} to read a specific entry by its ID.
|
||||
* @implSpec This will be called in {@link #read}.
|
||||
* The output of the execution will be used in {@link #getInstanceFromResultSet}.
|
||||
*/
|
||||
protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
|
||||
|
||||
/**
|
||||
* @param result The {@link ResultSet} from execution of the statement received from {@link #getReadAllStatement}.
|
||||
* @return A {@link List} of type {@link T} holding all database entries as model instances.
|
||||
* @implSpec This will be called in {@link #readAll}.
|
||||
*/
|
||||
protected abstract List<T> getListFromResultSet(ResultSet result) throws SQLException;
|
||||
|
||||
/**
|
||||
* @return A {@link PreparedStatement} to read all entries of this model.
|
||||
* @implSpec This will be called in {@link #readAll}.
|
||||
* The output of the execution will be used in {@link #getListFromResultSet}.
|
||||
*/
|
||||
protected abstract PreparedStatement getReadAllStatement() throws SQLException;
|
||||
|
||||
/**
|
||||
* @param t The model instance of type {@link T} for which an entry should be created.
|
||||
* @return a {@link PreparedStatement} which can be used to create a new database entry for the model instance.
|
||||
* @implSpec This will be called in {@link #create}.
|
||||
*/
|
||||
protected abstract PreparedStatement getCreateStatement(T t) throws SQLException;
|
||||
|
||||
/**
|
||||
* @param t The model instance of type {@link T} for which the entry should be updated.
|
||||
* @return a {@link PreparedStatement} which can be used to update the database entry for the model instance.
|
||||
* @implSpec This will be called in {@link #update}.
|
||||
*/
|
||||
protected abstract PreparedStatement getReadByIDStatement(int id) throws SQLException;
|
||||
|
||||
protected abstract PreparedStatement getReadAllStatement() throws SQLException;
|
||||
|
||||
protected abstract PreparedStatement getUpdateStatement(T t) throws SQLException;
|
||||
|
||||
/**
|
||||
* @param id The ID of the database entry which should be deleted.
|
||||
* @return a {@link PreparedStatement} which can be used to delete the database entry.
|
||||
* @implSpec This will be called in {@link #delete}.
|
||||
*/
|
||||
protected abstract PreparedStatement getDeleteStatement(int id) throws SQLException;
|
||||
}
|
||||
|
|
|
@ -7,36 +7,36 @@ import java.sql.SQLException;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A fixture is a class, which can be used to set up a specific set of data.
|
||||
* A Fixture is a Class, which can be used to set up a specific set of Data.
|
||||
*
|
||||
* @param <T> The model for which the {@link Fixture} is implemented.
|
||||
* @param <T> The Model for which the {@link Fixture} is implemented.
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
* @implSpec The implementations should be added to the {@link Fixtures#main}.
|
||||
* @implSpec The Implementations should be added to the {@link Fixtures#main}.
|
||||
*/
|
||||
public interface Fixture<T> {
|
||||
|
||||
/**
|
||||
* Drop all dependent tables.
|
||||
* Drop all Dependent Tables.
|
||||
*
|
||||
* @param connection A database {@link Connection}, which should be received from
|
||||
* @param connection A Database {@link Connection}, which should be received from
|
||||
* the {@link ConnectionBuilder#getConnection}
|
||||
* @implSpec Use {@code IF EXISTS}, to ensure that it doesn't throw an {@link Exception}.
|
||||
*/
|
||||
void dropTable(Connection connection) throws SQLException;
|
||||
|
||||
/**
|
||||
* Set up the empty tables with the schema.
|
||||
* Set up the Empty Tables with the Schema.
|
||||
*
|
||||
* @param connection A database {@link Connection}, which should be received from
|
||||
* @param connection A Database {@link Connection}, which should be received from
|
||||
* the {@link ConnectionBuilder#getConnection}
|
||||
*/
|
||||
void setupTable(Connection connection) throws SQLException;
|
||||
|
||||
/**
|
||||
* Loads all model specific data to the database.
|
||||
* Loads all Model specific Data to the Database.
|
||||
*
|
||||
* @return A map of models with a {@link String} key, to be used by other {@link Fixture}
|
||||
* @return A Map of Models with a {@link String} key, to be used by other {@link Fixture}
|
||||
* @implSpec The {@link de.hitec.nhplus.datastorage.Dao Dao} should be received
|
||||
* from {@link de.hitec.nhplus.datastorage.DaoFactory DaoFactory}.
|
||||
*/
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.sql.Connection;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A class, implementing an entrypoint({@link #main}), for loading a specific set of data.
|
||||
* A Class, Implementing an Entrypoint({@link #main}), for loading a Specific set of Data.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
* @version 1.0
|
||||
|
@ -16,7 +16,7 @@ import java.util.Map;
|
|||
public class Fixtures {
|
||||
|
||||
/**
|
||||
* An entrypoint, for loading a specific set of data.
|
||||
* An Entrypoint, for loading a Specific set of Data.
|
||||
*
|
||||
* @param args unused.
|
||||
*/
|
||||
|
|
|
@ -12,11 +12,7 @@ import java.sql.Connection;
|
|||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* {@link Fixture} for {@link Medication}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
|
||||
public class MedicationFixture implements Fixture<Medication> {
|
||||
private static final String SCHEMA = "/de/hitec/nhplus/medication/database/Medication.sql";
|
||||
private static final String INGREDIENT_SCHEMA = "/de/hitec/nhplus/medication/database/Medication_Ingredient.sql";
|
||||
|
|
|
@ -4,7 +4,6 @@ import de.hitec.nhplus.Main;
|
|||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
import de.hitec.nhplus.nurse.database.NurseDao;
|
||||
import de.hitec.nhplus.treatment.Treatment;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -12,11 +11,6 @@ import java.sql.Connection;
|
|||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* {@link Fixture} for {@link Nurse}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class NurseFixture implements Fixture<Nurse> {
|
||||
@Override
|
||||
public void dropTable(Connection connection) throws SQLException {
|
||||
|
|
|
@ -13,11 +13,6 @@ import java.util.*;
|
|||
|
||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||
|
||||
/**
|
||||
* {@link Fixture} for {@link Patient}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class PatientFixture implements Fixture<Patient> {
|
||||
@Override
|
||||
public void dropTable(Connection connection) throws SQLException {
|
||||
|
|
|
@ -16,12 +16,6 @@ import java.util.*;
|
|||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalDate;
|
||||
import static de.hitec.nhplus.utils.DateConverter.convertStringToLocalTime;
|
||||
|
||||
|
||||
/**
|
||||
* {@link Fixture} for {@link Treatment}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class TreatmentFixture implements Fixture<Treatment> {
|
||||
private final Map<String, Patient> patientsByName;
|
||||
private final Map<String, Nurse> nursesByName;
|
||||
|
|
|
@ -11,12 +11,6 @@ import javafx.scene.layout.BorderPane;
|
|||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Controller for the main window of the application, which holds all tabs.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class MainWindowController {
|
||||
@FXML
|
||||
private TabPane mainTabPane;
|
||||
|
@ -48,9 +42,6 @@ public class MainWindowController {
|
|||
medicationTab.setOnSelectionChanged(event -> loadMedicationPage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the patient page into its tab.
|
||||
*/
|
||||
private void loadPatientPage() {
|
||||
try {
|
||||
BorderPane patientsPane = FXMLLoader.load(
|
||||
|
@ -66,9 +57,6 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the treatment page into its tab.
|
||||
*/
|
||||
private void loadTreatmentsPage() {
|
||||
try {
|
||||
BorderPane treatmentsPane = FXMLLoader.load(
|
||||
|
@ -84,9 +72,6 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the nurse page into its tab.
|
||||
*/
|
||||
private void loadNursePage() {
|
||||
try {
|
||||
BorderPane nursePane = FXMLLoader.load(
|
||||
|
@ -102,9 +87,6 @@ public class MainWindowController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the medication page into its tab.
|
||||
*/
|
||||
private void loadMedicationPage() {
|
||||
try {
|
||||
BorderPane medicationPane = FXMLLoader.load(
|
||||
|
|
|
@ -2,12 +2,6 @@ package de.hitec.nhplus.main;
|
|||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
* A simple base model for a {@link Person} that can be extended.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public abstract class Person {
|
||||
private final SimpleStringProperty firstName;
|
||||
private final SimpleStringProperty surName;
|
||||
|
|
|
@ -13,11 +13,6 @@ import javafx.scene.control.cell.PropertyValueFactory;
|
|||
import java.sql.SQLException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Medication}s.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class AllMedicationController {
|
||||
@FXML
|
||||
private TableView<Medication> tableView;
|
||||
|
@ -39,10 +34,6 @@ public class AllMedicationController {
|
|||
private final ObservableList<Medication> medications = FXCollections.observableArrayList();
|
||||
private MedicationDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
|
||||
|
@ -50,14 +41,16 @@ public class AllMedicationController {
|
|||
this.columnName.setCellValueFactory(new PropertyValueFactory<>("name"));
|
||||
this.columnManufacturer.setCellValueFactory(new PropertyValueFactory<>("manufacturer"));
|
||||
this.columnIngredient.setCellValueFactory(
|
||||
cellData -> new SimpleStringProperty(
|
||||
cellData
|
||||
.getValue()
|
||||
.getIngredients()
|
||||
.stream()
|
||||
.map(ingredient -> ingredient.getName())
|
||||
.collect(Collectors.joining("\n"))
|
||||
));
|
||||
cellData -> {
|
||||
return new SimpleStringProperty(
|
||||
cellData
|
||||
.getValue()
|
||||
.getIngredients()
|
||||
.stream()
|
||||
.map(ingredient -> ingredient.getName())
|
||||
.collect(Collectors.joining("\n"))
|
||||
);
|
||||
});
|
||||
this.columnPossibleSideEffects.setCellValueFactory(new PropertyValueFactory<>("possibleSideEffects"));
|
||||
this.columnAdministrationMethod.setCellValueFactory(new PropertyValueFactory<>("administrationMethod"));
|
||||
this.columnCurrentStock.setCellValueFactory(new PropertyValueFactory<>("currentStock"));
|
||||
|
@ -65,9 +58,6 @@ public class AllMedicationController {
|
|||
this.tableView.setItems(this.medications);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
public void readAllAndShowInTableView() {
|
||||
this.dao = DaoFactory.getInstance().createMedicationDAO();
|
||||
try {
|
||||
|
|
|
@ -2,13 +2,6 @@ package de.hitec.nhplus.medication;
|
|||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
/**
|
||||
* The simple model for an {@link Ingredient}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
* @implSpec This isn't a conventional model, because it isn't directly stored in the database,
|
||||
* but it can be changed to do that, in the case that its complexity rises in the future.
|
||||
*/
|
||||
public class Ingredient {
|
||||
private final SimpleStringProperty name;
|
||||
|
||||
|
|
|
@ -10,11 +10,6 @@ import java.util.List;
|
|||
import java.util.StringJoiner;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The model for a {@link Medication}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class Medication {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleStringProperty name;
|
||||
|
@ -24,13 +19,6 @@ public class Medication {
|
|||
private final SimpleStringProperty administrationMethod;
|
||||
private final SimpleIntegerProperty currentStock;
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Medication} object,
|
||||
* before it is stored in the database, by omitting the {@link Medication#id ID} value.
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.medication.database.MedicationDao#create MedicationDao.create}.
|
||||
*/
|
||||
public Medication(
|
||||
String name,
|
||||
String manufacturer,
|
||||
|
@ -47,9 +35,6 @@ public class Medication {
|
|||
this.currentStock = new SimpleIntegerProperty(currentStock);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Medication} object with all existing fields.
|
||||
*/
|
||||
public Medication(
|
||||
int id,
|
||||
String name,
|
||||
|
|
|
@ -13,13 +13,6 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The {@link MedicationDao} is an implementation of the{@link de.hitec.nhplus.datastorage.Dao Dao}
|
||||
* for the {@link Medication} model.
|
||||
*
|
||||
* @author Bernd Heidemannn
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class MedicationDao implements Dao<Medication> {
|
||||
protected final Connection connection;
|
||||
|
||||
|
@ -160,13 +153,6 @@ public class MedicationDao implements Dao<Medication> {
|
|||
preparedStatement.executeUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a {@link Medication} object from the {@link ResultSet} obtained after executing a database query.
|
||||
* This method is used internally to map the {@link ResultSet} data to a {@link Medication} object.
|
||||
*
|
||||
* @param result The {@link ResultSet} containing the data retrieved from the database.
|
||||
* @return A {@link Medication} object constructed from the {@link ResultSet} data.
|
||||
*/
|
||||
private Medication getInstanceFromResultSet(ResultSet result) throws SQLException {
|
||||
Medication medication = new Medication(
|
||||
result.getInt(1),
|
||||
|
|
|
@ -17,12 +17,6 @@ import javafx.scene.control.cell.TextFieldTableCell;
|
|||
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Nurse}s.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
* @author Ole Kück
|
||||
*/
|
||||
public class AllNurseController {
|
||||
@FXML
|
||||
public TextField textFieldSurName;
|
||||
|
@ -46,10 +40,6 @@ public class AllNurseController {
|
|||
private final ObservableList<Nurse> nurses = FXCollections.observableArrayList();
|
||||
private NurseDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
|
@ -82,28 +72,15 @@ public class AllNurseController {
|
|||
this.textFieldPhoneNumber.textProperty().addListener(inputNewNurseValidationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
private void readAllAndShowInTableView(){
|
||||
this.nurses.clear();
|
||||
this.dao = DaoFactory.getInstance().createNurseDAO();
|
||||
try {
|
||||
this.nurses.setAll(this.dao.readAll());
|
||||
this.nurses.addAll(this.dao.readAll());
|
||||
}catch (SQLException exception){
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method that clears the text fields used for creating a new {@link Nurse}.
|
||||
*/
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleAdd(){
|
||||
String surname=this.textFieldSurName.getText();
|
||||
|
@ -119,5 +96,10 @@ public class AllNurseController {
|
|||
clearTextfields();
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldPhoneNumber.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,22 +6,10 @@ import javafx.beans.property.SimpleStringProperty;
|
|||
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* The model for a {@link Nurse}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class Nurse extends Person {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleStringProperty phoneNumber;
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Nurse} object,
|
||||
* before it is stored in the database, by omitting the {@link Nurse#id ID} value.
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.nurse.database.NurseDao#create NurseDao.create}.
|
||||
*/
|
||||
public Nurse(
|
||||
String firstName,
|
||||
String surName,
|
||||
|
@ -31,9 +19,6 @@ public class Nurse extends Person {
|
|||
this.phoneNumber = new SimpleStringProperty(phoneNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Nurse} object with all existing fields.
|
||||
*/
|
||||
public Nurse(
|
||||
int id,
|
||||
String firstName,
|
||||
|
|
|
@ -10,12 +10,6 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The {@link NurseDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
||||
* for the {@link Nurse} model.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class NurseDao extends DaoImp<Nurse> {
|
||||
public NurseDao(Connection connection) {
|
||||
super(connection);
|
||||
|
|
|
@ -19,13 +19,6 @@ import java.time.LocalDate;
|
|||
|
||||
import static de.hitec.nhplus.utils.Validator.*;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Patient}s.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @author Armin Ribic
|
||||
*/
|
||||
public class AllPatientController {
|
||||
|
||||
@FXML
|
||||
|
@ -60,10 +53,6 @@ public class AllPatientController {
|
|||
private final ObservableList<Patient> patients = FXCollections.observableArrayList();
|
||||
private PatientDao dao;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
this.readAllAndShowInTableView();
|
||||
|
||||
|
@ -115,41 +104,6 @@ public class AllPatientController {
|
|||
this.textFieldRoomNumber.textProperty().addListener(inputNewPatientValidationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
private void readAllAndShowInTableView() {
|
||||
this.patients.clear();
|
||||
this.dao = DaoFactory.getInstance().createPatientDAO();
|
||||
try {
|
||||
this.patients.setAll(this.dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method that stores the changes in the database.
|
||||
*/
|
||||
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
try {
|
||||
this.dao.update(event.getRowValue());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method that clears the text fields used for creating a new {@link Patient}.
|
||||
*/
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldDateOfBirth.clear();
|
||||
this.textFieldCareLevel.clear();
|
||||
this.textFieldRoomNumber.clear();
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleOnEditFirstname(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
String newFirstName = event.getNewValue();
|
||||
|
@ -210,6 +164,25 @@ public class AllPatientController {
|
|||
this.doUpdate(event);
|
||||
}
|
||||
|
||||
|
||||
private void doUpdate(TableColumn.CellEditEvent<Patient, String> event) {
|
||||
try {
|
||||
this.dao.update(event.getRowValue());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void readAllAndShowInTableView() {
|
||||
this.patients.clear();
|
||||
this.dao = DaoFactory.getInstance().createPatientDAO();
|
||||
try {
|
||||
this.patients.addAll(this.dao.readAll());
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleDelete() {
|
||||
Patient selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||
|
@ -239,4 +212,12 @@ public class AllPatientController {
|
|||
readAllAndShowInTableView();
|
||||
clearTextfields();
|
||||
}
|
||||
|
||||
private void clearTextfields() {
|
||||
this.textFieldFirstName.clear();
|
||||
this.textFieldSurName.clear();
|
||||
this.textFieldDateOfBirth.clear();
|
||||
this.textFieldCareLevel.clear();
|
||||
this.textFieldRoomNumber.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,13 +11,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* The model for a {@link Patient}.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
* @author Armin Ribic
|
||||
*/
|
||||
public class Patient extends Person {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleStringProperty dateOfBirth;
|
||||
|
@ -25,13 +18,6 @@ public class Patient extends Person {
|
|||
private final SimpleStringProperty roomNumber;
|
||||
private final List<Treatment> allTreatments = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Patient} object,
|
||||
* before it is stored in the database, by omitting the {@link Patient#id ID} value.
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.patient.database.PatientDao#create PatientDao.create}.
|
||||
*/
|
||||
public Patient(
|
||||
String firstName,
|
||||
String surName,
|
||||
|
@ -45,9 +31,6 @@ public class Patient extends Person {
|
|||
this.roomNumber = new SimpleStringProperty(roomNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Patient} object with all existing fields.
|
||||
*/
|
||||
public Patient(
|
||||
int id,
|
||||
String firstName,
|
||||
|
|
|
@ -11,13 +11,6 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The {@link PatientDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
||||
* for the {@link Patient} model.
|
||||
*
|
||||
* @author Bernd Heidemannn
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class PatientDao extends DaoImp<Patient> {
|
||||
|
||||
public PatientDao(Connection connection) {
|
||||
|
|
|
@ -22,12 +22,6 @@ import java.io.IOException;
|
|||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The controller for viewing all {@link Treatment}s.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class AllTreatmentController {
|
||||
|
||||
@FXML
|
||||
|
@ -70,10 +64,6 @@ public class AllTreatmentController {
|
|||
private final ObservableList<String> nurseSelection = FXCollections.observableArrayList();
|
||||
private ArrayList<Nurse> nurseList;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
@FXML
|
||||
public void initialize() {
|
||||
readAllAndShowInTableView();
|
||||
comboBoxPatientSelection.setItems(patientSelection);
|
||||
|
@ -111,9 +101,6 @@ public class AllTreatmentController {
|
|||
this.createComboBoxData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to read all data and set it to the table view.
|
||||
*/
|
||||
public void readAllAndShowInTableView() {
|
||||
this.dao = DaoFactory.getInstance().createTreatmentDao();
|
||||
try {
|
||||
|
@ -123,9 +110,6 @@ public class AllTreatmentController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to create the data set for the combobox that is used for creating a new {@link Treatment}.
|
||||
*/
|
||||
private void createComboBoxData() {
|
||||
PatientDao patientDAO = DaoFactory.getInstance().createPatientDAO();
|
||||
NurseDao nurseDao = DaoFactory.getInstance().createNurseDAO();
|
||||
|
@ -145,58 +129,6 @@ public class AllTreatmentController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to get the {@link Patient} object by its surname.
|
||||
*
|
||||
* @see AllTreatmentController#handleComboBoxPatient
|
||||
* @see AllTreatmentController#handleNewTreatment
|
||||
*/
|
||||
private Patient searchInPatientList(String surname) {
|
||||
for (Patient patient : this.patientList) {
|
||||
if (patient.getSurName().equals(surname)) {
|
||||
return patient;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to get the {@link Nurse} object by its surname.
|
||||
*
|
||||
* @see AllTreatmentController#handleNewTreatment
|
||||
*/
|
||||
private Nurse searchInNurseList(String surname) {
|
||||
for (Nurse nurse : this.nurseList) {
|
||||
if (nurse.getSurName().equals(surname)) {
|
||||
return nurse;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the changes to a {@link Treatment}.
|
||||
*/
|
||||
protected void updateTreatment(Treatment treatment) {
|
||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||
try {
|
||||
dao.update(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to create a new {@link Treatment}.
|
||||
*/
|
||||
public void createTreatment(Treatment treatment) {
|
||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||
try {
|
||||
dao.create(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleComboBoxPatient() {
|
||||
|
@ -222,40 +154,22 @@ public class AllTreatmentController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to create a {@link TreatmentModalController TreatmentModal}.
|
||||
*
|
||||
* @param treatment The {@link Treatment} which should be edited. Set null to create a new one.
|
||||
* @param title The Title of the created modal.
|
||||
* @param patient The {@link Patient} whose {@link Treatment} this is.
|
||||
* @param nurse The {@link Nurse} who did the {@link Treatment}.
|
||||
*/
|
||||
public void treatmentWindow(Treatment treatment, String title, Patient patient, Nurse nurse) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||
);
|
||||
BorderPane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
Stage stage = new Stage();
|
||||
|
||||
TreatmentModalController controller = loader.getController();
|
||||
controller.initialize(
|
||||
this,
|
||||
stage,
|
||||
treatment,
|
||||
patient,
|
||||
nurse
|
||||
);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle(title);
|
||||
stage.setResizable(true);
|
||||
stage.setAlwaysOnTop(true);
|
||||
stage.showAndWait();
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
private Patient searchInPatientList(String surname) {
|
||||
for (Patient patient : this.patientList) {
|
||||
if (patient.getSurName().equals(surname)) {
|
||||
return patient;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Nurse searchInNurseList(String surname) {
|
||||
for (Nurse nurse : this.nurseList) {
|
||||
if (nurse.getSurName().equals(surname)) {
|
||||
return nurse;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -296,24 +210,94 @@ public class AllTreatmentController {
|
|||
return;
|
||||
}
|
||||
|
||||
treatmentWindow(null, "NHPlus - Neue Behandlung", patient, nurse);
|
||||
newTreatmentWindow(patient, nurse);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void handleMouseClick() {
|
||||
tableView.setOnMouseClicked(event ->
|
||||
{
|
||||
if (event.getClickCount() == 2 && (tableView.getSelectionModel().getSelectedItem() != null)) {
|
||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||
Treatment treatment = this.treatments.get(index);
|
||||
treatmentWindow(
|
||||
treatment,
|
||||
"NHPlus - Behandlung",
|
||||
treatment.getPatient(),
|
||||
treatment.getNurse()
|
||||
);
|
||||
if (event.getClickCount() != 2 || (tableView.getSelectionModel().getSelectedItem() == null)) {
|
||||
return;
|
||||
}
|
||||
int index = this.tableView.getSelectionModel().getSelectedIndex();
|
||||
Treatment treatment = this.treatments.get(index);
|
||||
treatmentWindow(treatment, treatment.getNurse());
|
||||
});
|
||||
}
|
||||
|
||||
public void newTreatmentWindow(Patient patient, Nurse nurse) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||
);
|
||||
BorderPane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
Stage stage = new Stage();
|
||||
|
||||
TreatmentModalController controller = loader.getController();
|
||||
controller.initialize(
|
||||
this,
|
||||
stage,
|
||||
null,
|
||||
patient,
|
||||
nurse
|
||||
);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("NHPlus - Neue Behandlung");
|
||||
stage.setResizable(true);
|
||||
stage.setAlwaysOnTop(true);
|
||||
stage.showAndWait();
|
||||
} catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void treatmentWindow(Treatment treatment, Nurse nurse) {
|
||||
try {
|
||||
FXMLLoader loader = new FXMLLoader(
|
||||
Main.class.getResource("/de/hitec/nhplus/treatment/TreatmentModal.fxml")
|
||||
);
|
||||
BorderPane pane = loader.load();
|
||||
Scene scene = new Scene(pane);
|
||||
Stage stage = new Stage();
|
||||
|
||||
TreatmentModalController controller = loader.getController();
|
||||
PatientDao pDao = DaoFactory.getInstance().createPatientDAO();
|
||||
controller.initialize(
|
||||
this,
|
||||
stage,
|
||||
treatment,
|
||||
pDao.read(treatment.getPatient().getId()),
|
||||
nurse
|
||||
);
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.setTitle("NHPlus - Behandlung");
|
||||
stage.setResizable(true);
|
||||
stage.setAlwaysOnTop(true);
|
||||
stage.showAndWait();
|
||||
} catch (IOException | SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void createTreatment(Treatment treatment) {
|
||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||
try {
|
||||
dao.create(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTreatment(Treatment treatment) {
|
||||
TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao();
|
||||
try {
|
||||
dao.update(treatment);
|
||||
} catch (SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,12 +11,6 @@ import java.time.LocalDate;
|
|||
import java.time.LocalTime;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* The model for a {@link Treatment}.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class Treatment {
|
||||
private SimpleIntegerProperty id;
|
||||
private final SimpleObjectProperty<Patient> patient;
|
||||
|
@ -27,22 +21,8 @@ public class Treatment {
|
|||
private final SimpleStringProperty description;
|
||||
private final SimpleStringProperty remarks;
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Treatment} object,
|
||||
* before it is stored in the database, by omitting the {@link Treatment#id ID} value.
|
||||
*
|
||||
* @implSpec Instances created with this constructor can be directly passed to
|
||||
* {@link de.hitec.nhplus.treatment.database.TreatmentDao#create TreatmentDao.create}.
|
||||
*/
|
||||
public Treatment(
|
||||
Patient patient,
|
||||
Nurse nurse,
|
||||
LocalDate date,
|
||||
LocalTime begin,
|
||||
LocalTime end,
|
||||
String description,
|
||||
String remarks
|
||||
) {
|
||||
public Treatment(Patient patient, Nurse nurse, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.patient = new SimpleObjectProperty<>(patient);
|
||||
this.nurse = new SimpleObjectProperty<>(nurse);
|
||||
this.date = new SimpleObjectProperty<>(date);
|
||||
|
@ -52,19 +32,8 @@ public class Treatment {
|
|||
this.remarks = new SimpleStringProperty(remarks);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor allows instantiating a {@link Treatment} object with all existing fields.
|
||||
*/
|
||||
public Treatment(
|
||||
int id,
|
||||
Patient patient,
|
||||
Nurse nurse,
|
||||
LocalDate date,
|
||||
LocalTime begin,
|
||||
LocalTime end,
|
||||
String description,
|
||||
String remarks
|
||||
) {
|
||||
public Treatment(int id, Patient patient, Nurse nurse, LocalDate date, LocalTime begin,
|
||||
LocalTime end, String description, String remarks) {
|
||||
this.id = new SimpleIntegerProperty(id);
|
||||
this.patient = new SimpleObjectProperty<>(patient);
|
||||
this.nurse = new SimpleObjectProperty<>(nurse);
|
||||
|
|
|
@ -14,11 +14,6 @@ import java.time.LocalTime;
|
|||
|
||||
import static de.hitec.nhplus.utils.Validator.*;
|
||||
|
||||
/**
|
||||
* The controller for creating and editing a specific {@link Treatment}.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class TreatmentModalController {
|
||||
@FXML
|
||||
private Label labelNurseName;
|
||||
|
@ -45,9 +40,6 @@ public class TreatmentModalController {
|
|||
private Treatment treatment;
|
||||
private boolean isNewTreatment = false;
|
||||
|
||||
/**
|
||||
* Initialization method that is called after the binding of all the fields.
|
||||
*/
|
||||
public void initialize(
|
||||
AllTreatmentController controller,
|
||||
Stage stage,
|
||||
|
@ -117,9 +109,6 @@ public class TreatmentModalController {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to show the data in the view.
|
||||
*/
|
||||
private void showData() {
|
||||
this.labelNurseName.setText(nurse.getSurName());
|
||||
this.labelFirstName.setText(patient.getFirstName());
|
||||
|
@ -160,4 +149,8 @@ public class TreatmentModalController {
|
|||
public void handleCancel() {
|
||||
stage.close();
|
||||
}
|
||||
|
||||
public Treatment getTreatment() {
|
||||
return treatment;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package de.hitec.nhplus.treatment.database;
|
|||
|
||||
import de.hitec.nhplus.datastorage.DaoFactory;
|
||||
import de.hitec.nhplus.datastorage.DaoImp;
|
||||
import de.hitec.nhplus.patient.Patient;
|
||||
import de.hitec.nhplus.nurse.Nurse;
|
||||
import de.hitec.nhplus.treatment.Treatment;
|
||||
import de.hitec.nhplus.utils.DateConverter;
|
||||
|
@ -14,13 +13,6 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* The {@link TreatmentDao} is an implementation of the {@link de.hitec.nhplus.datastorage.Dao Dao}
|
||||
* for the {@link Treatment} model.
|
||||
*
|
||||
* @author Bernd Heidemannn
|
||||
* @author Dominik Säume
|
||||
*/
|
||||
public class TreatmentDao extends DaoImp<Treatment> {
|
||||
|
||||
public TreatmentDao(Connection connection) {
|
||||
|
@ -82,13 +74,6 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
|||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
||||
* {@link Patient#id patient ID} from the database.
|
||||
*
|
||||
* @param patientId The {@link Patient#id ID} of the {@link Patient} whose {@link Treatment}s are to be retrieved.
|
||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Patient} ID.
|
||||
*/
|
||||
public List<Treatment> readTreatmentsByPatient(int patientId) throws SQLException {
|
||||
final String SQL = "SELECT * FROM treatment WHERE patientId = ?";
|
||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||
|
@ -97,13 +82,6 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
|||
return getListFromResultSet(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of {@link Treatment}s associated with a specific
|
||||
* {@link Nurse#id patient ID} from the database.
|
||||
*
|
||||
* @param nurseId The {@link Nurse#id ID} of the {@link Nurse} whose {@link Treatment}s are to be retrieved.
|
||||
* @return A {@link List} of {@link Treatment} objects associated with the specified {@link Nurse} ID.
|
||||
*/
|
||||
public List<Treatment> readTreatmentsByNurse(int nurseId) throws SQLException {
|
||||
final String SQL = "SELECT * FROM treatment WHERE nurseId = ?";
|
||||
PreparedStatement statement = this.connection.prepareStatement(SQL);
|
||||
|
|
|
@ -4,44 +4,23 @@ import java.time.LocalDate;
|
|||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* A utility class that holds utility methods for date conversion.
|
||||
*
|
||||
* @author Bernd Heidemann
|
||||
*/
|
||||
public class DateConverter {
|
||||
|
||||
private static final String DATE_FORMAT = "yyyy-MM-dd";
|
||||
private static final String TIME_FORMAT = "HH:mm";
|
||||
|
||||
/**
|
||||
* @param date A date {@link String} in the format: yyyy-MM-dd.
|
||||
* @return The converted date {@link String} as {@link LocalDate}.
|
||||
*/
|
||||
public static LocalDate convertStringToLocalDate(String date) {
|
||||
return LocalDate.parse(date, DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time A time {@link String} in the format: HH:mm.
|
||||
* @return The converted time {@link String} as {@link LocalTime}.
|
||||
*/
|
||||
public static LocalTime convertStringToLocalTime(String time) {
|
||||
return LocalTime.parse(time, DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param date A {@link LocalDate} which should be converted to a {@link String}.
|
||||
* @return The converted {@link LocalDate} in the format: yyy-MM-dd.
|
||||
*/
|
||||
public static String convertLocalDateToString(LocalDate date) {
|
||||
return date.format(DateTimeFormatter.ofPattern(DATE_FORMAT));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param time A {@link LocalTime} which should be converted to a {@link String}.
|
||||
* @return The converted {@link LocalTime} in the format: HH:mm.
|
||||
*/
|
||||
public static String convertLocalTimeToString(LocalTime time) {
|
||||
return time.format(DateTimeFormatter.ofPattern(TIME_FORMAT));
|
||||
}
|
||||
|
|
|
@ -5,34 +5,17 @@ import javafx.scene.control.Alert;
|
|||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
|
||||
/**
|
||||
* A utility class for validating all kinds of data.
|
||||
*
|
||||
* @author Dominik Säume
|
||||
* @author Ole Kück
|
||||
*/
|
||||
public class Validator {
|
||||
|
||||
/**
|
||||
* Shows a modal with a specific validation error.
|
||||
*
|
||||
* @param type The type for which a validation error should be shown as {@link String}.
|
||||
*/
|
||||
public static void showValidationError(String type) {
|
||||
public class Validator
|
||||
{
|
||||
public static void showValidationError(String type){
|
||||
Alert alert = new Alert(Alert.AlertType.ERROR);
|
||||
alert.setTitle("Error");
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText("Invalid " + type + " !");
|
||||
alert.showAndWait();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid date.
|
||||
*
|
||||
* @param text The date {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidDate(String text) {
|
||||
if (text.isBlank()) {
|
||||
if(text.isBlank()){
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
|
@ -42,14 +25,8 @@ public class Validator {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link LocalDate} is a valid date for storage in the database.
|
||||
*
|
||||
* @param date The {@link LocalDate} to validate.
|
||||
*/
|
||||
public static boolean isValidDate(LocalDate date) {
|
||||
if (date == null) {
|
||||
if(date == null){
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
|
@ -59,34 +36,21 @@ public class Validator {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid time.
|
||||
*
|
||||
* @param text The time {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidTime(String text) {
|
||||
if (text.isBlank()) {
|
||||
public static boolean isValidTime(String text){
|
||||
if(text.isBlank()){
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
DateConverter.convertStringToLocalTime(text);
|
||||
} catch (Exception exception) {
|
||||
}catch (Exception exception){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that two time {@link String}s are a valid time range.
|
||||
*
|
||||
* @param start The starting time {@link String}.
|
||||
* @param end The ending time {@link String}.
|
||||
*/
|
||||
public static boolean isValidTimeRange(String start, String end) {
|
||||
if (
|
||||
!isValidTime(start) || !isValidTime(end)
|
||||
) {
|
||||
public static boolean isValidTimeRange(String start, String end){
|
||||
if(
|
||||
!isValidTime(start) || !isValidTime(end)
|
||||
){
|
||||
return false;
|
||||
}
|
||||
LocalTime startTime = DateConverter.convertStringToLocalTime(start);
|
||||
|
@ -95,57 +59,24 @@ public class Validator {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid description.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidDescription(String text) {
|
||||
public static boolean isValidDescription(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidFirstName(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidSurName(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidPhoneNumber(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidCareLevel(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
public static boolean isValidRoomNumber(String text){
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid first name.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidFirstName(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid surname.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidSurName(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid phone number.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidPhoneNumber(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid care level.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidCareLevel(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a {@link String} is a valid room number.
|
||||
*
|
||||
* @param text The {@link String} to validate.
|
||||
*/
|
||||
public static boolean isValidRoomNumber(String text) {
|
||||
return !text.isBlank();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue