From 708ed158c41ee2ee5dfce64fdecf89aed4c17685 Mon Sep 17 00:00:00 2001 From: Tharre Date: Tue, 1 May 2018 22:36:49 +0200 Subject: Add sql database schema --- src/main/resources/sql/database.sql | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/resources/sql/database.sql (limited to 'src/main/resources') diff --git a/src/main/resources/sql/database.sql b/src/main/resources/sql/database.sql new file mode 100644 index 0000000..9d1b0e1 --- /dev/null +++ b/src/main/resources/sql/database.sql @@ -0,0 +1,57 @@ +CREATE TABLE IF NOT EXISTS VehicleVersion ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(100) NOT NULL, + constructionType ENUM('Normal', 'Hochdach', 'Mittelhochdach') NOT NULL, + type ENUM('BKTW', 'KTW-B', 'KTW', 'RTW', 'NEF', 'NAH') NOT NULL, +); + +CREATE TABLE IF NOT EXISTS Vehicle ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + version BIGINT NOT NULL, + status ENUM('abgemeldet', 'frei_wache', 'zum_berufungsort', 'am_berufungsort', 'zum_zielort', + 'am_zielort', 'frei_funk', 'deleted') NOT NULL, + FOREIGN KEY (version) REFERENCES VehicleVersion(id), +); + +CREATE TABLE IF NOT EXISTS EmployeeVersion ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(100) NOT NULL, + birthday DATE NOT NULL, + educationLevel ENUM('RS', 'NFS', 'NKV', 'NKA', 'NKI', 'NA') NOT NULL, + isDriver BOOLEAN NOT NULL, + isPilot BOOLEAN NOT NULL, +); + +CREATE TABLE IF NOT EXISTS Employee ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + version BIGINT NOT NULL, + FOREIGN KEY (version) REFERENCES EmployeeVersion(id), +); + +CREATE TABLE IF NOT EXISTS Registration ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + vehicleId BIGINT NOT NULL, + employeeId BIGINT NOT NULL, + start TIMESTAMP NOT NULL, + end TIMESTAMP NOT NULL, + active BOOLEAN NOT NULL, + FOREIGN KEY (vehicleId) REFERENCES VehicleVersion(id), + FOREIGN KEY (employeeId) REFERENCES EmployeeVersion(id), +); + +CREATE TABLE IF NOT EXISTS Operation ( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + opCode VARCHAR(20) NOT NULL, + severity ENUM('A', 'B', 'C', 'D', 'E', 'O') NOT NULL, + created TIMESTAMP NOT NULL, + destination VARCHAR(100) NOT NULL, + additionalInfo VARCHAR(100), +); + +CREATE TABLE IF NOT EXISTS VehicleOperation ( + vehicleId BIGINT NOT NULL, + operationId BIGINT NOT NULL, + FOREIGN KEY (vehicleId) REFERENCES VehicleVersion(id), + FOREIGN KEY (operationId) REFERENCES Operation(id), + PRIMARY KEY (vehicleId, operationId), +); -- cgit v1.2.3-70-g09d2 From 4849e2fdcdbaca390f427e13a45de9015c2e8752 Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Tue, 1 May 2018 11:41:23 +0200 Subject: create first version of createNewEmployee-UI --- src/main/resources/fxml/createNewEmployee.fxml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/resources/fxml/createNewEmployee.fxml (limited to 'src/main/resources') diff --git a/src/main/resources/fxml/createNewEmployee.fxml b/src/main/resources/fxml/createNewEmployee.fxml new file mode 100644 index 0000000..3acc7d1 --- /dev/null +++ b/src/main/resources/fxml/createNewEmployee.fxml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From fa0991ed6d68e8658f7e413f4a765f12791486bf Mon Sep 17 00:00:00 2001 From: Viktoria Pundy Date: Fri, 4 May 2018 12:06:52 +0200 Subject: Finished implementing needed methods in Persistence layer, added some validation factors for operation validation; Added methods to ui to add/remove vehicles to operation, created dummy vehicles --- .../einsatzverwaltung/dao/DBOperationDAO.java | 19 ++-- .../einsatzverwaltung/dao/DBVehicleDAO.java | 49 ++++++--- .../service/OperationServiceImpl.java | 40 +++++-- .../service/VehicleServiceImpl.java | 18 +++- .../userInterface/CreateOperationController.java | 117 +++++++++++++++++++-- .../resources/fxml/CreateOperationController.fxml | 94 +++++++++++++++++ .../fxmlFiles/CreateOperationController.fxml | 94 ----------------- 7 files changed, 293 insertions(+), 138 deletions(-) create mode 100644 src/main/resources/fxml/CreateOperationController.fxml delete mode 100644 src/main/resources/fxmlFiles/CreateOperationController.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java index 7036a1b..707d346 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java @@ -5,6 +5,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.S import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.beans.Statement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -29,7 +30,8 @@ public class DBOperationDAO implements OperationDAO { .getConnection() .prepareStatement( "INSERT INTO operation(opCode, severity, " - + "created, destination, additionalInfo, status) values (?,?,?,?,?,?)"); + + "created, destination, additionalInfo, status) values (?,?,?,?,?,?)", + java.sql.Statement.RETURN_GENERATED_KEYS); if (operation.opCode() == null) { throw new PersistenceException("Code darf nicht null sein!"); @@ -79,18 +81,19 @@ public class DBOperationDAO implements OperationDAO { throw new PersistenceException( "Länge der zusätzlichen Information überschreitet erlaubte Länge von 100 Zeichen!"); else pstmt.setString(5, operation.additionalInfo()); - if (operation.status() != null) { - pstmt.setString(6, operation.status().toString()); + if (operation.status() == null) { + throw new PersistenceException("Status darf nicht null sein!"); } else if (operation.status().toString().length() > 100) { throw new PersistenceException( "Länge des Status überschreitet erlaubte Länge von 100 Zeichen!"); } else { - throw new PersistenceException("Status darf nicht null sein!"); + pstmt.setString(6, operation.status().toString()); } - - pstmt.executeQuery(); + pstmt.executeUpdate(); ResultSet rs = pstmt.getGeneratedKeys(); - if (rs.next()) return rs.getInt(1); + if (rs.next()) { + return rs.getInt(1); + } else throw new PersistenceException("Einsatz konnte nicht gespeichert werden"); } catch (SQLException e) { throw new PersistenceException(e); @@ -132,7 +135,7 @@ public class DBOperationDAO implements OperationDAO { + "values (?,?)"); pstmt.setLong(1, vehicleID); pstmt.setLong(2, operationID); - pstmt.executeQuery(); + pstmt.execute(); ResultSet rs = pstmt.getGeneratedKeys(); if (rs.next()) return rs.getInt(1); else diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java index 57a94de..e1b8c21 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java @@ -3,6 +3,7 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; @@ -11,7 +12,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nullable; public class DBVehicleDAO implements VehicleDAO { @@ -27,36 +27,51 @@ public class DBVehicleDAO implements VehicleDAO { } @Override - public void update(Vehicle vehicle) throws ElementNotFoundException, PersistenceException { - - } + public void update(Vehicle vehicle) throws ElementNotFoundException, PersistenceException {} @Override public List list() throws PersistenceException { PreparedStatement pstmt = null; List result = new LinkedList<>(); try { - pstmt = jdbcConnectionManager.getConnection().prepareStatement("Select * from VehicleVersion, " - + "Vehicle where VehicleVersion.id=Vehicle.version"); - //TODO: CORRECT? + pstmt = + jdbcConnectionManager + .getConnection() + .prepareStatement( + "Select * from VehicleVersion, " + + "Vehicle where VehicleVersion.id=Vehicle.version"); + // TODO: CORRECT? pstmt.executeQuery(); ResultSet rs = pstmt.getResultSet(); - while (rs.next()){ - //TODO: HAS NEF?, Registrations - Vehicle vehicle = Vehicle.builder().name(rs.getString(2)). - constructionType(ConstructionType.valueOf(rs.getString(2))). - status(Status.valueOf(rs.getString(7))).id(rs.getInt(1)).build(); + while (rs.next()) { + // TODO: Registrations + Vehicle vehicle = + Vehicle.builder() + .name(rs.getString(2)) + .constructionType(ConstructionType.valueOf(rs.getString(3))) + .status(Status.valueOf(rs.getString(8))) + .id(rs.getInt(6)) + .hasNef(rs.getBoolean(5)) + .type(VehicleType.valueOf(rs.getString(4))) + .build(); result.add(vehicle); } } catch (SQLException e) { - //TODO + throw new PersistenceException("Die Werte konnten nicht geladen werden.", e); + } finally { + if (pstmt != null) { + try { + pstmt.close(); + } catch (SQLException e) { + throw new PersistenceException( + "Verbindung zur Datenbank konnte nicht geschlossen werden!", e); + } + } } - return null; + return result; } @Override - public void remove(long id) throws ElementNotFoundException, PersistenceException { - - } + public void remove(long id) throws ElementNotFoundException, PersistenceException {} } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java index eee158b..9ba3a63 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java @@ -11,6 +11,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationExcepti import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; import javafx.collections.transformation.SortedList; @@ -18,12 +19,22 @@ import javafx.collections.transformation.SortedList; public class OperationServiceImpl implements OperationService { // TODO: anders? - private OperationDAO operationDAO = new DBOperationDAO(); + private OperationDAO operationDAO = new DBOperationDAO(new JDBCConnectionManager()); @Override public long add(Operation operation) throws InvalidOperationException, ServiceException { List vehicles = operation.vehicles(); boolean rtw = false; + if (operation.vehicles().size() == 0) { + throw new InvalidOperationException( + "Es muss mindestens ein Fahrzeug ausgewählt werden!"); + } + if (faultyInput(operation.destination())){ + throw new InvalidOperationException("Adresse ist ungültig!"); + } + if (faultyInput(operation.opCode())){ + throw new InvalidOperationException("Code ist ungültig!"); + } for (Vehicle vehicle : vehicles) { if (vehicle.status() == Vehicle.Status.ABGEMELDET) throw new InvalidOperationException( @@ -47,7 +58,7 @@ public class OperationServiceImpl implements OperationService { } } if (!rtw) - //TODO: NUR WARNUNG AUSGEBEN + // TODO: NUR WARNUNG AUSGEBEN throw new InvalidOperationException( "Zu einem Fahrzeug des Typs NAH muss auch ein Fahrzeug des Typs RTW geschickt werden!"); } @@ -55,7 +66,7 @@ public class OperationServiceImpl implements OperationService { String[] codeParts = operation.opCode().split("\\-"); String severity = ""; for (int i = 0; i < codeParts[1].length(); i++) { - if ((int) (codeParts[1].charAt(i)) > 101 && (int) (codeParts[1].charAt(i)) < 117) { + if (((int) (codeParts[1].charAt(i)) >= 65 && (int) (codeParts[1].charAt(i)) <= 79) || ((int) (codeParts[1].charAt(i)) >= 97 && (int) (codeParts[1].charAt(i))<=111)) { severity = "" + codeParts[1].charAt(i); break; } @@ -66,11 +77,28 @@ public class OperationServiceImpl implements OperationService { throw new InvalidOperationException( "Der Schweregrad des Einsatzes konnte nicht ausgelesen werden!"); } + operation = operation.toBuilder().status(Status.ACTIVE).build(); for (Vehicle vehicle : vehicles) { - operationDAO.connectVehicleToOperation(vehicle.id(), operation.id()); + try { + operationDAO.connectVehicleToOperation(vehicle.id(), operation.id()); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + try { + return operationDAO.add(operation); + } catch (PersistenceException e) { + throw new ServiceException(e); + } + } + + private boolean faultyInput(String name) { + if (name == null) return true; + else if (name.isEmpty()) return true; + for (int i = 0; i < name.length(); i++) { + if (name.charAt(i) != ' ') return false; } - return operationDAO.add(operation); - // TODO: CODE VALIDIEREN? + return true; } @Override diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java index 80d7432..f21ae9a 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java @@ -1,14 +1,21 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBVehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; public class VehicleServiceImpl implements VehicleService { + // TODO + private static VehicleDAO vehicleDAO = new DBVehicleDAO(new JDBCConnectionManager()); + @Override public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { return 0; @@ -21,11 +28,14 @@ public class VehicleServiceImpl implements VehicleService { @Override public List list(EnumSet statuses) throws ServiceException { - return null; + // TODO: IMPLEMENT SEARCH WITH STATUS + try { + return vehicleDAO.list(); + } catch (PersistenceException e) { + throw new ServiceException(e); + } } @Override - public void remove(long id) throws InvalidVehicleException, ServiceException { - - } + public void remove(long id) throws InvalidVehicleException, ServiceException {} } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java index 10f9f03..8df8acc 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java @@ -1,19 +1,27 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.userInterface; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationServiceImpl; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleServiceImpl; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; import java.time.Instant; +import java.util.EnumSet; import java.util.LinkedList; import java.util.List; +import javafx.collections.FXCollections; import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; @@ -28,8 +36,9 @@ public class CreateOperationController { public ListView lvVehicles; public ListView lvActiveOperations; public Label lblChosenVehicles; - public LinkedList chosenVehicles; + public LinkedList chosenVehicles = new LinkedList<>(); + // TODO: Anders? OperationService operationService = new OperationServiceImpl(); VehicleService vehicleService = new VehicleServiceImpl(); @@ -37,14 +46,104 @@ public class CreateOperationController { @FXML public void initialize() { + lblChosenVehicles.setText("keine ausgewählt"); + lvVehicles.setCellFactory( + param -> + new ListCell() { + @Override + protected void updateItem(Vehicle item, boolean empty) { + super.updateItem(item, empty); + + if (empty || item == null || item.name() == null) { + setText(null); + } else { + setText(item.name()); + } + } + }); + lvVehicles.setOnMouseClicked( event -> { if (event.getClickCount() == 2) { - chosenVehicles.add(lvVehicles.getSelectionModel().getSelectedItem()); + boolean remove = false; + for (int i = 0; i < chosenVehicles.size(); i++) { + if (lvVehicles + .getSelectionModel() + .getSelectedItem() + .equals(chosenVehicles.get(i))) { + remove = true; + break; + } + } + if (!remove) { + chosenVehicles.add(lvVehicles.getSelectionModel().getSelectedItem()); + + } + else { + chosenVehicles.remove(lvVehicles.getSelectionModel().getSelectedItem()); + + } + String result = ""; + for (int i = 0; i < chosenVehicles.size(); i++) { + if (i == chosenVehicles.size() - 1) { + result += chosenVehicles.get(i).name(); + } else { + result += chosenVehicles.get(i).name() + ", "; + } + } + if (result.equals("")){ + lblChosenVehicles.setText("keine ausgewählt"); + } + else { + lblChosenVehicles.setText(result); + } } }); } + public void fillList() { + // TODO: Zu anderem Zeitpunkt aktualisieren. + /*try { + this.lvVehicles.setItems( + //TODO: ALLE FREI STATI Frei FUnk Frei Wache + FXCollections.observableArrayList( + vehicleService.list(EnumSet.of(Vehicle.Status.FREI_FUNK)))); + } catch (ServiceException e) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Fehler"); + alert.setHeaderText("Fehler!"); + alert.setContentText(e.getMessage()); + alert.showAndWait(); + }*/ + + this.lvVehicles.setItems(FXCollections.observableArrayList(mylist())); + } + + private LinkedList mylist() { + Vehicle vehicle = + Vehicle.builder() + .name("Test-KTW") + .constructionType(ConstructionType.HOCHDACH) + .type(VehicleType.KTW) + .status(Vehicle.Status.FREI_WACHE) + .hasNef(true) + .build(); + + Vehicle vehicle1 = + Vehicle.builder() + .name("Test-NEF") + .constructionType(ConstructionType.NORMAL) + .type(VehicleType.NEF) + .status(Vehicle.Status.FREI_FUNK) + .hasNef(true) + .build(); + LinkedList list = new LinkedList<>(); + list.add(vehicle); + list.add(vehicle1); + // this.lvVehicles.setItems(FXCollections.observableArrayList(list)); + return list; + } + @FXML protected void createOperationClicked() { Vehicle[] vehicles = new Vehicle[chosenVehicles.size()]; @@ -59,16 +158,16 @@ public class CreateOperationController { .opCode(txtCode.getText()) .status(Status.ACTIVE) .vehicles(List.of(vehicles)) + .severity(Severity.A) .build(); - try { operationService.add(operation); - } catch (InvalidOperationException e) { - //TODO - } catch (ServiceException e) { - e.printStackTrace(); + } catch (ServiceException | InvalidOperationException e) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle("Fehler"); + alert.setHeaderText("Fehler!"); + alert.setContentText(e.getMessage()); + alert.showAndWait(); } } - - } diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml new file mode 100644 index 0000000..949d4ec --- /dev/null +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml deleted file mode 100644 index 7b188fd..0000000 --- a/src/main/resources/fxmlFiles/CreateOperationController.fxml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2 From 26112a42b3608c919fefe9e2d4ba02a6d4e15b86 Mon Sep 17 00:00:00 2001 From: Viktoria Pundy Date: Wed, 2 May 2018 21:18:20 +0200 Subject: Created first (unfinished) version for operation UI, started implementing Controller --- .../userInterface/CreateOperationController.java | 7 ++ .../fxmlFiles/CreateOperationController.fxml | 94 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/main/resources/fxmlFiles/CreateOperationController.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java index 7e6722c..b5a8cf1 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java @@ -3,6 +3,7 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.userInterface; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBOperationDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; @@ -22,6 +23,12 @@ import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListCell; +import java.time.Instant; +import java.util.LinkedList; +import java.util.List; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml new file mode 100644 index 0000000..7b188fd --- /dev/null +++ b/src/main/resources/fxmlFiles/CreateOperationController.fxml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From d77d9625cb4cd05d2b746c721b65f0f32313fab8 Mon Sep 17 00:00:00 2001 From: Viktoria Pundy Date: Fri, 4 May 2018 12:06:52 +0200 Subject: Finished implementing needed methods in Persistence layer, added some validation factors for operation validation; Added methods to ui to add/remove vehicles to operation, created dummy vehicles --- .../einsatzverwaltung/dao/DBOperationDAO.java | 5 +- .../einsatzverwaltung/dao/DBVehicleDAO.java | 1 - .../service/OperationServiceImpl.java | 1 + .../service/VehicleServiceImpl.java | 18 ++++- .../userInterface/CreateOperationController.java | 8 ++ .../fxmlFiles/CreateOperationController.fxml | 94 ---------------------- 6 files changed, 27 insertions(+), 100 deletions(-) delete mode 100644 src/main/resources/fxmlFiles/CreateOperationController.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java index d332acc..aaf7631 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java @@ -5,6 +5,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.S import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.beans.Statement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -92,7 +93,9 @@ public class DBOperationDAO implements OperationDAO { } pstmt.executeUpdate(); ResultSet rs = pstmt.getGeneratedKeys(); - if (rs.next()) return rs.getInt(1); + if (rs.next()) { + return rs.getInt(1); + } else throw new PersistenceException("Einsatz konnte nicht gespeichert werden"); } catch (SQLException e) { throw new PersistenceException(e); diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java index a2cd486..d966dc5 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBVehicleDAO.java @@ -12,7 +12,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nullable; public class DBVehicleDAO implements VehicleDAO { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java index 4d5fb68..e0fd824 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java @@ -15,6 +15,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationExcepti import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; import javafx.collections.transformation.SortedList; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java index 80d7432..f21ae9a 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java @@ -1,14 +1,21 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBVehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; public class VehicleServiceImpl implements VehicleService { + // TODO + private static VehicleDAO vehicleDAO = new DBVehicleDAO(new JDBCConnectionManager()); + @Override public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { return 0; @@ -21,11 +28,14 @@ public class VehicleServiceImpl implements VehicleService { @Override public List list(EnumSet statuses) throws ServiceException { - return null; + // TODO: IMPLEMENT SEARCH WITH STATUS + try { + return vehicleDAO.list(); + } catch (PersistenceException e) { + throw new ServiceException(e); + } } @Override - public void remove(long id) throws InvalidVehicleException, ServiceException { - - } + public void remove(long id) throws InvalidVehicleException, ServiceException {} } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java index b5a8cf1..ab761e3 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java @@ -4,11 +4,15 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBOperation import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationServiceImpl; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleServiceImpl; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; @@ -24,11 +28,15 @@ import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListCell; import java.time.Instant; +import java.util.EnumSet; import java.util.LinkedList; import java.util.List; +import javafx.collections.FXCollections; import javafx.fxml.FXML; +import javafx.scene.control.Alert; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml deleted file mode 100644 index 7b188fd..0000000 --- a/src/main/resources/fxmlFiles/CreateOperationController.fxml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2 From 854f8e0cfdf14b9cbc17f8ec1039604363734c77 Mon Sep 17 00:00:00 2001 From: Viktoria Pundy Date: Wed, 2 May 2018 21:18:20 +0200 Subject: Created first (unfinished) version for operation UI, started implementing Controller --- .../userInterface/CreateOperationController.java | 7 ++ .../fxmlFiles/CreateOperationController.fxml | 94 ++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 src/main/resources/fxmlFiles/CreateOperationController.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java index 47de178..3bf50e4 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java @@ -6,6 +6,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.S import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBOperationDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; @@ -37,6 +38,12 @@ import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListCell; +import java.time.Instant; +import java.util.LinkedList; +import java.util.List; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml new file mode 100644 index 0000000..7b188fd --- /dev/null +++ b/src/main/resources/fxmlFiles/CreateOperationController.fxml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From a24998777f198617819ffef3e7ff5ef7a0bc5dc2 Mon Sep 17 00:00:00 2001 From: Viktoria Pundy Date: Fri, 4 May 2018 12:06:52 +0200 Subject: Finished implementing needed methods in Persistence layer, added some validation factors for operation validation; Added methods to ui to add/remove vehicles to operation, created dummy vehicles --- .../einsatzverwaltung/dao/DBOperationDAO.java | 5 +- .../service/OperationServiceImpl.java | 1 + .../service/VehicleServiceImpl.java | 18 ++++- .../userInterface/CreateOperationController.java | 22 ----- .../fxmlFiles/CreateOperationController.fxml | 94 ---------------------- 5 files changed, 19 insertions(+), 121 deletions(-) delete mode 100644 src/main/resources/fxmlFiles/CreateOperationController.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java index d332acc..aaf7631 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/DBOperationDAO.java @@ -5,6 +5,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.S import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.beans.Statement; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -92,7 +93,9 @@ public class DBOperationDAO implements OperationDAO { } pstmt.executeUpdate(); ResultSet rs = pstmt.getGeneratedKeys(); - if (rs.next()) return rs.getInt(1); + if (rs.next()) { + return rs.getInt(1); + } else throw new PersistenceException("Einsatz konnte nicht gespeichert werden"); } catch (SQLException e) { throw new PersistenceException(e); diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java index 36f8d8b..ad16caf 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceImpl.java @@ -21,6 +21,7 @@ import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationExcepti import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; import javafx.collections.transformation.SortedList; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java index 80d7432..f21ae9a 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java @@ -1,14 +1,21 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBVehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.util.EnumSet; import java.util.List; public class VehicleServiceImpl implements VehicleService { + // TODO + private static VehicleDAO vehicleDAO = new DBVehicleDAO(new JDBCConnectionManager()); + @Override public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { return 0; @@ -21,11 +28,14 @@ public class VehicleServiceImpl implements VehicleService { @Override public List list(EnumSet statuses) throws ServiceException { - return null; + // TODO: IMPLEMENT SEARCH WITH STATUS + try { + return vehicleDAO.list(); + } catch (PersistenceException e) { + throw new ServiceException(e); + } } @Override - public void remove(long id) throws InvalidVehicleException, ServiceException { - - } + public void remove(long id) throws InvalidVehicleException, ServiceException {} } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java index 3bf50e4..b9b6c6d 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/userInterface/CreateOperationController.java @@ -3,10 +3,6 @@ package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.userInterface; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBOperationDAO; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.DBOperationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Severity; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Operation.Status; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; @@ -15,7 +11,6 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.Vehicle import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; import java.time.Instant; import java.util.EnumSet; import java.util.LinkedList; @@ -23,27 +18,10 @@ import java.util.List; import javafx.collections.FXCollections; import javafx.fxml.FXML; import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListCell; -import java.time.Instant; -import java.util.EnumSet; -import java.util.LinkedList; -import java.util.List; -import javafx.collections.FXCollections; -import javafx.fxml.FXML; -import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.ListCell; -import java.time.Instant; -import java.util.LinkedList; -import java.util.List; -import javafx.fxml.FXML; -import javafx.scene.control.Button; -import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.control.TextField; import javafx.scene.layout.AnchorPane; diff --git a/src/main/resources/fxmlFiles/CreateOperationController.fxml b/src/main/resources/fxmlFiles/CreateOperationController.fxml deleted file mode 100644 index 7b188fd..0000000 --- a/src/main/resources/fxmlFiles/CreateOperationController.fxml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3-70-g09d2 From 3d3f4440238ededefa6bb142106295d6eab4678c Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Mon, 7 May 2018 12:33:11 +0200 Subject: Change CreateOperationController.fxml labels to hyperlinks with onAction --- src/main/resources/fxml/CreateOperationController.fxml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 949d4ec..1ba6498 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -1,6 +1,7 @@ + @@ -59,21 +60,21 @@ - - - + -- cgit v1.2.3-70-g09d2 From e7acdd7afb6612ef35265ba706ae968d326495a7 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Sat, 5 May 2018 22:17:05 +0200 Subject: First mockup of RegistrationWindow and its controller --- .../controller/RegistrationWindowController.java | 203 +++++++++++++++++++++ src/main/resources/fxml/RegistrationWindow.fxml | 76 ++++++++ 2 files changed, 279 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java create mode 100644 src/main/resources/fxml/RegistrationWindow.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java new file mode 100644 index 0000000..8fea9dc --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java @@ -0,0 +1,203 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidRegistrationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneOffset; +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; +import javafx.beans.property.SimpleStringProperty; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.fxml.FXML; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import javafx.scene.input.MouseEvent; +import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; + +@Controller +public class RegistrationWindowController { + + private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); + + private EmployeeService employeeService; + + private VehicleService vehicleService; + + private RegistrationService registrationService; + + @Autowired + public void setEmployeeService(EmployeeService employeeService) { + this.employeeService = employeeService; + } + + @Autowired + public void setVehicleService(VehicleService vehicleService) { + this.vehicleService = vehicleService; + } + + @Autowired + public void setRegistrationService(RegistrationService registrationService) { + this.registrationService = registrationService; + } + + @FXML public ChoiceBox cbStart; + @FXML public ChoiceBox cbEnd; + @FXML public Label lVehicles; + @FXML public Label lEmployees; + @FXML public TextField tfVehicleSearch; + @FXML public TextField tfEmployeeSearch; + @FXML public TableView tvVehicles; + @FXML public TableView tvEmployees; + @FXML public TableColumn tcVehicles; + @FXML public TableColumn tcEmployees; + + private Vehicle chosenVehicle; + private List chosenEmployees = new LinkedList<>(); + + @FXML + public void initialize() { + // will have to be replaced for FlowPane + try { + List vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + tcVehicles.setCellValueFactory(x -> new SimpleStringProperty(x.getValue().name())); + tvVehicles.setItems(FXCollections.observableArrayList(vehicles)); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting vehicles. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Fahrzeuge - Fehler!"); + alert.setHeaderText("Beim Auflisten der Fahrzeug ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } + try { + List employees = employeeService.list(); + tcEmployees.setCellValueFactory(x -> new SimpleStringProperty(x.getValue().name())); + tvEmployees.setItems(FXCollections.observableArrayList(employees)); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting employees. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Personal - Fehler!"); + alert.setHeaderText("Beim Auflisten des Personals ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } + tvVehicles.setOnMousePressed( + new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { + chosenVehicle = tvVehicles.getSelectionModel().getSelectedItem(); + lVehicles.setText(chosenVehicle.name()); + } + } + }); + tvEmployees.setOnMousePressed( + new EventHandler() { + @Override + public void handle(MouseEvent mouseEvent) { + if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { + chosenEmployees.add(tvEmployees.getSelectionModel().getSelectedItem()); + StringBuilder text = new StringBuilder(); + for (Employee employee : chosenEmployees) { + text.append(employee.name()).append("\n"); + } + lEmployees.setText(text.toString()); + } + } + }); + ObservableList hours = + FXCollections.observableArrayList( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23); + cbStart.setItems(hours); + cbEnd.setItems(hours); + } + + public void cancel() { + LOG.debug("Cancel Button clicked"); + ((Stage) lVehicles.getScene().getWindow()).close(); + } + + public void create() { + LOG.debug("Create Button clicked"); + + List registrations = new LinkedList<>(); + + for (Employee employee : chosenEmployees) { + registrations.add( + Registration.builder() + .id(chosenVehicle.id()) + .employee(employee) + .start( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbStart.getValue(), 0)) + .toInstant(ZoneOffset.ofHours(0))) + .end( + LocalDateTime.of( + LocalDate.now(), + LocalTime.of(cbEnd.getValue(), 0)) + .toInstant(ZoneOffset.ofHours(0))) + .build()); + } + try { + registrationService.add(chosenVehicle, registrations); + } catch (InvalidVehicleException e) { + // NOT THROWN ANYWHERE RIGHT NOW + LOG.info( + "Caught InvalidVehicleException. Showing it to user. Error message: {}", + e.getClass().toString(), + e.getMessage()); + Alert alert = new Alert(AlertType.WARNING); + alert.setTitle("Ungültiges Fahrzeug"); + alert.setHeaderText("Das spezifizierte Fahrzeug ist nicht gültig."); + alert.setContentText(e.getMessage()); + alert.show(); + } catch (ServiceException e) { + LOG.warn( + "Caught ServiceException while getting vehicles. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.ERROR); + alert.setTitle("Anmeldung - Fehler!"); + alert.setHeaderText("Beim Erstellen der Anmeldung ist ein Fehler aufgetreten."); + alert.setContentText(e.getMessage()); + alert.show(); + } catch (InvalidRegistrationException e) { + LOG.info( + "Caught InvalidRegistrationException. Showing it to user. Error message: {}", + e.getMessage()); + Alert alert = new Alert(AlertType.WARNING); + alert.setTitle("Ungültige Eingabe"); + alert.setHeaderText( + "Die gewählte Kombination von Fahrzeug und Personal ist nicht gültig!"); + alert.setContentText(e.getMessage()); + alert.show(); + } + } +} diff --git a/src/main/resources/fxml/RegistrationWindow.fxml b/src/main/resources/fxml/RegistrationWindow.fxml new file mode 100644 index 0000000..0394ca7 --- /dev/null +++ b/src/main/resources/fxml/RegistrationWindow.fxml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 5a6c00ebc1583e0505fb795b3483f8937e7b8eb4 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Sun, 6 May 2018 16:01:10 +0200 Subject: Added groundwork for DAO tests --- pom.xml | 4 +- .../sql/H2RegistrationDAOTest_depopulate.sql | 5 ++ .../sql/H2RegistrationDAOTest_populate.sql | 10 ++++ .../dao/H2RegistrationDAOTest.java | 65 ++++++++++++++++++++++ 4 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql create mode 100644 src/main/resources/sql/H2RegistrationDAOTest_populate.sql create mode 100644 src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java (limited to 'src/main/resources') diff --git a/pom.xml b/pom.xml index 42f24e7..95747aa 100644 --- a/pom.xml +++ b/pom.xml @@ -66,13 +66,13 @@ ${auto-value.version} provided - com.h2database h2 ${h2.version} - runtime + compile + ch.qos.logback logback-classic diff --git a/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql b/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql new file mode 100644 index 0000000..f43b641 --- /dev/null +++ b/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql @@ -0,0 +1,5 @@ +DELETE FROM Registration; +DELETE FROM Vehicle; +DELETE FROM VehicleVersion; +DELETE FROM Employee; +DELETE FROM EmployeeVersion; \ No newline at end of file diff --git a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql new file mode 100644 index 0000000..8322479 --- /dev/null +++ b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql @@ -0,0 +1,10 @@ +INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (1, 'John Doe', '2000-01-01', 'RS', TRUE, TRUE); +INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (2, 'Nick "Kage" Verily', '1990-01-01', 'NKV', TRUE, FALSE); +INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (3, 'Nicht Arzt', '1980-01-01', 'NA', FALSE, FALSE); +INSERT INTO Employee (id, version) VALUES (1, 1); +INSERT INTO Employee (id, version) VALUES (2, 2); +INSERT INTO Employee (id, version) VALUES (3, 3); +INSERT INTO VehicleVersion (id, name, constructionType, type) VALUES (1, 'RTW-1', 'Hochdach', 'RTW'); +INSERT INTO VehicleVersion (id, name, constructionType, type) VALUES (2, 'NEF-1', 'Normal', 'NEF'); +INSERT INTO Vehicle (id, version, status) VALUES (1, 1, 'abgemeldet'); +INSERT INTO Vehicle (id, version, status) VALUES (2, 2, 'abgemeldet'); \ No newline at end of file diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java new file mode 100644 index 0000000..03b70b1 --- /dev/null +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/H2RegistrationDAOTest.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; + +import static org.junit.Assert.*; + +import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.nio.charset.Charset; +import java.sql.SQLException; +import org.h2.tools.RunScript; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class H2RegistrationDAOTest { + + // Base taken from EmployeePersistenceTest + + private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + private static final String JDBC_URL = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"; + private static final String USER = ""; + private static final String PASSWORD = ""; + + private RegistrationDAO registrationDAO; + + public H2RegistrationDAOTest() throws PersistenceException { + this.registrationDAO = new H2RegistrationDAO(new JDBCConnectionManager(JDBC_URL)); + } + + @BeforeClass + public static void setupDatabase() throws SQLException { + RunScript.execute( + JDBC_URL, + USER, + PASSWORD, + "classpath:sql/database.sql", + Charset.forName("UTF8"), + false); + } + + @Before + public void setUp() throws SQLException { + RunScript.execute( + JDBC_URL, + USER, + PASSWORD, + "classpath:sql/H2RegistrationDAOTest_populate.sql", + Charset.forName("UTF8"), + false); + } + + @After + public void tearDown() throws SQLException { + RunScript.execute( + JDBC_URL, + USER, + PASSWORD, + "classpath:sql/H2RegistrationDAOTest_depopulate.sql", + Charset.forName("UTF8"), + false); + } + + @Test + public void add() {} +} -- cgit v1.2.3-70-g09d2 From 12302ff88604440cac2257741b4502b9b173d708 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Mon, 7 May 2018 14:53:00 +0200 Subject: Changed test data to be in sync with new database schema --- src/main/resources/sql/H2RegistrationDAOTest_populate.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql index 8322479..b81eb78 100644 --- a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql +++ b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql @@ -4,7 +4,7 @@ INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPil INSERT INTO Employee (id, version) VALUES (1, 1); INSERT INTO Employee (id, version) VALUES (2, 2); INSERT INTO Employee (id, version) VALUES (3, 3); -INSERT INTO VehicleVersion (id, name, constructionType, type) VALUES (1, 'RTW-1', 'Hochdach', 'RTW'); -INSERT INTO VehicleVersion (id, name, constructionType, type) VALUES (2, 'NEF-1', 'Normal', 'NEF'); +INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (1, 'RTW-1', TRUE, 'Hochdach', 'RTW'); +INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (2, 'NEF-1', FALSE, 'Normal', 'NEF'); INSERT INTO Vehicle (id, version, status) VALUES (1, 1, 'abgemeldet'); INSERT INTO Vehicle (id, version, status) VALUES (2, 2, 'abgemeldet'); \ No newline at end of file -- cgit v1.2.3-70-g09d2 From ad44dc581b063485eede5c2b19b1b5ab0753ce72 Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Sat, 5 May 2018 15:45:15 +0200 Subject: Change enum types to varchar with check constraint to support DBUnit --- src/main/resources/sql/database.sql | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/sql/database.sql b/src/main/resources/sql/database.sql index bb23c91..e775550 100644 --- a/src/main/resources/sql/database.sql +++ b/src/main/resources/sql/database.sql @@ -1,26 +1,30 @@ CREATE TABLE IF NOT EXISTS VehicleVersion ( id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, - constructionType ENUM('Normal', 'Hochdach', 'Mittelhochdach') NOT NULL, - type ENUM('BKTW', 'KTW-B', 'KTW', 'RTW', 'NEF', 'NAH') NOT NULL, + constructionType VARCHAR NOT NULL, + type VARCHAR NOT NULL, hasNef BOOLEAN NOT NULL, + CHECK constructionType IN ('Normal', 'Hochdach', 'Mittelhochdach'), + CHECK type IN ('BKTW', 'KTW-B', 'KTW', 'RTW', 'NEF', 'NAH') ); CREATE TABLE IF NOT EXISTS Vehicle ( id BIGINT AUTO_INCREMENT PRIMARY KEY, version BIGINT NOT NULL, - status ENUM('abgemeldet', 'frei_wache', 'zum_berufungsort', 'am_berufungsort', 'zum_zielort', - 'am_zielort', 'frei_funk', 'deleted') NOT NULL, + status VARCHAR NOT NULL, FOREIGN KEY (version) REFERENCES VehicleVersion(id), + CHECK status IN ('abgemeldet', 'frei_wache', 'zum_berufungsort', 'am_berufungsort', 'zum_zielort', + 'am_zielort', 'frei_funk', 'deleted') ); CREATE TABLE IF NOT EXISTS EmployeeVersion ( id BIGINT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100) NOT NULL, birthday DATE NOT NULL, - educationLevel ENUM('RS', 'NFS', 'NKV', 'NKA', 'NKI', 'NA') NOT NULL, + educationLevel VARCHAR NOT NULL, isDriver BOOLEAN NOT NULL, isPilot BOOLEAN NOT NULL, + CHECK educationLevel IN ('RS', 'NFS', 'NKV', 'NKA', 'NKI', 'NA') ); CREATE TABLE IF NOT EXISTS Employee ( @@ -43,10 +47,11 @@ CREATE TABLE IF NOT EXISTS Registration ( CREATE TABLE IF NOT EXISTS Operation ( id BIGINT AUTO_INCREMENT PRIMARY KEY, opCode VARCHAR(20) NOT NULL, - severity ENUM('A', 'B', 'C', 'D', 'E', 'O') NOT NULL, + severity VARCHAR NOT NULL, created TIMESTAMP NOT NULL, destination VARCHAR(100) NOT NULL, additionalInfo VARCHAR(100), + CHECK severity IN ('A', 'B', 'C', 'D', 'E', 'O') ); CREATE TABLE IF NOT EXISTS VehicleOperation ( -- cgit v1.2.3-70-g09d2 From d4d8ba884a80d0f7483efe2fb2c981023f983022 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Mon, 7 May 2018 17:23:31 +0200 Subject: Changed enums (and similar fields) to match enum names of Java --- .../einsatzverwaltung/dao/RegistrationDatabaseDAO.java | 2 +- src/main/resources/sql/H2RegistrationDAOTest_populate.sql | 8 ++++---- src/main/resources/sql/database.sql | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java index e4bc0ab..8fbcd18 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java @@ -25,7 +25,7 @@ public class RegistrationDatabaseDAO implements RegistrationDAO { private static final String ADD_REGISTRATION = "INSERT INTO Registration (vehicleId, employeeId, start, end, active) VALUES (?,?,?,?,?);"; private static final String UPDATE_VEHICLE = - "UPDATE Vehicle SET status = 'frei_wache' WHERE id = ?;"; + "UPDATE Vehicle SET status = 'FREI_WACHE' WHERE id = ?;"; private PreparedStatement addRegistration; private PreparedStatement updateVehicle; diff --git a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql index b81eb78..3c268a0 100644 --- a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql +++ b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql @@ -4,7 +4,7 @@ INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPil INSERT INTO Employee (id, version) VALUES (1, 1); INSERT INTO Employee (id, version) VALUES (2, 2); INSERT INTO Employee (id, version) VALUES (3, 3); -INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (1, 'RTW-1', TRUE, 'Hochdach', 'RTW'); -INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (2, 'NEF-1', FALSE, 'Normal', 'NEF'); -INSERT INTO Vehicle (id, version, status) VALUES (1, 1, 'abgemeldet'); -INSERT INTO Vehicle (id, version, status) VALUES (2, 2, 'abgemeldet'); \ No newline at end of file +INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (1, 'RTW-1', TRUE, 'HOCHDACH', 'RTW'); +INSERT INTO VehicleVersion (id, name, hasNef, constructionType, type) VALUES (2, 'NEF-1', FALSE, 'NORMAL', 'NEF'); +INSERT INTO Vehicle (id, version, status) VALUES (1, 1, 'ABGEMELDET'); +INSERT INTO Vehicle (id, version, status) VALUES (2, 2, 'ABGEMELDET'); \ No newline at end of file diff --git a/src/main/resources/sql/database.sql b/src/main/resources/sql/database.sql index e775550..4f3adf7 100644 --- a/src/main/resources/sql/database.sql +++ b/src/main/resources/sql/database.sql @@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS VehicleVersion ( constructionType VARCHAR NOT NULL, type VARCHAR NOT NULL, hasNef BOOLEAN NOT NULL, - CHECK constructionType IN ('Normal', 'Hochdach', 'Mittelhochdach'), + CHECK constructionType IN ('NORMAL', 'HOCHDACH', 'MITTELHOCHDACH'), CHECK type IN ('BKTW', 'KTW-B', 'KTW', 'RTW', 'NEF', 'NAH') ); @@ -13,8 +13,8 @@ CREATE TABLE IF NOT EXISTS Vehicle ( version BIGINT NOT NULL, status VARCHAR NOT NULL, FOREIGN KEY (version) REFERENCES VehicleVersion(id), - CHECK status IN ('abgemeldet', 'frei_wache', 'zum_berufungsort', 'am_berufungsort', 'zum_zielort', - 'am_zielort', 'frei_funk', 'deleted') + CHECK status IN ('ABGEMELDET', 'FREI_WACHE', 'ZUM_BERUFUNGSORT', 'AM_BERUFUNGSORT', 'ZUM_ZIELORT', + 'AM_ZIELORT', 'FREI_FUNK', 'DELETED') ); CREATE TABLE IF NOT EXISTS EmployeeVersion ( @@ -51,7 +51,9 @@ CREATE TABLE IF NOT EXISTS Operation ( created TIMESTAMP NOT NULL, destination VARCHAR(100) NOT NULL, additionalInfo VARCHAR(100), - CHECK severity IN ('A', 'B', 'C', 'D', 'E', 'O') + status VARCHAR NOT NULL, + CHECK severity IN ('A', 'B', 'C', 'D', 'E', 'O'), + CHECK status IN ('ACTIVE', 'COMPLETED', 'CANCELLED') ); CREATE TABLE IF NOT EXISTS VehicleOperation ( -- cgit v1.2.3-70-g09d2 From 834f9b4fff11c778dbb09dc74a88d658fc094a54 Mon Sep 17 00:00:00 2001 From: Felix Kehrer Date: Mon, 7 May 2018 18:06:00 +0200 Subject: Changed test behaviour to leave "clean" database for other tests --- .../sql/H2RegistrationDAOTest_populate.sql | 5 +++++ .../dao/RegistrationDatabaseDAOTest.java | 24 ++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql index 3c268a0..7e7b428 100644 --- a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql +++ b/src/main/resources/sql/H2RegistrationDAOTest_populate.sql @@ -1,3 +1,8 @@ +DELETE FROM Registration; +DELETE FROM Vehicle; +DELETE FROM VehicleVersion; +DELETE FROM Employee; +DELETE FROM EmployeeVersion; INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (1, 'John Doe', '2000-01-01', 'RS', TRUE, TRUE); INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (2, 'Nick "Kage" Verily', '1990-01-01', 'NKV', TRUE, FALSE); INSERT INTO EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) VALUES (3, 'Nicht Arzt', '1980-01-01', 'NA', FALSE, FALSE); diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAOTest.java index 980c429..03059ff 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAOTest.java @@ -14,8 +14,7 @@ import java.time.LocalDate; import java.util.LinkedList; import java.util.List; import org.h2.tools.RunScript; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -45,10 +44,6 @@ public class RegistrationDatabaseDAOTest { "classpath:sql/database.sql", Charset.forName("UTF8"), false); - } - - @Before - public void setUp() throws SQLException { RunScript.execute( JDBC_URL, USER, @@ -57,9 +52,20 @@ public class RegistrationDatabaseDAOTest { Charset.forName("UTF8"), false); } - - @After - public void tearDown() throws SQLException { + /* + @Before + public void setUp() throws SQLException { + RunScript.execute( + JDBC_URL, + USER, + PASSWORD, + "classpath:sql/H2RegistrationDAOTest_populate.sql", + Charset.forName("UTF8"), + false); + } + */ + @AfterClass + public static void tearDown() throws SQLException { RunScript.execute( JDBC_URL, USER, -- cgit v1.2.3-70-g09d2 From e8aff26f9855c9106defd23c78d37c0907a0d97e Mon Sep 17 00:00:00 2001 From: Dominic Rogetzer Date: Mon, 7 May 2018 21:29:38 +0200 Subject: Change header-background-color and add drop-shadows to main elements --- src/main/resources/fxml/CreateOperationController.fxml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 1ba6498..086a5d1 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -10,8 +10,8 @@ - - + + - - + @@ -75,7 +75,7 @@ - + - + -- cgit v1.2.3-70-g09d2 From d1be1e7dc30f11084f4d7054612d02a230271514 Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Thu, 3 May 2018 20:25:01 +0200 Subject: Empty skeleton for VehiclePane. --- .../ui/vehiclePane/VehiclePaneController.java | 33 ++++++++++++++++++++++ src/main/resources/fxml/vehiclePane.fxml | 14 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java create mode 100644 src/main/resources/fxml/vehiclePane.fxml (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java new file mode 100644 index 0000000..ee9e29f --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java @@ -0,0 +1,33 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclePane; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import java.io.IOException; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; + +public class VehiclePaneController { + public static VehiclePaneController createVehiclePane() throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); + Node root = fxmlLoader.load(); + VehiclePaneController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + private Node rootElement; + + public Node getRootElement() { + return rootElement; + } + + /*** + * Set the displayed data of this VehiclePane. + * @param vehicle The data to display. + * @param showQualification If true, the most recent registration of vehicle will be searched for the highest qualification. + */ + public void setData(Vehicle vehicle, boolean showQualification) + { + + } +} diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml new file mode 100644 index 0000000..f6824dc --- /dev/null +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -0,0 +1,14 @@ + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 4e9bbe5134b2efd9e3eab277a92366fe0ba38d4e Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Sat, 5 May 2018 16:28:09 +0200 Subject: VehiclePane FXML --- .../ui/vehiclePane/VehiclePaneController.java | 11 +++ src/main/resources/fxml/vehiclePane.fxml | 78 ++++++++++++++++++--- src/main/resources/images/NEF.png | Bin 0 -> 327 bytes src/main/resources/images/Not.png | Bin 0 -> 872 bytes src/main/resources/images/NotNEF.png | Bin 0 -> 1042 bytes src/main/resources/images/Qualification.png | Bin 0 -> 1029 bytes src/main/resources/images/Vehicle.png | Bin 0 -> 964 bytes 7 files changed, 78 insertions(+), 11 deletions(-) create mode 100644 src/main/resources/images/NEF.png create mode 100644 src/main/resources/images/Not.png create mode 100644 src/main/resources/images/NotNEF.png create mode 100644 src/main/resources/images/Qualification.png create mode 100644 src/main/resources/images/Vehicle.png (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java index ee9e29f..903028e 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java @@ -4,8 +4,19 @@ import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; import java.io.IOException; import javafx.fxml.FXMLLoader; import javafx.scene.Node; +import javafx.scene.image.ImageView; +import javafx.scene.text.Text; public class VehiclePaneController { + + private Text txtType; + private Text txtNumber; + private ImageView ivNEF; + private Text txtNEF; + private ImageView ivQualification; + private Text txtQualification; + private Text txtRooftype; + public static VehiclePaneController createVehiclePane() throws IOException { FXMLLoader fxmlLoader = new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); Node root = fxmlLoader.load(); diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml index f6824dc..6014c72 100644 --- a/src/main/resources/fxml/vehiclePane.fxml +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -1,14 +1,70 @@ - - - - - + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/images/NEF.png b/src/main/resources/images/NEF.png new file mode 100644 index 0000000..687f914 Binary files /dev/null and b/src/main/resources/images/NEF.png differ diff --git a/src/main/resources/images/Not.png b/src/main/resources/images/Not.png new file mode 100644 index 0000000..03063af Binary files /dev/null and b/src/main/resources/images/Not.png differ diff --git a/src/main/resources/images/NotNEF.png b/src/main/resources/images/NotNEF.png new file mode 100644 index 0000000..0c17d53 Binary files /dev/null and b/src/main/resources/images/NotNEF.png differ diff --git a/src/main/resources/images/Qualification.png b/src/main/resources/images/Qualification.png new file mode 100644 index 0000000..c58a640 Binary files /dev/null and b/src/main/resources/images/Qualification.png differ diff --git a/src/main/resources/images/Vehicle.png b/src/main/resources/images/Vehicle.png new file mode 100644 index 0000000..2fe992d Binary files /dev/null and b/src/main/resources/images/Vehicle.png differ -- cgit v1.2.3-70-g09d2 From b9aadec691affd632c8d83e30293964cc1bb05bb Mon Sep 17 00:00:00 2001 From: Andreas Weninger Date: Mon, 7 May 2018 17:53:59 +0200 Subject: Reformat. Implemented find maximum education in VehiclePaneController; relies on EducationLevel.Compare. --- .../ui/vehiclePane/VehiclePaneController.java | 69 ----------------- .../ui/vehiclepane/VehiclePaneController.java | 84 ++++++++++++++++++++ src/main/resources/fxml/vehiclePane.fxml | 90 +++++++++++----------- 3 files changed, 129 insertions(+), 114 deletions(-) delete mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java create mode 100644 src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java (limited to 'src/main/resources') diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java deleted file mode 100644 index 2b0df13..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclePane/VehiclePaneController.java +++ /dev/null @@ -1,69 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclePane; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import java.io.IOException; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.scene.Node; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.text.Text; - -public class VehiclePaneController { - @FXML private Text txtType; - @FXML private Text txtNumber; - @FXML private ImageView ivNEF; - @FXML private Text txtNEF; - @FXML private ImageView ivQualification; - @FXML private Text txtQualification; - @FXML private Text txtRooftype; - - public static VehiclePaneController createVehiclePane() throws IOException { - FXMLLoader fxmlLoader = - new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); - Node root = fxmlLoader.load(); - VehiclePaneController result = fxmlLoader.getController(); - result.rootElement = root; - - return result; - } - - private Node rootElement; - - public Node getRootElement() { - return rootElement; - } - - /** - * * Set the displayed data of this VehiclePane. - * - * @param vehicle The data to display. - * @param showQualification If true, the most recent registration of vehicle will be searched - * for the highest qualification. - */ - public void setData(Vehicle vehicle, boolean showQualification) { - txtType.setText(vehicle.type().name()); - String constrType = vehicle.constructionType().name(); - txtRooftype.setText( - constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); - txtNumber.setText("" + vehicle.id()); - if (vehicle.hasNef()) { - ivNEF.setImage(new Image("../images/NEF.png")); - txtNEF.setText("hat NEF-Halterung"); - } else { - ivNEF.setImage(new Image("../images/NotNEF.png")); - txtNEF.setText("keine NEF-Halterung"); - } - if (showQualification) - { - //TODO - } - else - { - txtQualification.setVisible(false); - txtQualification.setManaged(false); - ivQualification.setVisible(false); - ivQualification.setManaged(false); - } - } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java new file mode 100644 index 0000000..2db6f37 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/ui/vehiclepane/VehiclePaneController.java @@ -0,0 +1,84 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.ui.vehiclepane; + +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; +import java.io.IOException; +import java.time.Instant; +import java.util.Date; +import java.util.List; +import java.util.Optional; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.text.Text; + +public class VehiclePaneController { + @FXML private Text txtType; + @FXML private Text txtNumber; + @FXML private ImageView ivNEF; + @FXML private Text txtNEF; + @FXML private ImageView ivQualification; + @FXML private Text txtQualification; + @FXML private Text txtRooftype; + + public static VehiclePaneController createVehiclePane() throws IOException { + FXMLLoader fxmlLoader = + new FXMLLoader(VehiclePaneController.class.getResource("/fxml/vehiclePane.fxml")); + Node root = fxmlLoader.load(); + VehiclePaneController result = fxmlLoader.getController(); + result.rootElement = root; + + return result; + } + + private Node rootElement; + + public Node getRootElement() { + return rootElement; + } + + /** + * * Set the displayed data of this VehiclePane. + * + * @param vehicle The data to display. + * @param showQualification If true, the most recent registration of vehicle will be searched + * for the highest qualification. + */ + public void setData(Vehicle vehicle, boolean showQualification) { + txtType.setText(vehicle.type().name()); + String constrType = vehicle.constructionType().name(); + txtRooftype.setText( + constrType.substring(0, 1).toUpperCase() + constrType.substring(1).toLowerCase()); + txtNumber.setText("" + vehicle.id()); + if (vehicle.hasNef()) { + ivNEF.setImage(new Image("../images/NEF.png")); + txtNEF.setText("hat NEF-Halterung"); + } else { + ivNEF.setImage(new Image("../images/NotNEF.png")); + txtNEF.setText("keine NEF-Halterung"); + } + if (showQualification) { + + Instant now = (new Date()).toInstant(); + List regs = vehicle.registrations(); + + assert regs != null; + Optional edu = + regs.stream() + .filter(reg -> reg.start().isBefore(now) && reg.end().isAfter(now)) + .map(reg -> reg.employee().educationLevel()) + .max(EducationLevel::compareTo); + + assert edu.isPresent(); + txtQualification.setText(edu.get().name()); + } else { + txtQualification.setVisible(false); + txtQualification.setManaged(false); + ivQualification.setVisible(false); + ivQualification.setManaged(false); + } + } +} diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml index 6014c72..8b1d194 100644 --- a/src/main/resources/fxml/vehiclePane.fxml +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -10,61 +10,61 @@ - + - - - - + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - + + - + - - - - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2