diff options
Diffstat (limited to 'src')
99 files changed, 4326 insertions, 2377 deletions
| diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java index d8365a7..a6c0566 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/MainApplication.java @@ -1,6 +1,7 @@  package at.ac.tuwien.sepm.assignment.groupphase.application; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateOperationController; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.CreateOperationController; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader;  import javafx.application.Application;  import javafx.application.Platform; @@ -25,7 +26,13 @@ public class MainApplication extends Application {      public void start(Stage primaryStage) throws Exception {          primaryStage.setTitle("Einsatz erstellen");          primaryStage.centerOnScreen(); -        primaryStage.setOnCloseRequest(event -> Platform.exit()); +        primaryStage.setOnCloseRequest( +                event -> { +                    final var jdbcConnectionManager = +                            configApplicationContext.getBean(JDBCConnectionManager.class); +                    jdbcConnectionManager.closeConnection(); +                    Platform.exit(); +                });          configApplicationContext = new AnnotationConfigApplicationContext(MainApplication.class);          final var fxmlLoader = configApplicationContext.getBean(SpringFXMLLoader.class); diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java new file mode 100644 index 0000000..4ff1f78 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/application/PopulateDB.java @@ -0,0 +1,20 @@ +package at.ac.tuwien.sepm.assignment.groupphase.application; + +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.io.InputStreamReader; +import java.sql.SQLException; +import org.h2.tools.RunScript; +import org.springframework.core.io.ClassPathResource; + +public class PopulateDB { +    public static void main(String[] args) throws SQLException { +        JDBCConnectionManager jdbcConnectionManager = new JDBCConnectionManager(); + +        RunScript.execute( +                jdbcConnectionManager.getConnection(), +                new InputStreamReader( +                        ClassPathResource.class.getResourceAsStream("/sql/testdata.sql"))); + +        jdbcConnectionManager.closeConnection(); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java deleted file mode 100644 index 80d9fc4..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ArchiveOperationController.java +++ /dev/null @@ -1,127 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -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; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.time.LocalDateTime; -import java.time.ZoneOffset; -import java.util.Collection; -import java.util.EnumSet; -import java.util.LinkedList; -import java.util.Objects; -import java.util.stream.Collectors; -import javafx.fxml.FXML; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; -import javafx.scene.control.Hyperlink; -import javafx.scene.control.Label; -import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane; -import org.springframework.stereotype.Controller; - -@Controller -public class ArchiveOperationController { -    @FXML private AnchorPane apDetails; -    @FXML private Label lblCodeHeader; -    @FXML private Hyperlink hypBack; -    @FXML private Label lblOpCode; -    @FXML private Label lblVehicles; -    @FXML private Label lblDate; -    @FXML private Label lblAddress; -    @FXML private FlowPane fpVehicles; -    private final OperationService operationService; -    @FXML private FlowPane archiveOperationFlowPane; -    private LinkedList<Operation> list = new LinkedList<>(); - -    public ArchiveOperationController(OperationService operationService) { -        this.operationService = operationService; -    } - -    @FXML -    private void initialize() { -        try { -            list.addAll(operationService.list(EnumSet.of(Status.CANCELLED, Status.COMPLETED))); -        } catch (ServiceException e) { -            Alert alert = new Alert(AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText("Die Einsätze konnten nicht geladen werden!"); -            alert.showAndWait(); -        } -        for (Operation operation : list) { -            Button b = new Button(); -            b.setPrefHeight(200); -            b.setPrefWidth(750 / 2); -            b.setText(operation.opCode()); -            b.setOnAction(event -> buttonClicked(b)); -            archiveOperationFlowPane.getChildren().add(b); -        } -    } - -    private Operation detailOperation; - -    private void buttonClicked(Button button) { -        int size = archiveOperationFlowPane.getChildren().size(); -        int index = 0; -        for (int i = 0; i < size; i++) { -            if (archiveOperationFlowPane.getChildren().get(i) == button) { -                index = i; -                break; -            } -        } -        detailOperation = list.get(index); -        setOperation(); -        setDetailsVisible(true); -    } - -    private void setOperation() { -        lblCodeHeader.setText(detailOperation.opCode()); -        String date = "am "; -        if (detailOperation.created() != null) { -            LocalDateTime myDateTime = -                    LocalDateTime.ofInstant( -                            Objects.requireNonNull(detailOperation.created()), ZoneOffset.UTC); -            date += -                    myDateTime.getDayOfMonth() -                            + "." -                            + myDateTime.getMonth().getValue() -                            + "." -                            + myDateTime.getYear(); -            lblDate.setText(date); -        } else { -            lblDate.setText("---"); -        } - -        lblOpCode.setText(detailOperation.opCode()); -        Collection<String> elements = -                detailOperation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); -        String result = String.join(", ", elements); - -        lblVehicles.setText(result); -        lblAddress.setText(detailOperation.destination()); - -        for (Vehicle vehicle : detailOperation.vehicles()) { -            Button b = new Button(); -            b.setPrefHeight(200); -            b.setPrefWidth(600 / 2); -            b.setText(vehicle.name()); -            fpVehicles.getChildren().add(b); -        } -    } - -    public void setListVisible(boolean b) { -        archiveOperationFlowPane.setVisible(b); -    } - -    private void setDetailsVisible(boolean b) { -        apDetails.setVisible(b); -    } - -    public void backClicked() { -        fpVehicles.getChildren().clear(); -        setDetailsVisible(false); -    } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java deleted file mode 100644 index ce795da..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateCarController.java +++ /dev/null @@ -1,206 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -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.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.lang.invoke.MethodHandles; -import java.util.EnumSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import javafx.collections.FXCollections; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.geometry.HPos; -import javafx.geometry.Orientation; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType; -import javafx.scene.control.Button; -import javafx.scene.control.ButtonType; -import javafx.scene.control.CheckBox; -import javafx.scene.control.ChoiceBox; -import javafx.scene.layout.FlowPane; -import javafx.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class CreateCarController { - -    @FXML private ChoiceBox<String> cmb_Ctyp; -    @FXML private ChoiceBox<String> cmb_typ; -    @FXML private Button btn_cancel; -    @FXML private Button btn_create; -    @FXML private CheckBox cbx_NEF; -    @FXML private FlowPane fp_vehicleList; - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); -    private final VehicleService vehicleService; -    private boolean update = false; -    private long vid = -1; - -    public CreateCarController(VehicleService vehicleService) { -        this.vehicleService = vehicleService; -    } - -    @FXML -    private void initialize() { -        cmb_Ctyp.setItems( -                FXCollections.observableArrayList( -                        Stream.of( -                                        ConstructionType.NORMAL, -                                        ConstructionType.MITTELHOCHDACH, -                                        ConstructionType.HOCHDACH) -                                .map(Enum::toString) -                                .collect(Collectors.toList()))); -        cmb_Ctyp.setValue(ConstructionType.NORMAL.toString()); -        cmb_typ.setItems( -                FXCollections.observableArrayList( -                        Stream.of( -                                        VehicleType.BKTW, -                                        VehicleType.KTW_B, -                                        VehicleType.KTW, -                                        VehicleType.RTW, -                                        VehicleType.NEF, -                                        VehicleType.NAH) -                                .map(Enum::toString) -                                .collect(Collectors.toList()))); -        cmb_typ.setValue(VehicleType.BKTW.toString()); -        vehicleListFP(); -    } - -    @FXML -    private void onCancelClicked() { -        ((Stage) btn_cancel.getScene().getWindow()).close(); -    } - -    @FXML -    private void createCar(ActionEvent actionEvent) { - -        if (!update) { -            Vehicle vehicle = -                    Vehicle.builder() -                            .constructionType(parseConstructionType()) -                            .type(parseType()) -                            .name("") -                            .status(Status.ABGEMELDET) -                            .hasNef(cbx_NEF.isSelected()) -                            .build(); -            try { -                vehicleService.add(vehicle); -                setToStart(); -            } catch (InvalidVehicleException e) { -                LOG.error("Invalid Vehicle: {}", e); -                createComplete(AlertType.ERROR, "Ungültige Eingabe", e.getMessage()); -                setToStart(); -                return; -            } catch (ServiceException e) { -                LOG.error("Exception: {}", e); -                createComplete(AlertType.ERROR, "Fehler", e.getMessage()); -                setToStart(); -                return; -            } -            createComplete( -                    AlertType.CONFIRMATION, -                    "Speichern Erfolgreich", -                    "Auto wurde erfolgreich angelegt"); -        } else { -            try { -                Vehicle vehicle = -                        Vehicle.builder() -                                .id(vid) -                                .constructionType(parseConstructionType()) -                                .type(parseType()) -                                .name("") -                                .status(Status.ABGEMELDET) -                                .hasNef(cbx_NEF.isSelected()) -                                .build(); -                vehicleService.update(vehicle); -                setToStart(); -            } catch (InvalidVehicleException e) { -                LOG.error("Invalid Vehicle: {}", e); -                createComplete(AlertType.ERROR, "Ungültige Eingabe", e.getMessage()); -                setToStart(); -                return; -            } catch (ServiceException e) { -                LOG.error("Exception: {}", e); -                createComplete(AlertType.ERROR, "Fehler", e.getMessage()); -                setToStart(); -                return; -            } -            createComplete( -                    AlertType.CONFIRMATION, -                    "Bearbiten Erfolgreich", -                    "Auto wurde erfolgreich bearbeitet"); -        } -        vehicleListFP(); -    } - -    private ConstructionType parseConstructionType() { -        if (cmb_Ctyp.getSelectionModel().getSelectedItem() == null) { -            return ConstructionType.NORMAL; -        } -        return ConstructionType.valueOf(cmb_Ctyp.getSelectionModel().getSelectedItem().toString()); -    } - -    private VehicleType parseType() { -        if (cmb_typ.getSelectionModel().getSelectedItem() == null) { -            return VehicleType.BKTW; -        } -        return VehicleType.valueOf(cmb_typ.getSelectionModel().getSelectedItem().toString()); -    } - -    private void createComplete(AlertType alertType, String headerText, String contentText) { -        Alert alert = new Alert(alertType, contentText, ButtonType.OK); -        alert.setHeaderText(headerText); -        alert.showAndWait(); -    } - -    private void vehicleListFP() { -        Set<Vehicle> vehicleList = null; -        fp_vehicleList.getChildren().clear(); -        try { -            vehicleList = vehicleService.list(EnumSet.range(Status.ABGEMELDET, Status.FREI_FUNK)); -        } catch (ServiceException e) { -            e.printStackTrace(); -        } - -        fp_vehicleList.setOrientation(Orientation.HORIZONTAL); -        fp_vehicleList.setColumnHalignment(HPos.LEFT); // align labels on left -        fp_vehicleList.setPrefWrapLength(200); // preferred height = 200 - -        for (Vehicle v : vehicleList) { -            Button b = new Button(v.name()); -            b.setOnAction(event -> updateVehicle(v)); -            fp_vehicleList.getChildren().add(b); -        } -        fp_vehicleList.setVisible(true); -    } - -    private void setToStart() { -        btn_create.setText("Erstellen"); -        cbx_NEF.setSelected(false); -        cmb_typ.setValue(VehicleType.BKTW.name()); -        cmb_Ctyp.setValue(ConstructionType.NORMAL.name()); -        update = false; -    } - -    private void updateVehicle(Vehicle vehicle) { -        cmb_Ctyp.setValue(vehicle.constructionType().name()); -        cmb_typ.setValue(vehicle.type().name()); -        cbx_NEF.setSelected(vehicle.hasNef()); -        btn_create.setText("Speichern"); -        vid = vehicle.id(); -        update = true; -    } - -    @FXML -    public void cancelAction(ActionEvent actionEvent) { -        setToStart(); -    } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java deleted file mode 100644 index dc7e969..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/OperationDetailsController.java +++ /dev/null @@ -1,162 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -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; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService; -import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; -import java.util.Collection; -import java.util.EnumSet; -import java.util.stream.Collectors; -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 javafx.scene.control.ListView; -import javafx.scene.layout.AnchorPane; -import org.springframework.stereotype.Controller; - -@Controller -public class OperationDetailsController { - -    public Operation operation; -    private final OperationService operationService; -    private final VehicleService vehicleService; -    private final CreateOperationController createOperationController; -    @FXML private ListView<Vehicle> lvVehicles; -    @FXML private ListView<Operation> lvActiveOperations; -    @FXML private Label lblChosenVehicles; -    @FXML private Button btnCloseOperation; -    @FXML private Button btnCancelOperation; -    @FXML private Label lblCode, lblAdditionalInfo, lblAddress; -    @FXML private AnchorPane operationDetailsAP; - -    public OperationDetailsController( -            OperationService operationService, -            VehicleService vehicleService, -            CreateOperationController createOperationController) { -        this.operationService = operationService; -        this.vehicleService = vehicleService; -        this.createOperationController = createOperationController; -    } - -    @FXML -    private void initialize() { -        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()); -                                } -                            } -                        }); -        lvActiveOperations.setCellFactory( -                param -> -                        new ListCell<>() { -                            @Override -                            protected void updateItem(Operation item, boolean empty) { -                                super.updateItem(item, empty); - -                                if (empty || item == null || item.opCode() == null) { -                                    setText(null); -                                } else { -                                    setText(item.opCode()); -                                } -                            } -                        }); -        lvActiveOperations.setOnMouseClicked( -                event -> { -                    if (event.getClickCount() == 2) { -                        if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { -                            return; -                        } -                        initOperation(lvActiveOperations.getSelectionModel().getSelectedItem()); -                    } -                }); -    } - -    void initOperation(Operation operation) { -        fillActiveList(); -        this.operation = operation; -        lblCode.setText(operation.opCode()); -        Collection<String> vehicleNames = -                operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); -        String result = String.join(", ", vehicleNames); -        lblChosenVehicles.setText(result.toString()); -        lblAdditionalInfo.setText(operation.additionalInfo()); -        lblAddress.setText(operation.destination()); -        lvVehicles.setItems(FXCollections.observableArrayList(operation.vehicles())); -        operationDetailsAP.setVisible(true); -    } - -    private void fillActiveList() { -        try { -            lvActiveOperations.setItems( -                    FXCollections.observableArrayList( -                            operationService.list(EnumSet.of(Status.ACTIVE)))); -        } catch (ServiceException e) { -            Alert alert = new Alert(AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); -        } -    } - -    @FXML -    public void closeOperationClicked() { -        try { -            operationService.complete(operation.id(), Status.COMPLETED); -        } catch (InvalidOperationException | ServiceException e) { -            Alert alert = new Alert(AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); -            return; -        } -        Alert alert = new Alert(AlertType.CONFIRMATION); -        alert.setTitle("Erfolg"); -        alert.setHeaderText("Erfolgreich aktualisiert"); -        alert.setContentText("Der Einsatz wurde erfolgreich aktualisiert."); -        alert.showAndWait(); -        closeWindow(); -        createOperationController.updateList(); -    } - -    public void cancelOperationClicked() { -        try { -            operationService.complete(operation.id(), Status.CANCELLED); -        } catch (InvalidOperationException | ServiceException e) { -            Alert alert = new Alert(AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); -            return; -        } -        Alert alert = new Alert(AlertType.CONFIRMATION); -        alert.setTitle("Erfolg"); -        alert.setHeaderText("Erfolgreich aktualisiert"); -        alert.setContentText("Der Einsatz wurde erfolgreich aktualisiert."); -        alert.showAndWait(); -        closeWindow(); -        createOperationController.updateList(); -    } - -    public void closeWindow() { -        operationDetailsAP.setVisible(false); -        this.createOperationController.setVisible(true); -    } -} 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 deleted file mode 100644 index 4653663..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java +++ /dev/null @@ -1,213 +0,0 @@ -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.OffsetDateTime; -import java.util.EnumSet; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import javafx.beans.property.SimpleStringProperty; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -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.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; - -@Controller -public class RegistrationWindowController { - -    private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); - -    private final EmployeeService employeeService; - -    private final VehicleService vehicleService; - -    private final RegistrationService registrationService; - -    public RegistrationWindowController( -            EmployeeService employeeService, -            VehicleService vehicleService, -            RegistrationService registrationService) { -        this.employeeService = employeeService; -        this.vehicleService = vehicleService; -        this.registrationService = registrationService; -    } - -    @FXML private ChoiceBox<Integer> cbStart; -    @FXML private ChoiceBox<Integer> cbEnd; -    @FXML private Label lVehicles; -    @FXML private Label lEmployees; -    @FXML private TextField tfVehicleSearch; -    @FXML private TextField tfEmployeeSearch; -    @FXML private TableView<Vehicle> tvVehicles; -    @FXML private TableView<Employee> tvEmployees; -    @FXML private TableColumn<Vehicle, String> tcVehicles; -    @FXML private TableColumn<Employee, String> tcEmployees; - -    private Vehicle chosenVehicle; -    private List<Employee> chosenEmployees = new LinkedList<>(); - -    @FXML -    private void initialize() { -        // will have to be replaced for FlowPane -        try { -            Set<Vehicle> 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 { -            Set<Employee> 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( -                mouseEvent -> { -                    if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { -                        chosenVehicle = tvVehicles.getSelectionModel().getSelectedItem(); -                        if (chosenVehicle == null) { -                            return; -                        } -                        lVehicles.setText(chosenVehicle.name()); -                    } -                }); -        tvEmployees.setOnMousePressed( -                mouseEvent -> { -                    if (mouseEvent.isPrimaryButtonDown() && mouseEvent.getClickCount() == 2) { -                        Employee selection = tvEmployees.getSelectionModel().getSelectedItem(); -                        if (selection == null) { -                            return; -                        } else if (chosenEmployees.contains(selection)) { -                            chosenEmployees.remove(selection); -                        } else { -                            chosenEmployees.add(selection); -                        } - -                        StringBuilder text = new StringBuilder(); -                        for (Employee employee : chosenEmployees) { -                            text.append(employee.name()).append("\n"); -                        } -                        lEmployees.setText(text.toString()); -                    } -                }); -        ObservableList<Integer> 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); -        cbStart.setValue(0); -        cbEnd.setItems(hours); -        cbEnd.setValue(12); -    } - -    public void cancel() { -        LOG.debug("Cancel Button clicked"); -        chosenEmployees.clear(); -        ((Stage) lVehicles.getScene().getWindow()).close(); -    } - -    public void create() { -        LOG.debug("Create Button clicked"); - -        Set<Registration> registrations = new HashSet<>(); -        try { -            if (chosenVehicle == null) { -                throw new InvalidVehicleException("no Vehicle"); -            } -            for (Employee employee : chosenEmployees) { -                registrations.add( -                        Registration.builder() -                                .id(chosenVehicle.id()) -                                .employee(employee) -                                .start( -                                        LocalDateTime.of( -                                                        LocalDate.now(), -                                                        LocalTime.of(cbStart.getValue(), 0)) -                                                .toInstant(OffsetDateTime.now().getOffset())) -                                .end( -                                        LocalDateTime.of( -                                                        LocalDate.now(), -                                                        LocalTime.of(cbEnd.getValue(), 0)) -                                                .toInstant(OffsetDateTime.now().getOffset())) -                                .build()); -            } - -            registrationService.add(chosenVehicle.id(), registrations); -            chosenEmployees.clear(); -            ((Stage) lVehicles.getScene().getWindow()).close(); - -        } 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(); -            chosenEmployees.clear(); -        } 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(); -            chosenEmployees.clear(); -        } 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(); -            chosenEmployees.clear(); -        } -    } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java deleted file mode 100644 index 43a5c9d..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDatabaseDAO.java +++ /dev/null @@ -1,201 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -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.lang.invoke.MethodHandles; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.HashSet; -import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Repository; - -@Repository -public class EmployeeDatabaseDAO implements EmployeeDAO { - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); -    private static final String INSERT_EMPLOYEE_VERSION = -            "INSERT INTO EmployeeVersion(name, birthday, educationLevel, isDriver, isPilot) " -                    + "VALUES(?, ?, ?, ?, ?)"; -    private static final String INSERT_EMPLOYEE = "INSERT INTO Employee(version) VALUES(?)"; -    private static final String LIST_EMPLOYEE = -            "SELECT emp.id, v.name, v.birthday, v.educationLevel, v.isDriver, v.isPilot " -                    + "FROM employee emp " -                    + "JOIN EmployeeVersion v ON v.id = emp.version"; -    private static final String UPDATE_EMPLOYEE = "UPDATE Employee SET version = ? WHERE id = ?"; - -    private final PreparedStatement insertEmployeeVersion, -            insertEmployee, -            listEmployee, -            updateEmployee; - -    private final Connection connection; - -    public EmployeeDatabaseDAO(JDBCConnectionManager connectionManager) -            throws PersistenceException { - -        try { - -            connection = connectionManager.getConnection(); -            insertEmployeeVersion = -                    connection.prepareStatement( -                            INSERT_EMPLOYEE_VERSION, Statement.RETURN_GENERATED_KEYS); -            insertEmployee = -                    connection.prepareStatement(INSERT_EMPLOYEE, Statement.RETURN_GENERATED_KEYS); - -            listEmployee = connection.prepareStatement(LIST_EMPLOYEE); - -            updateEmployee = connection.prepareStatement(UPDATE_EMPLOYEE); - -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } -    } - -    @Override -    public long add(Employee employee) throws PersistenceException { - -        // Assumption: the given employee is already validated (from service) -        Savepoint savepoint = null; -        try { -            savepoint = connection.setSavepoint(); -            connection.setAutoCommit(false); -            insertEmployeeVersion.setString(1, employee.name()); -            insertEmployeeVersion.setTimestamp( -                    2, Timestamp.valueOf(employee.birthday().atStartOfDay())); -            insertEmployeeVersion.setString(3, employee.educationLevel().toString()); -            insertEmployeeVersion.setBoolean(4, employee.isDriver()); -            insertEmployeeVersion.setBoolean(5, employee.isPilot()); -            insertEmployeeVersion.executeUpdate(); -            try (ResultSet resultSetEmployeeVersion = insertEmployeeVersion.getGeneratedKeys()) { -                if (resultSetEmployeeVersion.next()) { -                    long versionId = resultSetEmployeeVersion.getLong(1); - -                    insertEmployee.setLong(1, versionId); -                    insertEmployee.executeUpdate(); - -                    try (ResultSet resultSetEmployee = insertEmployee.getGeneratedKeys()) { -                        if (resultSetEmployee.next()) { -                            connection.commit(); -                            return resultSetEmployee.getLong(1); -                        } -                    } -                } -            } - -            throw new PersistenceException("Employee was not updated"); - -        } catch (SQLException e) { -            try { -                if (savepoint != null) { -                    connection.rollback(savepoint); -                } -            } catch (SQLException e1) { -                throw new PersistenceException(e); -            } -            throw new PersistenceException(e); -        } finally { -            try { -                connection.setAutoCommit(true); -            } catch (SQLException e) { -                throw new PersistenceException(e); -            } -        } -    } - -    @Override -    public void update(Employee employee) throws ElementNotFoundException, PersistenceException { - -        Savepoint savepoint = null; -        try { -            savepoint = connection.setSavepoint(); -            connection.setAutoCommit(false); - -            insertEmployeeVersion.setString(1, employee.name()); -            insertEmployeeVersion.setTimestamp( -                    2, Timestamp.valueOf(employee.birthday().atStartOfDay())); -            insertEmployeeVersion.setString(3, employee.educationLevel().toString()); -            insertEmployeeVersion.setBoolean(4, employee.isDriver()); -            insertEmployeeVersion.setBoolean(5, employee.isPilot()); -            insertEmployeeVersion.executeUpdate(); -            try (ResultSet resultSetEmployeeVersion = insertEmployeeVersion.getGeneratedKeys()) { - -                if (resultSetEmployeeVersion.next()) { -                    long versionId = resultSetEmployeeVersion.getLong(1); - -                    updateEmployee.setLong(1, versionId); -                    updateEmployee.setLong(2, employee.id()); -                    int affectedRows = updateEmployee.executeUpdate(); - -                    if (affectedRows == 1) { -                        connection.commit(); -                    } else { -                        throw new ElementNotFoundException( -                                "element not found with id: " + employee.id()); -                    } -                } -            } - -        } catch (SQLException e) { -            try { -                if (savepoint != null) { -                    connection.rollback(savepoint); -                } -            } catch (SQLException e1) { -                throw new PersistenceException(e); -            } -            throw new PersistenceException(e); -        } finally { -            try { -                connection.setAutoCommit(true); -            } catch (SQLException e) { -                throw new PersistenceException(e); -            } -        } -    } - -    @Override -    public Set<Employee> list() throws PersistenceException { - -        try { -            Set<Employee> employees; -            try (ResultSet rs = listEmployee.executeQuery()) { - -                employees = new HashSet<>(); -                while (rs.next()) { - -                    Employee employee = -                            Employee.builder() -                                    .id(rs.getLong(1)) -                                    .name(rs.getString(2)) -                                    .birthday(rs.getTimestamp(3).toLocalDateTime().toLocalDate()) -                                    .educationLevel(EducationLevel.valueOf(rs.getString(4))) -                                    .isDriver(rs.getBoolean(5)) -                                    .isPilot(rs.getBoolean(6)) -                                    .build(); - -                    employees.add(employee); -                } -            } - -            return employees; - -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } -    } - -    @Override -    public void remove(long id) throws ElementNotFoundException, PersistenceException { -        throw new UnsupportedOperationException(); -    } -} 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 deleted file mode 100644 index 13f2c0f..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDatabaseDAO.java +++ /dev/null @@ -1,147 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; - -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.exception.ElementNotFoundException; -import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; - -@Repository -public class RegistrationDatabaseDAO implements RegistrationDAO { - -    private static final Logger LOG = LoggerFactory.getLogger(RegistrationDatabaseDAO.class); - -    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 = ?;"; -    private static final String FETCH_REGISTRATIONS = -            "SELECT * FROM Registration WHERE vehicleId = ?"; - -    private PreparedStatement addRegistration; -    private PreparedStatement updateVehicle; -    private PreparedStatement fetchRegistrations; - -    private Connection connection; -    private EmployeeDAO employeePersistence; - -    @Autowired -    public RegistrationDatabaseDAO( -            JDBCConnectionManager connectionManager, EmployeeDAO employeePersistence) -            throws PersistenceException { -        this.employeePersistence = employeePersistence; -        try { -            connection = connectionManager.getConnection(); -            addRegistration = -                    connection.prepareStatement(ADD_REGISTRATION, Statement.RETURN_GENERATED_KEYS); -            updateVehicle = connection.prepareStatement(UPDATE_VEHICLE); -            fetchRegistrations = connection.prepareStatement(FETCH_REGISTRATIONS); -        } catch (SQLException e) { -            LOG.error("Could not get connection or preparation of statement failed"); -            throw new PersistenceException(e); -        } -    } - -    @Override -    public Set<Long> add(long vehicleId, Set<Registration> registrations) -            throws PersistenceException { -        Set<Long> returnValues = new HashSet<>(); -        try { -            connection.setAutoCommit(false); -            for (Registration registration : registrations) { -                addRegistration.setLong(1, vehicleId); -                addRegistration.setLong(2, registration.employee().id()); -                addRegistration.setTimestamp(3, Timestamp.from(registration.start())); -                addRegistration.setTimestamp(4, Timestamp.from(registration.end())); -                addRegistration.setBoolean( -                        5, true); // ASSUMPTION: Registration gets created as active -                addRegistration.executeUpdate(); -                try (ResultSet rs = addRegistration.getGeneratedKeys()) { -                    if (rs.next()) { -                        returnValues.add(rs.getLong(1)); -                    } else { -                        LOG.error("No ResultSet was created while adding registration"); -                        throw new PersistenceException( -                                "Anmeldung konnte nicht gespeichert werden."); -                    } -                } -            } - -            updateVehicle.setLong(1, vehicleId); -            updateVehicle.executeUpdate(); - -            connection.commit(); -            return returnValues; -        } catch (SQLException e) { -            LOG.error( -                    "An SQLException occurred while trying to save registrations to database. " -                            + "Attempting a rollback. Error message: {}", -                    e.getMessage()); -            try { -                connection.rollback(); -            } catch (SQLException e1) { -                LOG.error("Rollback failed :("); -            } -            throw new PersistenceException(e); -        } finally { -            try { -                connection.setAutoCommit(true); -            } catch (SQLException e) { -                LOG.error( -                        "Setting back AutoCommit to false failed! Error message: {}", -                        e.getMessage()); -                // SonarLint insists on me not throwing anything here... -            } -        } -    } - -    @Override -    public void remove(long id) throws ElementNotFoundException, PersistenceException { -        throw new UnsupportedOperationException(); -    } - -    public List<Registration> list(long vehicleId) throws PersistenceException { -        List<Registration> registrationList = new ArrayList<>(); -        try { -            fetchRegistrations.setLong(1, vehicleId); -            ResultSet rs = fetchRegistrations.executeQuery(); -            while (rs.next()) { -                long employeeId = rs.getLong("employeeId"); -                // TODO: replace the following with employeePersistence.get once implemented -                Employee emp = -                        employeePersistence -                                .list() -                                .stream() -                                .filter(employee -> employee.id() == employeeId) -                                .findAny() -                                .orElse(null); -                Registration registration = -                        Registration.builder() -                                .id(rs.getLong("id")) -                                .start(rs.getTimestamp("start").toInstant()) -                                .end(rs.getTimestamp("end").toInstant()) -                                .employee(emp) -                                .build(); -                registrationList.add(registration); -            } -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } - -        return registrationList; -    } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java deleted file mode 100644 index 6d50588..0000000 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDatabaseDAO.java +++ /dev/null @@ -1,220 +0,0 @@ -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; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.HashSet; -import java.util.Set; -import org.springframework.stereotype.Repository; - -@Repository -public class VehicleDatabaseDAO implements VehicleDAO { - -    private final JDBCConnectionManager jdbcConnectionManager; -    private RegistrationDatabaseDAO registrationDatabaseDao; - -    public VehicleDatabaseDAO( -            JDBCConnectionManager j, RegistrationDatabaseDAO registrationDatabaseDao) { -        jdbcConnectionManager = j; -        this.registrationDatabaseDao = registrationDatabaseDao; -    } - -    public long add(Vehicle vehicle) throws PersistenceException { -        String query1 = -                "INSERT INTO VehicleVersion (name,hasNef,constructionType,type) VALUES (?,?,?,?)"; -        String query2 = "INSERT INTO Vehicle (version,status) VALUES (?,?)"; - -        String status = "ABGEMELDET"; -        String name = ""; -        int id = -1; -        int version = -1; -        try { -            Connection connection = jdbcConnectionManager.getConnection(); -            connection.setAutoCommit(false); -            try (PreparedStatement p1 = -                    connection.prepareStatement(query1, PreparedStatement.RETURN_GENERATED_KEYS)) { - -                p1.setString(1, name); -                p1.setBoolean(2, vehicle.hasNef()); -                p1.setString(3, vehicle.constructionType().name()); - -                p1.setString(4, vehicle.type().name()); - -                p1.executeUpdate(); -                try (ResultSet keyResultSet = p1.getGeneratedKeys()) { - -                    if (keyResultSet.next()) { -                        version = keyResultSet.getInt(1); -                    } -                } -            } -            try (PreparedStatement p2 = -                    connection.prepareStatement(query2, Statement.RETURN_GENERATED_KEYS)) { - -                p2.setInt(1, version); -                p2.setString(2, status); -                p2.executeUpdate(); -                try (ResultSet keyResultSet = p2.getGeneratedKeys()) { - -                    if (keyResultSet.next()) { -                        id = keyResultSet.getInt(1); -                    } -                } - -                name = vehicle.type().name() + "-" + id; -            } -            query1 = "UPDATE VehicleVersion SET name=? WHERE id=?"; -            try (PreparedStatement p3 = connection.prepareStatement(query1)) { -                p3.setString(1, name); -                p3.setInt(2, version); -                p3.executeUpdate(); -            } - -            connection.commit(); -            connection.setAutoCommit(true); -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } -        return id; -    } - -    @Override -    public void update(Vehicle vehicle) throws ElementNotFoundException, PersistenceException { -        String query = "SELECT * FROM vehicle WHERE id=?"; - -        long vehicleID = -1; -        long vehicleVersion = -1; -        try { -            Connection connection = jdbcConnectionManager.getConnection(); -            connection.setAutoCommit(false); -            try (PreparedStatement p = -                    connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)) { - -                p.setLong(1, vehicle.id()); -                p.executeQuery(); -                try (ResultSet rs = p.getResultSet()) { -                    while (rs.next()) { -                        vehicleID = rs.getLong("id"); -                    } -                } -            } -            if (vehicleID == -1) { -                throw new ElementNotFoundException("Vehicle don´t found"); -            } - -            query = -                    "INSERT INTO VehicleVersion (name,hasNef,constructionType,type) VALUES (?,?,?,?)"; -            String name = ""; -            try (PreparedStatement p = -                    connection.prepareStatement(query, Statement.RETURN_GENERATED_KEYS)) { -                p.setString(1, name); -                p.setBoolean(2, vehicle.hasNef()); -                p.setString(3, vehicle.constructionType().name()); - -                p.setString(4, vehicle.type().name()); - -                p.executeUpdate(); - -                try (ResultSet keyResultSet = p.getGeneratedKeys()) { - -                    if (keyResultSet.next()) { -                        vehicleVersion = keyResultSet.getInt(1); -                    } -                } -                if (vehicleVersion == -1) { -                    throw new ElementNotFoundException("Vehicle don´t found"); -                } -            } -            name = vehicle.type().name() + "-" + vehicleID; - -            query = "UPDATE VehicleVersion SET name=? WHERE id=?"; -            try (PreparedStatement p = connection.prepareStatement(query)) { - -                p.setString(1, name); -                p.setLong(2, vehicleVersion); -                p.executeUpdate(); -            } -            query = "UPDATE Vehicle SET version=? WHERE id=?"; -            try (PreparedStatement p = connection.prepareStatement(query)) { - -                p.setLong(1, vehicleVersion); -                p.setLong(2, vehicleID); -                p.executeUpdate(); -            } -            connection.commit(); -            connection.setAutoCommit(true); -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } -    } - -    @Override -    public Set<Vehicle> list() throws PersistenceException { -        Set<Vehicle> result = new HashSet<>(); - -        String sql = -                "Select * from VehicleVersion, Vehicle where VehicleVersion.id=Vehicle.version"; - -        try (PreparedStatement pstmt = -                jdbcConnectionManager.getConnection().prepareStatement(sql)) { -            pstmt.executeQuery(); -            try (ResultSet rs = pstmt.getResultSet()) { -                while (rs.next()) { -                    result.add(vehicleFromRS(rs)); -                } -            } -        } catch (SQLException e) { -            throw new PersistenceException("Die Werte konnten nicht geladen werden.", e); -        } -        return result; -    } - -    @Override -    public Vehicle get(long id) throws ElementNotFoundException, PersistenceException { -        String sql = -                "SELECT a.id, b.name, b.constructionType, b.type, a.status, b.hasNef" -                        + " FROM Vehicle a" -                        + " INNER JOIN VehicleVersion b" -                        + " ON version = b.id" -                        + " WHERE a.id = ?"; - -        try { -            Connection con = jdbcConnectionManager.getConnection(); -            try (PreparedStatement pstmt = con.prepareStatement(sql)) { -                pstmt.setLong(1, id); - -                try (ResultSet rs = pstmt.executeQuery()) { -                    if (!rs.first()) throw new ElementNotFoundException("No such vehicle exists"); - -                    return vehicleFromRS(rs); -                } -            } -        } catch (SQLException e) { -            throw new PersistenceException(e); -        } -    } - -    @Override -    public void remove(long id) throws ElementNotFoundException, PersistenceException {} - -    private Vehicle vehicleFromRS(ResultSet rs) throws SQLException, PersistenceException { -        return Vehicle.builder() -                .id(rs.getLong("Vehicle.id")) -                .name(rs.getString("name")) -                .constructionType(ConstructionType.values()[rs.getInt("constructionType")]) -                .type(VehicleType.valueOf(rs.getString("type"))) -                .status(Status.values()[rs.getInt("status")]) -                .hasNef(rs.getBoolean("hasNef")) -                .registrations(registrationDatabaseDao.list(rs.getLong("id"))) -                .build(); -    } -} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java new file mode 100644 index 0000000..212dba6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ArchiveOperationController.java @@ -0,0 +1,281 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.io.IOException; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class ArchiveOperationController { + +    private static final Logger LOG = LoggerFactory.getLogger(ArchiveOperationController.class); +    @FXML private TextField txtSearch; + +    @FXML private ImageView imvVehicleDetail; +    @FXML private Label lblStatus; +    @FXML private AnchorPane apMainDetails; +    @FXML private Label lblOperations; +    @FXML private Label lblCompleted; +    @FXML private Label lblCancelled; +    @FXML private AnchorPane backApMain; +    @FXML private AnchorPane backApDetails; +    @FXML private AnchorPane archiveOperationAP; +    @FXML private AnchorPane apDetails; +    @FXML private Label lblCodeHeader; +    @FXML private Label lblOpCode; +    @FXML private Label lblVehicles; +    @FXML private Label lblDate; +    @FXML private Label lblAddress; +    @FXML private FlowPane fpVehicles; +    private final OperationService operationService; +    @FXML private FlowPane archiveOperationFlowPane; +    private final CreateOperationController createOperationController; +    private Set<Operation> list = new HashSet<>(); +    private final SpringFXMLLoader fxmlLoader; + +    public ArchiveOperationController( +            OperationService operationService, +            CreateOperationController createOperationController, +            SpringFXMLLoader fxmlLoader) { +        this.operationService = operationService; +        this.createOperationController = createOperationController; +        this.fxmlLoader = fxmlLoader; +    } + +    @FXML +    private void initialize() { +        update(); +    } + +    public void update() { +        archiveOperationFlowPane.getChildren().clear(); +        list.clear(); +        try { +            list.addAll(operationService.list(EnumSet.of(Status.CANCELLED, Status.COMPLETED))); +            long cancelledAmount = 0; +            long completedAmount = 0; +            for (Operation operation : list) { +                if (operation.status() == Status.CANCELLED) cancelledAmount++; +                else completedAmount++; +            } +            lblCancelled.setText("storniert: " + cancelledAmount); +            lblCompleted.setText("abgeschlossen: " + completedAmount); +            lblOperations.setText("Einsätze: " + list.size()); +        } catch (ServiceException e) { +            LOG.error("ServiceException in update().", e); +            showServiceExceptionAlertAndWait("Die Einsätze konnten nicht geladen werden!"); +            ; +        } +        setFlowPane(list); +    } + +    public void update(Set<Operation> operations) { +        long cancelledAmount = 0; +        long completedAmount = 0; +        for (Operation operation : operations) { +            if (operation.status() == Status.CANCELLED) cancelledAmount++; +            else completedAmount++; +        } +        lblCancelled.setText("storniert: " + cancelledAmount); +        lblCompleted.setText("abgeschlossen: " + completedAmount); +        lblOperations.setText("Einsätze: " + operations.size()); +        setFlowPane(operations); +    } + +    private void setFlowPane(Set<Operation> operations) { +        try { +            archiveOperationFlowPane.getChildren().clear(); +            for (Operation operation : sortSet(operations)) { +                OperationInArchiveController opInAController = +                        OperationInArchiveController.create(); +                opInAController.set(operation); +                opInAController +                        .getRoot() +                        .setOnMouseClicked( +                                event -> { +                                    detailOperation = operation; +                                    backApMain.setVisible(false); +                                    apMainDetails.setVisible(false); +                                    backApDetails.setVisible(true); +                                    setOperation(); +                                    setDetailsVisible(true); +                                    imvVehicleDetail.setImage(new Image("/images/Vehicle.png")); +                                }); +                archiveOperationFlowPane.getChildren().add(opInAController.getRoot()); +            } +        } catch (IOException e) { +            LOG.error("IOException in setFlowPane(). ", e); +            showServiceExceptionAlertAndWait("Die Elemente konnten nicht geladen werden!"); +        } +    } + +    private Operation detailOperation; + +    private List<Operation> sortSet(Set<Operation> operationsSet) { +        Operation[] array = operationsSet.toArray(new Operation[operationsSet.size()]); +        for (int i = array.length - 1; i > 0; i--) { +            for (int j = 0; j < i; j++) { +                LocalDateTime first = +                        LocalDateTime.ofInstant( +                                Objects.requireNonNull(array[j].created()), ZoneOffset.UTC); +                LocalDateTime second = +                        LocalDateTime.ofInstant( +                                Objects.requireNonNull(array[j + 1].created()), ZoneOffset.UTC); +                if (first.isBefore(second)) { +                    Operation help = array[j]; +                    array[j] = array[j + 1]; +                    array[j + 1] = help; +                } +            } +        } +        return Arrays.asList(array); +    } + +    private void setOperation() { +        lblCodeHeader.setText(detailOperation.opCode()); +        if (detailOperation.created() != null) { +            LocalDateTime dateTime = +                    LocalDateTime.ofInstant( +                            Objects.requireNonNull(detailOperation.created()), ZoneOffset.UTC); +            lblDate.setText( +                    "am " +                            + dateTime.getDayOfMonth() +                            + "." +                            + dateTime.getMonth().getValue() +                            + "." +                            + dateTime.getYear()); +        } else { +            lblDate.setText("---"); +        } +        lblStatus.setText( +                "Status: " +                        + (detailOperation.status() == Status.CANCELLED +                                ? "storniert" +                                : "abgeschlossen")); +        lblOpCode.setText(detailOperation.opCode()); +        Collection<String> elements = +                detailOperation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); +        String result = String.join(", ", elements); + +        lblVehicles.setText(result); +        lblAddress.setText(detailOperation.destination()); + +        fpVehicles.getChildren().clear(); +        try { +            for (Vehicle vehicle : detailOperation.vehicles()) { +                DetailArchiveOperationController controller = null; + +                controller = DetailArchiveOperationController.create(fxmlLoader); + +                controller.set(vehicle, detailOperation); +                fpVehicles.getChildren().add(controller.getRoot()); +            } +        } catch (IOException e) { +            LOG.error("IOException in setOperation(). ", e); +            showServiceExceptionAlertAndWait("Die Element konnte nicht geladen werden!"); +        } +    } + +    private void setDetailsVisible(boolean b) { +        apDetails.setVisible(b); +    } + +    public void backClicked() { +        LOG.debug("Hyperlink \"Zurück\" in archive detail view clicked."); +        fpVehicles.getChildren().clear(); +        setDetailsVisible(false); +        backApDetails.setVisible(false); +        apMainDetails.setVisible(true); +        backApMain.setVisible(true); +    } + +    public void backToMain() { +        LOG.debug("Hyperlink \"Zurück\" in archive main view clicked."); +        this.setVisible(false); +        createOperationController.setVisible(true); +    } + +    void setVisible(boolean b) { +        archiveOperationAP.setVisible(b); +        backApMain.setVisible(b); +        apMainDetails.setVisible(b); +    } + +    @FXML +    public void searchInput() { +        LOG.debug("Search for operations in archive detail view started."); +        String text = txtSearch.getText(); +        Set<Operation> chosenOperations = new HashSet<>(); +        if (emptyText(text)) update(); +        else { +            for (Operation operation : list) { +                if (checkEquality(operation, text)) chosenOperations.add(operation); +            } +            update(chosenOperations); +        } +    } + +    private boolean emptyText(String text) { +        if (text == null) return true; +        text = text.replaceAll("\\s+", ""); +        return text.isEmpty(); +    } + +    private boolean checkEquality(Operation operation, String text) { +        if (isEqual(text, operation.opCode()) +                || isEqual(text, operation.destination()) +                || isEqual(text, reformDateToString(operation.created()))) return true; +        for (Vehicle vehicle : operation.vehicles()) { +            if (isEqual(text, vehicle.name())) return true; +        } +        return false; +    } + +    private String reformDateToString(Instant time) { +        LocalDateTime dateTime = +                LocalDateTime.ofInstant(Objects.requireNonNull(time), ZoneOffset.UTC); +        return "am " +                + dateTime.getDayOfMonth() +                + "." +                + dateTime.getMonth().getValue() +                + "." +                + dateTime.getYear(); +    } + +    private boolean isEqual(String text, String realText) { +        for (int i = 0; (i + text.length()) < realText.length(); i++) { +            StringBuilder result = new StringBuilder(); +            for (int j = i; j < i + text.length(); j++) { +                result.append(realText.charAt(j)); +            } +            if ((text.toLowerCase()).equals(result.toString().toLowerCase())) return true; +        } +        return false; +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java new file mode 100644 index 0000000..4da46a2 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateCarController.java @@ -0,0 +1,231 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import java.io.IOException; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javafx.collections.FXCollections; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceBox; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class CreateCarController { + +    @FXML private AnchorPane createCarAP; +    @FXML private ChoiceBox<String> cmbCtype; +    @FXML private ChoiceBox<String> cmbTyp; + +    @FXML private Button btnCreate; +    @FXML private CheckBox cbxNEF; +    @FXML private FlowPane fpVehicleList; +    private final CreateOperationController createOperationController; + +    private static final Logger LOG = LoggerFactory.getLogger(CreateCarController.class); +    private final VehicleService vehicleService; +    private boolean update = false; +    private long vid = -1; + +    private Vehicle chooseVehicle; + +    public CreateCarController( +            CreateOperationController createOperationController, VehicleService vehicleService) { +        this.createOperationController = createOperationController; +        this.vehicleService = vehicleService; +    } + +    @FXML +    private void initialize() { +        fpVehicleList.setHgap(5); +        fpVehicleList.setVgap(5); + +        cmbCtype.setItems( +                FXCollections.observableArrayList( +                        Stream.of( +                                        ConstructionType.NORMAL, +                                        ConstructionType.MITTELHOCHDACH, +                                        ConstructionType.HOCHDACH) +                                .map(Enum::toString) +                                .collect(Collectors.toList()))); +        cmbCtype.setValue(ConstructionType.NORMAL.toString()); +        cmbTyp.setItems( +                FXCollections.observableArrayList( +                        Stream.of( +                                        VehicleType.BKTW, +                                        VehicleType.KTW_B, +                                        VehicleType.KTW, +                                        VehicleType.RTW, +                                        VehicleType.NEF, +                                        VehicleType.NAH) +                                .map(Enum::toString) +                                .collect(Collectors.toList()))); +        cmbTyp.setValue(VehicleType.BKTW.toString()); + +        updateVehiclePane(); +    } + +    @FXML +    private void createCar(ActionEvent actionEvent) { + +        if (!update) { +            LOG.debug("Button \"Erstellen\" clicked."); +            Vehicle vehicle = +                    Vehicle.builder() +                            .constructionType(parseConstructionType()) +                            .type(parseType()) +                            .name("") +                            .status(Status.ABGEMELDET) +                            .hasNef(cbxNEF.isSelected()) +                            .build(); +            try { +                vehicleService.add(vehicle); +                setToStart(); +            } catch (InvalidVehicleException e) { +                LOG.debug("Validation of Vehicle failed"); +                showValidationErrorAlertAndWait(e.getMessage()); +                setToStart(); +                return; +            } catch (ServiceException e) { +                LOG.error("ServiceException in createCar(). ", e); +                showServiceExceptionAlertAndWait( +                        "Ein Fehler beim Erstellen des Fahrzeuges ist aufgetreten."); +                setToStart(); +                return; +            } +            showSuccessAlertAndWait("Auto wurde erfolgreich angelegt."); +        } else { +            LOG.debug("Button \"Speichern\" clicked."); +            try { +                Vehicle vehicle = +                        Vehicle.builder() +                                .id(vid) +                                .constructionType(parseConstructionType()) +                                .type(parseType()) +                                .name("") +                                .status(Status.ABGEMELDET) +                                .hasNef(cbxNEF.isSelected()) +                                .build(); +                vehicleService.update(vehicle); +                setToStart(); +                chooseVehicle = null; +            } catch (InvalidVehicleException e) { +                LOG.debug("Validation of Vehicle failed"); +                showValidationErrorAlertAndWait(e.getMessage()); +                setToStart(); +                return; +            } catch (ServiceException e) { +                LOG.error("ServiceException in createCar(). ", e); +                showServiceExceptionAlertAndWait(e.getMessage()); +                setToStart(); +                return; +            } +            showSuccessAlertAndWait("Auto wurde erfolgreich bearbeitet."); +        } + +        updateVehiclePane(); +    } + +    private ConstructionType parseConstructionType() { +        if (cmbCtype.getSelectionModel().getSelectedItem() == null) { +            return ConstructionType.NORMAL; +        } +        return ConstructionType.valueOf(cmbCtype.getSelectionModel().getSelectedItem()); +    } + +    private VehicleType parseType() { +        if (cmbTyp.getSelectionModel().getSelectedItem() == null) { +            return VehicleType.BKTW; +        } +        return VehicleType.valueOf(cmbTyp.getSelectionModel().getSelectedItem()); +    } + +    private void setToStart() { +        btnCreate.setText("Erstellen"); +        cbxNEF.setSelected(false); +        cmbTyp.setValue(VehicleType.BKTW.name()); +        cmbCtype.setValue(ConstructionType.NORMAL.name()); +        update = false; +    } + +    private void updateVehicle(Vehicle vehicle) { + +        cmbCtype.setValue(vehicle.constructionType().name()); +        cmbTyp.setValue(vehicle.type().name()); +        cbxNEF.setSelected(vehicle.hasNef()); +        btnCreate.setText("Speichern"); +        vid = vehicle.id(); +        update = true; +        chooseVehicle = vehicle; +    } + +    public void setVisible(boolean b) { +        createCarAP.setVisible(b); +    } + +    @FXML +    private void backToMain() { +        LOG.debug("Hyperlink \"zurück\" clicked."); +        this.setVisible(false); +        createOperationController.setVisible(true); +    } + +    void updateVehiclePane() { +        try { +            fpVehicleList.getChildren().clear(); + +            Set<Vehicle> vehicles; + +            vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + +            for (Vehicle vehicle : vehicles) { +                VehiclePaneController controller = VehiclePaneController.createVehiclePane(); + +                controller.setData(vehicle, false, false); +                controller +                        .getRootElement() +                        .setOnMouseClicked( +                                event -> { +                                    if (event.getButton().equals(MouseButton.PRIMARY)) { +                                        if (chooseVehicle == null || vehicle == chooseVehicle) { +                                            if (update == false) { +                                                chooseVehicle = vehicle; +                                                updateVehicle(vehicle); +                                                controller.setSelected(true); +                                            } else { +                                                setToStart(); +                                                controller.setSelected(false); + +                                                chooseVehicle = null; +                                            } +                                        } +                                    } +                                }); + +                fpVehicleList.getChildren().add(controller.getRootElement()); +            } +        } catch (ServiceException | IOException e) { +            LOG.error("Exception in updateVehiclePane(). ", e); +            showServiceExceptionAlertAndWait(e.getMessage()); +        } +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java index 15282cc..3e0240c 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeController.java @@ -1,24 +1,24 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper;  import java.io.IOException; -import java.lang.invoke.MethodHandles;  import java.time.LocalDate;  import java.util.stream.Collectors;  import java.util.stream.Stream;  import javafx.collections.FXCollections;  import javafx.fxml.FXML;  import javafx.scene.Node; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType;  import javafx.scene.control.Button; -import javafx.scene.control.ButtonType;  import javafx.scene.control.CheckBox;  import javafx.scene.control.ChoiceBox;  import javafx.scene.control.Label; @@ -32,7 +32,7 @@ import org.springframework.stereotype.Controller;  @Scope("prototype")  public class CreateNewEmployeeController { -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); +    private static final Logger LOG = LoggerFactory.getLogger(CreateNewEmployeeController.class);      private final EmployeeService employeeService;      @FXML private Label lblHeader; @@ -80,6 +80,7 @@ public class CreateNewEmployeeController {      @FXML      private void onCancelClicked() { +        LOG.debug("Hyperlink \"abbrechen\" clicked.");          if (consumerCancelClicked != null) {              consumerCancelClicked.run();          } @@ -87,6 +88,7 @@ public class CreateNewEmployeeController {      @FXML      private void onCreateClicked() { +        LOG.debug("Button {} clicked.", btnCreate.getText());          employee =                  employee.toBuilder() @@ -104,40 +106,24 @@ public class CreateNewEmployeeController {                  employeeService.add(employee);              }          } catch (InvalidEmployeeException e) { -            LOG.error("Invalid Employee: {}", e); - -            showModalDialogWithOkButton( -                    AlertType.ERROR, -                    "Ungültige Eingabe", -                    "Mindestens eines der Eingabefelder haben einen ungültigen Wert!"); +            LOG.debug("Validation for Employee failed"); +            showValidationErrorAlertAndWait(e.getMessage());              return;          } catch (ServiceException e) { -            LOG.error("Employee could not be saved: {}", e); - -            showModalDialogWithOkButton( -                    AlertType.ERROR, -                    "Speicherfehler", +            LOG.error("ServiceException in onCreateClicked(). ", e); +            showServiceExceptionAlertAndWait(                      "Der Eintrag konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.");              return;          } -        showModalDialogWithOkButton( -                AlertType.INFORMATION, -                "Erfolgreich angelegt", -                "Mitarbeiter wurde erfolgreich angelegt und gespeichert!"); +        showSuccessAlertAndWait( +                "Der/die MitarbeiterIn wurde erfolgreich angelegt und gespeichert!");          if (consumerCreateClicked != null) {              consumerCreateClicked.run();          }      } -    private void showModalDialogWithOkButton( -            AlertType alertType, String headerText, String contentText) { -        Alert alert = new Alert(alertType, contentText, ButtonType.OK); -        alert.setHeaderText(headerText); -        alert.showAndWait(); -    } -      private EducationLevel parseEducationLevel() {          if (inputQualification.getSelectionModel().getSelectedItem() == null) {              return EducationLevel.RS; @@ -152,7 +138,6 @@ public class CreateNewEmployeeController {          inputQualification.setValue(employee.educationLevel().name());          inputIsDriver.setSelected(employee.isDriver());          inputIsPilot.setSelected(employee.isPilot()); -          lblHeader.setText("Person bearbeiten");          btnCreate.setText("Speichern");      } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java index 57759e3..f06b43f 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateOperationController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateOperationController.java @@ -1,31 +1,26 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; -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.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.OperationService; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +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 at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService;  import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.time.Instant; -import java.time.temporal.ChronoUnit; -import java.util.ArrayList;  import java.util.EnumSet;  import java.util.LinkedList; -import java.util.List;  import java.util.Set;  import javafx.collections.FXCollections; -import javafx.event.ActionEvent;  import javafx.fxml.FXML; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.Alert; -import javafx.scene.control.Alert.AlertType;  import javafx.scene.control.Button;  import javafx.scene.control.ContextMenu;  import javafx.scene.control.Label; @@ -38,7 +33,7 @@ import javafx.scene.input.KeyEvent;  import javafx.scene.input.MouseButton;  import javafx.scene.layout.AnchorPane;  import javafx.scene.layout.FlowPane; -import javafx.stage.Stage; +import javafx.scene.layout.GridPane;  import org.slf4j.Logger;  import org.slf4j.LoggerFactory;  import org.springframework.stereotype.Controller; @@ -46,9 +41,10 @@ import org.springframework.stereotype.Controller;  @Controller  public class CreateOperationController { -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); +    private static final Logger LOG = LoggerFactory.getLogger(CreateOperationController.class);      public AnchorPane apCreateOperation; +    @FXML private GridPane grdWindowContainer;      @FXML private TextField txtCode;      @FXML private TextField txtAddress;      @FXML private TextField txtNote; @@ -58,40 +54,33 @@ public class CreateOperationController {      @FXML private Label lblChosenVehicles;      @FXML private AnchorPane apInvisible;      @FXML private OperationDetailsController operationDetailsController; +    @FXML private ManageEmployeesController manageEmployeesController; +    @FXML private CreateCarController createCarController; +    @FXML private RegistrationWindowController registrationWindowController; +    @FXML private ArchiveOperationController archiveOperationController;      @FXML private FlowPane fpVehicles;      private LinkedList<Vehicle> chosenVehicles = new LinkedList<>();      private final OperationService operationService;      private final VehicleService vehicleService; -    private final SpringFXMLLoader fxmlLoader; +    private final RegistrationService registrationService;      public CreateOperationController(              OperationService operationService,              VehicleService vehicleService, -            SpringFXMLLoader fxmlLoader) { +            RegistrationService registrationService) {          this.operationService = operationService;          this.vehicleService = vehicleService; -        this.fxmlLoader = fxmlLoader; +        this.registrationService = registrationService;      }      @FXML      private void initialize() { +          lblChosenVehicles.setText("keine ausgewählt"); -        lvActiveOperations.setCellFactory( -                param -> -                        new ListCell<>() { -                            @Override -                            protected void updateItem(Operation item, boolean empty) { -                                super.updateItem(item, empty); +        lvActiveOperations.setCellFactory(param -> generateOpCodeListItem()); -                                if (empty || item == null || item.opCode() == null) { -                                    setText(null); -                                } else { -                                    setText(item.opCode()); -                                } -                            } -                        });          lvActiveOperations.setOnMouseClicked(                  event -> {                      if (event.getClickCount() == 2) { @@ -101,6 +90,12 @@ public class CreateOperationController {                          openDetailsWindow(lvActiveOperations.getSelectionModel().getSelectedItem());                      }                  }); + +        setVisible(true); +        createCarController.setVisible(false); +        registrationWindowController.setVisible(false); + +        updateList();      }      public void updateList() { @@ -120,13 +115,16 @@ public class CreateOperationController {              for (Vehicle vehicle : vehicles) {                  VehiclePaneController controller = VehiclePaneController.createVehiclePane(); -                controller.setData(vehicle, true); +                controller.setData(vehicle, true, false);                  controller                          .getRootElement()                          .setOnMouseClicked(                                  event -> {                                      if (event.getButton().equals(MouseButton.SECONDARY)) { -                                        createContextMenu(vehicle, vehicleService) +                                        createContextMenu( +                                                        vehicle, +                                                        vehicleService, +                                                        registrationService)                                                  .show(                                                          controller.getRootElement(),                                                          event.getScreenX(), @@ -157,37 +155,36 @@ public class CreateOperationController {                                      }                                  }); +                if (chosenVehicles.stream().anyMatch(v -> v.id() == vehicle.id())) +                    controller.setSelected(true); +                  fpVehicles.getChildren().add(controller.getRootElement());              } -        } catch (ServiceException | IOException | InvalidOperationException e) { -            LOG.error("Error while updating list.", e); - -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +        } catch (ServiceException | IOException e) { +            LOG.error("Exception in updateList(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Erstellen des Ranking ist ein Fehler aufgetreten."); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in updateList(). ", e); +            showValidationErrorAlertAndWait(e.getMessage());          }          try {              lvActiveOperations.setItems(                      FXCollections.observableArrayList(                              operationService.list(EnumSet.of(Status.ACTIVE))));          } catch (ServiceException e) { -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler - Einsätze"); -            alert.setHeaderText("Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten."); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +            LOG.error("ServiceException in updateList(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Holen der aktiven Einsätze ist ein Fehler aufgetreten");          }      } -    private ContextMenu createContextMenu(Vehicle data, VehicleService vehicleService) { +    private ContextMenu createContextMenu( +            Vehicle data, VehicleService vehicleService, RegistrationService registrationService) {          ContextMenu menu = new ContextMenu();          for (Vehicle.Status status : Vehicle.Status.values()) { -            if (status == Vehicle.Status.ABGEMELDET) { -                continue; -            } +            if (status == Vehicle.Status.ABGEMELDET) continue;              MenuItem mi = new MenuItem(status.name()); @@ -202,10 +199,15 @@ public class CreateOperationController {                          try {                              vehicleService.update(data.toBuilder().status(status).build());                              this.updateList(); -                        } catch (InvalidVehicleException | ServiceException e) { -                            LOG.error("Error while setting status.", e); -                            Alert a = new Alert(AlertType.ERROR, e.getMessage()); -                            a.show(); +                        } catch (InvalidVehicleException e) { +                            LOG.debug( +                                    "Validation error in createContextMenu(). (mi.setOnAction) ", +                                    e); +                            showValidationErrorAlertAndWait(e.getMessage()); +                        } catch (ServiceException e) { +                            LOG.error("Exception in createContextMenu(). (mi.setOnAction) ", e); +                            showServiceExceptionAlertAndWait( +                                    "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten.");                          }                      }); @@ -217,35 +219,23 @@ public class CreateOperationController {          abmelden.setOnAction(                  event -> {                      try { -                        List<Registration> registrations = data.registrations(); -                        assert registrations -                                != null; // Otherwise the element shouldn't be in the list. +                        if (data.registrations() == null) return; -                        List<Registration> newRegistrations = new ArrayList<>(); -                        Instant now = Instant.now(); - -                        for (Registration registration : registrations) { -                            if (registration.start().isBefore(now) -                                    && registration.end().isAfter(now)) { -                                newRegistrations.add( -                                        registration -                                                .toBuilder() -                                                .end(Instant.now().minus(1, ChronoUnit.SECONDS)) -                                                .build()); -                            } else newRegistrations.add(registration); -                        } +                        for (Registration registration : data.registrations()) +                            registrationService.remove(registration.id());                          vehicleService.update( -                                data.toBuilder() -                                        .registrations(newRegistrations) -                                        .status(Vehicle.Status.ABGEMELDET) -                                        .build()); - +                                data.toBuilder().status(Vehicle.Status.ABGEMELDET).build());                          this.updateList(); -                    } catch (InvalidVehicleException | ServiceException e) { -                        LOG.error("Error while unregistering.", e); -                        Alert a = new Alert(AlertType.ERROR, e.getMessage()); -                        a.show(); +                    } catch (InvalidVehicleException | InvalidRegistrationException e) { +                        LOG.debug( +                                "Validation error in createContextMenu(). (abmelden.setOnAction) ", +                                e); +                        showValidationErrorAlertAndWait(e.getMessage()); +                    } catch (ServiceException e) { +                        LOG.error("Exception in createContextMenu(). (abmelden.setOnAction) ", e); +                        showServiceExceptionAlertAndWait( +                                "Beim Aktualisieren der Fahrzeuge ist ein Fehler aufgetreten.");                      }                  }); @@ -255,6 +245,7 @@ public class CreateOperationController {      @FXML      protected void createOperationClicked() { +        LOG.debug("Button \"Erstellen\" clicked.");          Vehicle[] vehicles = new Vehicle[chosenVehicles.size()];          for (int i = 0; i < chosenVehicles.size(); i++) {              vehicles[i] = chosenVehicles.get(i); @@ -269,19 +260,17 @@ public class CreateOperationController {                          .build();          try {              operationService.add(operation); -        } catch (ServiceException | InvalidOperationException e) { -            Alert alert = new Alert(Alert.AlertType.ERROR); -            alert.setTitle("Fehler"); -            alert.setHeaderText("Fehler!"); -            alert.setContentText(e.getMessage()); -            alert.showAndWait(); +        } catch (ServiceException e) { +            LOG.error("Exception in createOperationClicked(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Erstellen des Einsatzes ist ein Fehler aufgetreten."); +            return; +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in createOperationClicked(). ", e); +            showValidationErrorAlertAndWait(e.getMessage());              return;          } -        Alert alert = new Alert(AlertType.CONFIRMATION); -        alert.setTitle("Erfolg"); -        alert.setHeaderText("Erfolgreich gespeichert"); -        alert.setContentText("Der Einsatz wurde erfolgreich gespeichert."); -        alert.showAndWait(); +        showSuccessAlertAndWait("Der Einsatz wurde erfolgreich gespeichert.");          updateList();          lblChosenVehicles.setText("keine ausgewählt");          txtAddress.setText(""); @@ -290,76 +279,83 @@ public class CreateOperationController {          chosenVehicles = new LinkedList<>();      } -    public void onRegistrationLinkClicked(ActionEvent actionEvent) { -        openNewWindow("RegistrationWindow.fxml"); +    @FXML +    private void onRegistrationLinkClicked() { +        LOG.debug("Hyperlink \"Anmeldungen\" clicked."); +        openRegistrationWindow();      } -    public void onEmployeeLinkClicked(ActionEvent actionEvent) { -        openNewWindow("listEmployees.fxml"); +    @FXML +    private void onEmployeeLinkClicked() { +        LOG.debug("Hyperlink \"Personen\" clicked."); +        openCreateNewEmployeeWindow();      } -    public void onVehicleLinkClicked(ActionEvent actionEvent) { -        openNewWindow("createCar.fxml"); +    @FXML +    private void onVehicleLinkClicked() { +        LOG.debug("Hyperlink \"Fahrzeuge\" clicked."); +        openCreateCarWindow();      } -    public void onArchivLinkClicked() { -        openNewArchivWindow(); +    @FXML +    private void onArchivLinkClicked() { +        LOG.debug("Hyperlink \"Archiv\" clicked."); +        archiveOperationController.update(); +        openArchivWindow();      } -    private void openNewArchivWindow() { -        Stage stage = new Stage(); -        try { -            stage.setScene( -                    new Scene( -                            (Parent) -                                    fxmlLoader.load( -                                            getClass() -                                                    .getResourceAsStream( -                                                            "/fxml/ArchiveOperation.fxml")))); -        } catch (IOException e) { -            LOG.error("Could not open new window: {}", e); -        } -        stage.setTitle("Einsatz erstellen"); -        stage.centerOnScreen(); -        stage.show(); -        updateList(); +    private void openArchivWindow() { +        archiveOperationController.setVisible(true); +        this.setVisible(false);      } -    private void openNewWindow(String fxmlFileName) { +    void setVisible(boolean b) { +        apInvisible.setVisible(!b); +        grdWindowContainer.setVisible(!b); -        Stage stage = new Stage(); -        try { -            stage.setScene( -                    new Scene( -                            (Parent) -                                    fxmlLoader.load( -                                            getClass() -                                                    .getResourceAsStream( -                                                            "/fxml/" + fxmlFileName)))); -        } catch (IOException e) { -            LOG.error("Could not open new window: {}", e); -        } +        // if (b) updateList(); +    } -        stage.setTitle("Ressourcenverwaltung"); -        stage.centerOnScreen(); -        stage.showAndWait(); // important to call wait so that updateList is executed afterwards +    private void openDetailsWindow(Operation operation) { +        operationDetailsController.initOperation(operation); +        this.setVisible(false); +    } -        updateList(); +    private void openCreateNewEmployeeWindow() { +        this.setVisible(false); +        manageEmployeesController.setVisible(true);      } -    void setVisible(boolean b) { -        apInvisible.setVisible(!b); +    private void openCreateCarWindow() { +        this.setVisible(false); +        createCarController.setVisible(true); +        createCarController.updateVehiclePane();      } -    private void openDetailsWindow(Operation operation) { -        operationDetailsController.initOperation(operation); +    private void openRegistrationWindow() {          this.setVisible(false); +        registrationWindowController.setVisible(true);      }      @FXML -    public void onOperationCodeChanged(KeyEvent keyEvent) { +    private void onOperationCodeChanged(KeyEvent keyEvent) {          if (keyEvent.getCode() == KeyCode.ENTER) {              updateList();          }      } + +    static ListCell<Operation> generateOpCodeListItem() { +        return new ListCell<>() { +            @Override +            protected void updateItem(Operation item, boolean empty) { +                super.updateItem(item, empty); + +                if (empty || item == null || item.opCode() == null) { +                    setText(null); +                } else { +                    setText(item.opCode()); +                } +            } +        }; +    }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java new file mode 100644 index 0000000..ced0c10 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CustomListItemController.java @@ -0,0 +1,24 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import javafx.scene.Node; + +public abstract class CustomListItemController { + +    protected Node rootElement; + +    public Node getRootElement() { +        return rootElement; +    } + +    public void setSelected(boolean selected) { +        rootElement.getStyleClass().clear(); + +        if (selected) { +            rootElement.getStyleClass().add("bg-yellow"); +            rootElement.getStyleClass().add("shadowed"); +        } else { +            rootElement.getStyleClass().add("bg-white"); +            rootElement.getStyleClass().add("shadowed"); +        } +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java new file mode 100644 index 0000000..a866653 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/DetailArchiveOperationController.java @@ -0,0 +1,96 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.scene.Node; +import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class DetailArchiveOperationController { +    private static final Logger LOG = +            LoggerFactory.getLogger(DetailArchiveOperationController.class); + +    @FXML private VBox vBoxVehicle; +    @FXML private VBox vBoxPeople; +    private final SpringFXMLLoader fxmlLoader; + +    public DetailArchiveOperationController(SpringFXMLLoader fxmlLoader) { +        this.fxmlLoader = fxmlLoader; +    } + +    static DetailArchiveOperationController create(SpringFXMLLoader fxmlLoader) throws IOException { +        FXMLWrapper<Object, DetailArchiveOperationController> wrapper = +                fxmlLoader.loadAndWrap( +                        "/fxml/DetailArchiveOperation.fxml", +                        DetailArchiveOperationController.class); + +        Node root = (Node) wrapper.getLoadedObject(); +        DetailArchiveOperationController result = wrapper.getController(); +        result.rootElement = root; + +        return result; +    } + +    public Node getRoot() { +        return rootElement; +    } + +    private Node rootElement; + +    public void set(Vehicle vehicle, Operation operation) { +        VehiclePaneController controller; +        try { +            controller = VehiclePaneController.createVehiclePane(); +            controller.setData(vehicle, false, false); +            vBoxVehicle.getChildren().add(controller.getRootElement()); +        } catch (IOException e) { +            LOG.error("IOException in set(Vehicle). (vBoxVehicle) ", e); +            showServiceExceptionAlertAndWait( +                    "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); +        } +        try { +            List<Registration> registrations = +                    Objects.requireNonNull(vehicle.registrations()) +                            .stream() +                            .filter( +                                    registration -> +                                            registration +                                                            .start() +                                                            .isBefore( +                                                                    Objects.requireNonNull( +                                                                            operation.created())) +                                                    && registration +                                                            .end() +                                                            .isAfter( +                                                                    Objects.requireNonNull( +                                                                            operation.created()))) +                            .collect(Collectors.toList()); + +            for (Registration registration : registrations) { +                Employee employee = registration.employee(); +                EmployeeListItemController employeeListItemController = +                        EmployeeListItemController.createEmployeeListItemController( +                                fxmlLoader, employee); +                vBoxPeople.getChildren().add(employeeListItemController.getRootElement()); +            } +        } catch (IOException e) { +            LOG.error("IOException in set(Vehicle). (vBoxPeople) ", e); +            showServiceExceptionAlertAndWait( +                    "Ein interner Fehler ist aufgetreten. Bitte wenden Sie sich an den/die SystemadministratorIn."); +        } +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java new file mode 100644 index 0000000..12f6bff --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListController.java @@ -0,0 +1,133 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.function.Consumer; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; + +@Controller +@Scope("prototype") +public class EmployeeListController { + +    private static final Logger LOG = LoggerFactory.getLogger(EmployeeListController.class); + +    @FXML private FlowPane flowPaneEmployeeList; + +    private Consumer<Employee> onEmployeeClicked; + +    private final SpringFXMLLoader fxmlLoader; +    private Node rootElement; +    private List<EmployeeListItemController> employeeListItemControllers; +    private Insets listItemMargins = new Insets(10, 5, 0, 5); + +    public EmployeeListController(SpringFXMLLoader fxmlLoader) { +        this.fxmlLoader = fxmlLoader; +        this.employeeListItemControllers = new ArrayList<>(); +    } + +    public void setListItemMargins(Insets value) { +        this.listItemMargins = value; +    } + +    public void setData(Set<Employee> employeeList) { +        setData(employeeList, null, null); +    } + +    public void setData(Set<Employee> employeeList, Consumer<Employee> onEmployeeClicked) { +        setData(employeeList, onEmployeeClicked, null); +    } + +    public void setData( +            Set<Employee> employeeList, +            Consumer<Employee> onEmployeeClicked, +            Consumer<EmployeeListItemController> onEmployeeListItemClicked) { + +        flowPaneEmployeeList.getChildren().clear(); +        employeeListItemControllers.clear(); +        employeeList.forEach( +                employee -> +                        addEmployeeToFlowPane( +                                employee, onEmployeeClicked, onEmployeeListItemClicked)); +    } + +    private void addEmployeeToFlowPane( +            Employee employee, +            Consumer<Employee> onEmployeeClicked, +            Consumer<EmployeeListItemController> onEmployeeListItemClicked) { + +        try { +            EmployeeListItemController controller = +                    EmployeeListItemController.createEmployeeListItemController( +                            fxmlLoader, employee); +            Node rootElement = controller.getRootElement(); +            flowPaneEmployeeList.getChildren().add(rootElement); +            employeeListItemControllers.add(controller); +            FlowPane.setMargin(rootElement, listItemMargins); +            if (onEmployeeClicked != null) { +                controller.setConsumerEmployeeClicked(onEmployeeClicked); +            } +            if (onEmployeeListItemClicked != null) { +                controller.setConsumerEmployeeListItemClicked( +                        employeeListItemController -> { +                            onEmployeeListItemClicked.accept(employeeListItemController); +                            if (this.onEmployeeClicked != null) { +                                this.onEmployeeClicked.accept( +                                        employeeListItemController.getEmployee()); +                            } +                        }); +            } +        } catch (IOException e) { +            LOG.error("IOException in addEmployeeToFlowPane. ", e); +        } +    } + +    private void setEmployeeSelected(Employee employee, boolean selected) { +        employeeListItemControllers +                .stream() +                .filter(controller -> controller.getEmployee().equals(employee)) +                .forEach(controller -> controller.setSelected(selected)); +    } + +    public void selectEmployee(Employee employee) { +        setEmployeeSelected(employee, true); +    } + +    public void deselectEmployee(Employee employee) { +        setEmployeeSelected(employee, false); +    } + +    public void deselectAllEmployees() { +        employeeListItemControllers.forEach( +                employeeListItemController -> employeeListItemController.setSelected(false)); +    } + +    public static EmployeeListController createEmployeeListController(SpringFXMLLoader loader) +            throws IOException { +        FXMLWrapper<Object, EmployeeListController> wrapper = +                loader.loadAndWrap("/fxml/employeeList.fxml", EmployeeListController.class); +        Node root = (Node) wrapper.getLoadedObject(); +        EmployeeListController controller = wrapper.getController(); +        controller.rootElement = root; +        return controller; +    } + +    public Node getRootElement() { +        return rootElement; +    } + +    public void setOnEmployeeClicked(Consumer<Employee> onEmployeeClicked) { +        this.onEmployeeClicked = onEmployeeClicked; +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java index 11b5626..d445b43 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/EmployeeListItemController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/EmployeeListItemController.java @@ -1,6 +1,6 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper;  import java.io.IOException; @@ -15,7 +15,7 @@ import org.springframework.stereotype.Controller;  @Controller  @Scope("prototype") -public class EmployeeListItemController { +public class EmployeeListItemController extends CustomListItemController {      @FXML private Label lblName;      @FXML private Label lblQualification; @@ -25,15 +25,24 @@ public class EmployeeListItemController {      @FXML private ImageView imgDriver;      @FXML private ImageView imgQualification; -    private Node rootElement;      private Employee employee; -    private Consumer<Employee> consumerEditEmployeeClicked; +    private Consumer<Employee> consumerEmployeeClicked; +    private Consumer<EmployeeListItemController> consumerEmployeeListItemClicked; + +    private static Image imageQualification = new Image("/images/Qualification.png"); +    private static Image imagePilot = new Image("/images/Pilot.png"); +    private static Image imageNotPilot = new Image("/images/NotPilot.png"); +    private static Image imageDriver = new Image("images/Driver.png"); +    private static Image imageNotDriver = new Image("images/NotDriver.png");      @FXML -    public void onEditEmployeeClicked() { -        if (consumerEditEmployeeClicked != null) { -            consumerEditEmployeeClicked.accept(employee); +    private void onEmployeeClicked() { +        if (consumerEmployeeClicked != null) { +            consumerEmployeeClicked.accept(employee); +        } +        if (consumerEmployeeListItemClicked != null) { +            consumerEmployeeListItemClicked.accept(this);          }      } @@ -43,13 +52,9 @@ public class EmployeeListItemController {          lblQualification.setText(employee.educationLevel().name());          lblPilot.setText(String.format("%s Pilot", employee.isPilot() ? "ist" : "nicht"));          lblDriver.setText(String.format("%s Fahrer", employee.isDriver() ? "ist" : "nicht")); -        imgQualification.setImage(new Image("/images/Qualification.png")); -        String imgSrcPilot = -                String.format("/images/%s", employee.isPilot() ? "Pilot.png" : "NotPilot.png"); -        imgPilot.setImage(new Image(imgSrcPilot)); -        String imgSrcDriver = -                String.format("/images/%s", employee.isDriver() ? "Driver.png" : "NotDriver.png"); -        imgDriver.setImage(new Image(imgSrcDriver)); +        imgQualification.setImage(imageQualification); +        imgPilot.setImage(employee.isPilot() ? imagePilot : imageNotPilot); +        imgDriver.setImage(employee.isDriver() ? imageDriver : imageNotDriver);      }      public static EmployeeListItemController createEmployeeListItemController( @@ -69,15 +74,16 @@ public class EmployeeListItemController {          return controller;      } -    public Node getRootElement() { -        return rootElement; -    } -      public Employee getEmployee() {          return employee;      } -    public void setConsumerEditEmployeeClicked(Consumer<Employee> consumerEditEmployeeClicked) { -        this.consumerEditEmployeeClicked = consumerEditEmployeeClicked; +    public void setConsumerEmployeeClicked(Consumer<Employee> consumerEmployeeClicked) { +        this.consumerEmployeeClicked = consumerEmployeeClicked; +    } + +    public void setConsumerEmployeeListItemClicked( +            Consumer<EmployeeListItemController> consumerEmployeeListItemClicked) { +        this.consumerEmployeeListItemClicked = consumerEmployeeListItemClicked;      }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java index 6d6214d..a31c3e3 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/FilterEmployeesController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/FilterEmployeesController.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader.FXMLWrapper; @@ -7,12 +7,15 @@ import java.util.function.Consumer;  import javafx.fxml.FXML;  import javafx.scene.Node;  import javafx.scene.control.TextField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory;  import org.springframework.context.annotation.Scope;  import org.springframework.stereotype.Controller;  @Controller  @Scope("prototype")  public class FilterEmployeesController { +    private static final Logger LOG = LoggerFactory.getLogger(FilterEmployeesController.class);      @FXML private TextField inputFilterString; @@ -23,6 +26,7 @@ public class FilterEmployeesController {      @FXML      private void onAddEmployeeClicked() { +        LOG.debug("Button \"Person hinzufügen\" clicked.");          if (consumerAddEmployeeClicked != null) {              consumerAddEmployeeClicked.run();          } @@ -30,6 +34,7 @@ public class FilterEmployeesController {      @FXML      private void onFilterTextChanged() { +        LOG.debug("Filter text changed.");          if (consumerFilterTextChanged != null) {              consumerFilterTextChanged.accept(inputFilterString.getText());          } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java new file mode 100644 index 0000000..f120eb6 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/Helper.java @@ -0,0 +1,34 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.ButtonType; + +public class Helper { + +    static final String ALERT_TITLE_VALIDATION_ERROR = "Validierungsfehler"; +    static final String ALERT_TITLE_SERVICE_EXCEPTION = "Fehler"; +    static final String ALERT_TITLE_SUCCESS = "Erfolg"; + +    private Helper() {} // SonarLint insisted to create a private constructor to hide the public one + +    static void showValidationErrorAlertAndWait(String message) { +        showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_VALIDATION_ERROR, message); +    } + +    static void showServiceExceptionAlertAndWait(String message) { +        showAlertWithOkButtonAndWait(AlertType.ERROR, ALERT_TITLE_SERVICE_EXCEPTION, message); +    } + +    static void showSuccessAlertAndWait(String message) { +        showAlertWithOkButtonAndWait(AlertType.INFORMATION, ALERT_TITLE_SUCCESS, message); +    } + +    static void showAlertWithOkButtonAndWait( +            AlertType alertType, String headerText, String contentText) { +        Alert alert = new Alert(alertType, contentText, ButtonType.OK); +        alert.setTitle(headerText); +        alert.setHeaderText(headerText); +        alert.showAndWait(); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ListEmployeesController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java index 25f1263..fa228de 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/ListEmployeesController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/ManageEmployeesController.java @@ -1,34 +1,38 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader;  import java.io.IOException; -import java.lang.invoke.MethodHandles; +import java.util.HashSet; +import java.util.stream.Collectors;  import javafx.fxml.FXML; -import javafx.geometry.Insets; -import javafx.scene.Node;  import javafx.scene.layout.AnchorPane; -import javafx.scene.layout.FlowPane;  import org.slf4j.Logger;  import org.slf4j.LoggerFactory;  import org.springframework.stereotype.Controller;  @Controller -public class ListEmployeesController { - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); +public class ManageEmployeesController { +    private static final Logger LOG = LoggerFactory.getLogger(ManageEmployeesController.class); +    @FXML private AnchorPane listEmployeesAP;      @FXML private AnchorPane containerHeader; -    @FXML private FlowPane flowPaneEmployeeList; +    @FXML private EmployeeListController employeeListController;      private final EmployeeService employeeService;      private final SpringFXMLLoader fxmlLoader; -    public ListEmployeesController(EmployeeService employeeService, SpringFXMLLoader fxmlLoader) { +    private final CreateOperationController createOperationController; + +    public ManageEmployeesController( +            EmployeeService employeeService, +            SpringFXMLLoader fxmlLoader, +            CreateOperationController createOperationController) {          this.employeeService = employeeService;          this.fxmlLoader = fxmlLoader; +        this.createOperationController = createOperationController;      }      @FXML @@ -44,19 +48,21 @@ public class ListEmployeesController {              containerHeader.getChildren().add(filterEmployeesController.getRootElement());              filterEmployeesController.setOnFilterTextChangedListener(this::updateEmployeeList);              filterEmployeesController.setOnAddEmployeeClickedListener(this::openAddEmployee); -              updateEmployeeList();          } catch (IOException e) { -            LOG.error("Could not initialize controller: {}", e); +            LOG.error("IOException in openFilter().", e);          }      }      private void openAddEmployee() { +        employeeListController.deselectAllEmployees();          openEmployee(null);      }      private void openEditEmployee(Employee employee) { +        employeeListController.deselectAllEmployees(); +        employeeListController.selectEmployee(employee);          openEmployee(employee);      } @@ -73,7 +79,7 @@ public class ListEmployeesController {              createNewEmployeeController.setConsumerCancelClicked(this::openFilter);              createNewEmployeeController.setConsumerCreateClicked(this::openFilter);          } catch (IOException e) { -            LOG.error("Could not prepare UI for adding employee: {}", e); +            LOG.error("IOException in openEmployee(). ", e);          }      } @@ -82,36 +88,33 @@ public class ListEmployeesController {      }      private void updateEmployeeList(String searchString) { +          try { -            flowPaneEmployeeList.getChildren().clear(); -            employeeService -                    .list() -                    .stream() -                    .filter( -                            employee -> -                                    searchString.trim().isEmpty() -                                            || employee.name() -                                                    .toLowerCase() -                                                    .contains(searchString.toLowerCase())) -                    .forEach(this::addEmployeeToFlowPane); +            employeeListController.setData( +                    employeeService +                            .list() +                            .stream() +                            .filter( +                                    employee -> +                                            searchString.trim().isEmpty() +                                                    || employee.name() +                                                            .toLowerCase() +                                                            .contains(searchString.toLowerCase())) +                            .collect(Collectors.toCollection(HashSet::new)), +                    this::openEditEmployee); +          } catch (ServiceException e) { -            LOG.error("Could not fetch employee list: {}", e); +            LOG.error("ServiceException in updateEmployeeList(). ", e);          }      } -    private void addEmployeeToFlowPane(Employee employee) { -        Insets listItemMargins = new Insets(0, 5, 10, 5); +    public void setVisible(boolean b) { +        listEmployeesAP.setVisible(b); +    } -        try { -            EmployeeListItemController controller = -                    EmployeeListItemController.createEmployeeListItemController( -                            fxmlLoader, employee); -            Node rootElement = controller.getRootElement(); -            flowPaneEmployeeList.getChildren().add(rootElement); -            FlowPane.setMargin(rootElement, listItemMargins); -            controller.setConsumerEditEmployeeClicked(this::openEditEmployee); -        } catch (IOException e) { -            LOG.error("Could not create a new EmployeeListItem: {}", e); -        } +    public void backToMain() { +        LOG.debug("Hyperlink \"Zurück\" clicked."); +        this.setVisible(false); +        createOperationController.setVisible(true);      }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java new file mode 100644 index 0000000..daeaedd --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationDetailsController.java @@ -0,0 +1,194 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showAlertWithOkButtonAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showSuccessAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import java.io.IOException; +import java.util.Collection; +import java.util.EnumSet; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.fxml.FXML; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ListView; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.FlowPane; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class OperationDetailsController { +    private static final Logger LOG = LoggerFactory.getLogger(OperationDetailsController.class); + +    public Operation operation; +    private final OperationService operationService; +    private final VehicleService vehicleService; +    private final CreateOperationController createOperationController; +    @FXML private FlowPane fpVehicles; +    @FXML private FlowPane fpAdditional; +    @FXML private ListView<Operation> lvActiveOperations; +    @FXML private Label lblChosenVehicles; +    @FXML private Button btnCloseOperation; +    @FXML private Button btnCancelOperation; +    @FXML private Label lblCode, lblAdditionalInfo, lblAddress; +    @FXML private AnchorPane operationDetailsAP; + +    public OperationDetailsController( +            OperationService operationService, +            VehicleService vehicleService, +            CreateOperationController createOperationController) { +        this.operationService = operationService; +        this.vehicleService = vehicleService; +        this.createOperationController = createOperationController; +    } + +    @FXML +    private void initialize() { +        lvActiveOperations.setCellFactory( +                param -> CreateOperationController.generateOpCodeListItem()); +        lvActiveOperations.setOnMouseClicked( +                event -> { +                    if (event.getClickCount() == 2) { +                        if (lvActiveOperations.getSelectionModel().getSelectedItem() == null) { +                            return; +                        } +                        initOperation(lvActiveOperations.getSelectionModel().getSelectedItem()); +                    } +                }); +    } + +    private void updateFlowPane() { +        try { +            fpVehicles.getChildren().clear(); +            for (Vehicle vehicle : operation.vehicles()) { +                VehiclePaneController controller = VehiclePaneController.createVehiclePane(); +                controller.setData(vehicle, true, false); +                fpVehicles.getChildren().add(controller.getRootElement()); +            } + +            fpAdditional.getChildren().clear(); +            for (Vehicle vehicle : operationService.rankVehicles(operation.opCode())) { +                if (operation.vehicles().contains(vehicle)) continue; + +                VehiclePaneController controller = VehiclePaneController.createVehiclePane(); +                controller.setData(vehicle, true, true); +                controller.getBtnRequest().setOnAction(e -> requestVehicleClicked(controller)); +                fpAdditional.getChildren().add(controller.getRootElement()); +            } +        } catch (IOException | ServiceException e) { +            LOG.error("Error while updating list.", e); +            showServiceExceptionAlertAndWait("Error while updating list."); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation for Operation failed"); +            showValidationErrorAlertAndWait(e.getMessage()); +        } +    } + +    void initOperation(Operation operation) { +        fillActiveList(); +        this.operation = operation; +        lblCode.setText(operation.opCode()); +        Collection<String> vehicleNames = +                operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); +        String result = String.join(", ", vehicleNames); +        lblChosenVehicles.setText(result.toString()); +        lblAdditionalInfo.setText(operation.additionalInfo()); +        lblAddress.setText(operation.destination()); +        updateFlowPane(); +        operationDetailsAP.setVisible(true); +    } + +    private void fillActiveList() { +        try { +            lvActiveOperations.setItems( +                    FXCollections.observableArrayList( +                            operationService.list(EnumSet.of(Status.ACTIVE)))); +        } catch (ServiceException e) { +            LOG.error("ServiceException in fillActiveList(). ", e); +            showServiceExceptionAlertAndWait(e.getMessage()); +        } +    } + +    @FXML +    public void closeOperationClicked() { +        LOG.debug("Button \"Abschließen\" clicked."); +        try { +            operationService.complete(operation.id(), Status.COMPLETED); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in closeOperationClicked(). ", e); +            showAlertWithOkButtonAndWait(AlertType.ERROR, "Validierungsfehler", e.getMessage()); +            return; +        } catch (ServiceException e) { +            LOG.error("Exception in closeOperationClicked(). ", e); +            showServiceExceptionAlertAndWait(e.getMessage()); +            return; +        } +        showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); +        createOperationController.updateList(); +        closeWindow(); +    } + +    public void cancelOperationClicked() { +        LOG.debug("Button \"Stornieren\" clicked."); +        try { +            operationService.complete(operation.id(), Status.CANCELLED); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation error in cancelOperationClicked(). ", e); +            showValidationErrorAlertAndWait(e.getMessage()); +            return; +        } catch (ServiceException e) { +            LOG.error("Exception in cancelOperationClicked(). ", e); +            showServiceExceptionAlertAndWait(e.getMessage()); +            return; +        } +        showSuccessAlertAndWait("Der Einsatz wurde erfolgreich aktualisiert"); +        createOperationController.updateList(); +        closeWindow(); +    } + +    private void requestVehicleClicked(VehiclePaneController v) { +        LOG.debug("Button \"Nachfordern\" clicked."); + +        Vehicle vehicle = null; + +        try { +            vehicle = v.getData(); +            if (vehicle == null) return; + +            operationService.requestVehicles(operation.id(), Set.of(vehicle.id())); +        } catch (ServiceException e) { +            LOG.error("ServiceException in requestVehicleClicked()", e); +            showServiceExceptionAlertAndWait(e.getMessage()); +            return; +        } catch (InvalidVehicleException e) { +            LOG.debug("Validation of Vehicle failed"); +            showValidationErrorAlertAndWait(e.getMessage()); +        } catch (InvalidOperationException e) { +            LOG.debug("Validation of Operation failed"); +            showValidationErrorAlertAndWait(e.getMessage()); +        } +        showSuccessAlertAndWait("Das Fahrzeug wurde erfolgreich angefordert"); +        operation.vehicles().add(vehicle); +        updateFlowPane(); +    } + +    public void closeWindow() { +        LOG.debug("Hyperlink \"Zurück\" clicked."); +        operationDetailsAP.setVisible(false); +        this.createOperationController.setVisible(true); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java new file mode 100644 index 0000000..17f0f55 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/OperationInArchiveController.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import java.io.IOException; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.util.Collection; +import java.util.Objects; +import java.util.stream.Collectors; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.text.Text; + +public class OperationInArchiveController { + +    @FXML private Text txtAddress; +    @FXML private Text txtVehicles; +    @FXML private Text txtDate; +    @FXML private Text txtOpCode; + +    static OperationInArchiveController create() throws IOException { +        FXMLLoader fxmlLoader = +                new FXMLLoader( +                        OperationInArchiveController.class.getResource( +                                "/fxml/OperationInArchive.fxml")); +        Node root = fxmlLoader.load(); +        OperationInArchiveController result = fxmlLoader.getController(); +        result.rootElement = root; + +        return result; +    } + +    public Node getRoot() { +        return rootElement; +    } + +    private Node rootElement; + +    public void set(Operation operation) { +        txtAddress.setText(operation.destination()); +        String date = "am "; +        if (operation.created() != null) { +            LocalDateTime myDateTime = +                    LocalDateTime.ofInstant( +                            Objects.requireNonNull(operation.created()), ZoneOffset.UTC); +            date += +                    myDateTime.getDayOfMonth() +                            + "." +                            + myDateTime.getMonth().getValue() +                            + "." +                            + myDateTime.getYear(); +            txtDate.setText(date); +        } else { +            txtDate.setText("---"); +        } +        txtOpCode.setText(operation.opCode()); +        Collection<String> elements = +                operation.vehicles().stream().map(Vehicle::name).collect(Collectors.toList()); +        String result = String.join(", ", elements); + +        txtVehicles.setText(result); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java new file mode 100644 index 0000000..c445a12 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationWindowController.java @@ -0,0 +1,289 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showServiceExceptionAlertAndWait; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.showValidationErrorAlertAndWait; + +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 at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.io.IOException; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.OffsetDateTime; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.geometry.Insets; +import javafx.scene.Node; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseButton; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.VBox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; + +@Controller +public class RegistrationWindowController { + +    private static final Logger LOG = LoggerFactory.getLogger(RegistrationWindowController.class); + +    private final EmployeeService employeeService; +    private final VehicleService vehicleService; +    private final RegistrationService registrationService; +    private final CreateOperationController createOperationController; +    private final SpringFXMLLoader fxmlLoader; + +    @FXML private GridPane root; +    @FXML private VBox vbVehicles; +    @FXML private ScrollPane listEmployee; +    @FXML private ChoiceBox<Integer> cbStart; +    @FXML private ChoiceBox<Integer> cbEnd; +    @FXML private Label lVehicles; +    @FXML private Label lEmployees; +    @FXML private TextField tfVehicleSearch; +    @FXML private TextField tfEmployeeSearch; +    private EmployeeListController employeeListController; + +    private Vehicle chosenVehicle; +    private List<Employee> chosenEmployees = new LinkedList<>(); + +    public RegistrationWindowController( +            EmployeeService employeeService, +            VehicleService vehicleService, +            CreateOperationController createOperationController, +            RegistrationService registrationService, +            SpringFXMLLoader fxmlLoader) { +        this.employeeService = employeeService; +        this.vehicleService = vehicleService; +        this.createOperationController = createOperationController; +        this.registrationService = registrationService; +        this.fxmlLoader = fxmlLoader; +    } + +    @FXML +    private void initialize() throws IOException { +        employeeListController = EmployeeListController.createEmployeeListController(fxmlLoader); +        employeeListController.setListItemMargins(new Insets(10, 6, 0, 6)); +        //        listEmployee. .getChildren().add(employeeListController.getRootElement()); +        Node emplList = employeeListController.getRootElement(); +        //        emplList.(360); +        listEmployee.setContent(emplList); + +        ObservableList<Integer> 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); +        setDefaultTime(); +        // reset(); +    } + +    private void setDefaultTime() { +        cbStart.setValue(LocalDateTime.now().getHour()); +        cbEnd.setValue((LocalDateTime.now().getHour() + 4) % 24); +    } + +    private void updateEmplList() { +        employeeListController.deselectAllEmployees(); + +        try { +            Set<Employee> employees = +                    employeeService +                            .list() +                            .stream() +                            .filter( +                                    e -> +                                            e.name() +                                                    .toLowerCase() +                                                    .contains( +                                                            tfEmployeeSearch +                                                                    .getText() +                                                                    .toLowerCase())) +                            .collect(Collectors.toCollection(HashSet::new)); +            employeeListController.setData( +                    employees, +                    selection -> { +                        if (selection == null) { +                            return; +                        } else if (chosenEmployees.contains(selection)) { +                            chosenEmployees.remove(selection); +                        } else { +                            chosenEmployees.add(selection); +                        } + +                        StringBuilder text = new StringBuilder(); +                        boolean first = true; +                        for (Employee employee : chosenEmployees) { +                            if (!first) { +                                text.append(", "); +                            } +                            text.append(employee.name()); +                            first = false; +                        } +                        lEmployees.setText(text.toString()); +                    }, +                    contr -> contr.setSelected(chosenEmployees.contains(contr.getEmployee()))); + +            employees.forEach( +                    e -> { +                        if (chosenEmployees.contains(e)) employeeListController.selectEmployee(e); +                    }); +        } catch (ServiceException e) { +            LOG.error("ServiceException in updateEmplList(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Auflisten des Personals ist ein Fehler aufgetreten."); +        } +    } + +    private void updateVehList() { +        vbVehicles.getChildren().clear(); + +        try { +            Set<Vehicle> vehicles = vehicleService.list(EnumSet.of(Status.ABGEMELDET)); + +            boolean anyMatch = false; + +            for (Vehicle vehicle : vehicles) { +                if (!vehicle.name().toLowerCase().contains(tfVehicleSearch.getText().toLowerCase())) +                    continue; + +                anyMatch = true; + +                VehiclePaneController vp = VehiclePaneController.createVehiclePane(); +                vp.setData(vehicle, false, false); +                vbVehicles.getChildren().add(vp.getRootElement()); + +                vp.getRootElement() +                        .setOnMouseClicked( +                                event -> { +                                    if (event.getButton() == MouseButton.PRIMARY) { +                                        chosenVehicle = vehicle; +                                        lVehicles.setText(chosenVehicle.name()); +                                        updateVehList(); +                                    } +                                }); +                if (chosenVehicle != null && chosenVehicle.id() == vehicle.id()) +                    vp.setSelected(true); +            } + +            if (!anyMatch) { +                // Kind of ugly, but best way to get the size of a VehiclePane +                VehiclePaneController vp = VehiclePaneController.createVehiclePane(); +                vp.getRootElement().setVisible(false); +                vbVehicles.getChildren().add(vp.getRootElement()); +            } +        } catch (ServiceException e) { +            LOG.error("ServiceException in updateVehList(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Auflisten der Fahrzeuge ist ein Fehler aufgetreten"); +        } catch (IOException e) { +            LOG.error("IOException in updateVehList(). ", e); +            showServiceExceptionAlertAndWait("Beim Laden der Fahrzeuge ist ein Fehler aufgetreten"); +        } +    } + +    public void cancel() { +        LOG.debug("Hyperlink \"schließen\" clicked"); +        this.setVisible(false); +        createOperationController.setVisible(true); +    } + +    private void reset() { +        chosenEmployees.clear(); +        chosenVehicle = null; +        tfEmployeeSearch.setText(""); +        tfVehicleSearch.setText(""); +        lEmployees.setText("-"); +        lVehicles.setText("-"); +        updateVehList(); +        updateEmplList(); +        setDefaultTime(); +    } + +    public void create() { +        LOG.debug("Button \"ERSTELLEN\" clicked"); + +        Set<Registration> registrations = new HashSet<>(); +        try { +            if (chosenVehicle == null) { +                throw new InvalidVehicleException("no Vehicle"); +            } + +            LocalDateTime startDate = +                    LocalDateTime.of( +                            LocalDate.now(), +                            LocalTime.of( +                                    cbStart.getValue(), +                                    LocalDateTime.now().getMinute(), +                                    LocalDateTime.now().getSecond())); + +            LocalDateTime endDate = +                    LocalDateTime.of( +                            LocalDate.now() +                                    .plusDays(cbStart.getValue() >= cbEnd.getValue() ? 1 : 0), +                            LocalTime.of(cbEnd.getValue(), 0)); + +            for (Employee employee : chosenEmployees) { +                registrations.add( +                        Registration.builder() +                                .id(chosenVehicle.id()) +                                .employee(employee) +                                .start(startDate.toInstant(OffsetDateTime.now().getOffset())) +                                .end(endDate.toInstant(OffsetDateTime.now().getOffset())) +                                .build()); +            } + +            registrationService.add(chosenVehicle.id(), registrations); +            chosenEmployees.clear(); +            // ((Stage) lVehicles.getScene().getWindow()).close(); +            this.setVisible(false); +            createOperationController.setVisible(true); +            createOperationController.updateList(); +            // reset(); +        } catch (InvalidVehicleException e) { +            LOG.debug("Validation of Vehicle in Registration failed."); +            showValidationErrorAlertAndWait(e.getMessage()); +        } catch (ServiceException e) { +            LOG.error("ServiceException in create(). ", e); +            showServiceExceptionAlertAndWait( +                    "Beim Erstellen der Anmeldung ist ein Fehler aufgetreten."); +        } catch (InvalidRegistrationException e) { +            LOG.debug("Validation of Registration failed."); +            showValidationErrorAlertAndWait(e.getMessage()); +        } +    } + +    public void setVisible(boolean b) { +        if (b) reset(); +        root.setVisible(b); +    } + +    public void tfVehicleSearch_TextChanged(KeyEvent keyEvent) { +        updateVehList(); +    } + +    public void tfEmployeeSearch_TextChanged(KeyEvent keyEvent) { +        updateEmplList(); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java index 6c0932b..66b45d2 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/VehiclePaneController.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/VehiclePaneController.java @@ -1,8 +1,9 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; -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 at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status;  import java.io.IOException;  import java.time.Instant;  import java.util.List; @@ -10,15 +11,13 @@ import java.util.Optional;  import javafx.fxml.FXML;  import javafx.fxml.FXMLLoader;  import javafx.scene.Node; +import javafx.scene.control.Button; +import javafx.scene.control.Label;  import javafx.scene.image.Image;  import javafx.scene.image.ImageView;  import javafx.scene.text.Text; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class VehiclePaneController { - -    private static Logger LOG = LoggerFactory.getLogger(VehiclePaneController.class); +public class VehiclePaneController extends CustomListItemController {      public static VehiclePaneController createVehiclePane() throws IOException {          FXMLLoader fxmlLoader = @@ -30,6 +29,7 @@ public class VehiclePaneController {          return result;      } +    @FXML private Label txtStatus;      @FXML private Text txtType;      @FXML private Text txtNumber;      @FXML private ImageView ivNEF; @@ -37,14 +37,10 @@ public class VehiclePaneController {      @FXML private ImageView ivQualification;      @FXML private Text txtQualification;      @FXML private Text txtRooftype; +    @FXML private Button btnRequest; -    private Node rootElement;      private Vehicle data; -    public Node getRootElement() { -        return rootElement; -    } -      public Vehicle getData() {          return data;      } @@ -53,10 +49,10 @@ public class VehiclePaneController {       * * 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. +     * @param showStatusInfo If true, the highest qualification of the vehicle's active registration +     *     and the vehicle's status will be shown.       */ -    public void setData(Vehicle vehicle, boolean showQualification) { +    public void setData(Vehicle vehicle, boolean showStatusInfo, boolean showRequestVehicle) {          txtType.setText(vehicle.type().name());          String constrType = vehicle.constructionType().name();          txtRooftype.setText( @@ -69,7 +65,22 @@ public class VehiclePaneController {              ivNEF.setImage(new Image("images/NotNEF.png"));              txtNEF.setText("keine NEF-Halterung");          } -        if (showQualification) { + +        if (showRequestVehicle) { +            btnRequest.setVisible(true); +            btnRequest.setManaged(true); +        } else { +            btnRequest.setVisible(false); +            btnRequest.setManaged(false); +        } + +        if (showStatusInfo) { +            txtStatus.setText(vehicle.status().name()); +            if (vehicle.status() == Status.FREI_FUNK || vehicle.status() == Status.FREI_WACHE) { +                txtStatus.getStyleClass().add("bg-status-green"); +            } else { +                txtStatus.getStyleClass().add("bg-status-orange"); +            }              Instant now = Instant.now();              List<Registration> regs = vehicle.registrations(); @@ -94,20 +105,14 @@ public class VehiclePaneController {              txtQualification.setManaged(false);              ivQualification.setVisible(false);              ivQualification.setManaged(false); + +            txtStatus.setVisible(false);          }          this.data = vehicle;      } -    public void setSelected(boolean selected) { -        rootElement.getStyleClass().clear(); - -        if (selected) { -            rootElement.getStyleClass().add("bg-yellow"); -            rootElement.getStyleClass().add("shadowed"); -        } else { -            rootElement.getStyleClass().add("bg-white"); -            rootElement.getStyleClass().add("shadowed"); -        } +    public Button getBtnRequest() { +        return btnRequest;      }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java index 539a8e5..675e951 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAO.java @@ -1,8 +1,8 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee;  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.missioncontrol.dto.Employee;  import java.util.Set;  public interface EmployeeDAO { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java new file mode 100644 index 0000000..32dd6d2 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDatabaseDAO.java @@ -0,0 +1,144 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +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.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.LocalDate; +import java.util.HashSet; +import java.util.Set; +import org.springframework.stereotype.Repository; + +@Repository +public class EmployeeDatabaseDAO implements EmployeeDAO { + +    private JDBCConnectionManager jdbcConnectionManager; + +    public EmployeeDatabaseDAO(JDBCConnectionManager jdbcConnectionManager) { +        this.jdbcConnectionManager = jdbcConnectionManager; +    } + +    private long createEmployeeVersion(Connection con, Employee e) +            throws PersistenceException, SQLException { +        String sql = +                "INSERT INTO EmployeeVersion(name, birthday, educationLevel, isDriver, isPilot) " +                        + "VALUES(?, ?, ?, ?, ?)"; + +        try (PreparedStatement pstmt = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { +            pstmt.setString(1, e.name()); +            pstmt.setObject(2, e.birthday()); +            pstmt.setInt(3, e.educationLevel().ordinal()); +            pstmt.setBoolean(4, e.isDriver()); +            pstmt.setBoolean(5, e.isPilot()); +            pstmt.executeUpdate(); + +            try (ResultSet rs = pstmt.getGeneratedKeys()) { +                if (!rs.next()) throw new PersistenceException("Failed to insert EmployeeVersion"); + +                return rs.getLong(1); +            } +        } +    } + +    @Override +    public long add(Employee employee) throws PersistenceException { +        String sql = "INSERT INTO Employee(version) VALUES(?)"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            con.setAutoCommit(false); + +            long versionId = createEmployeeVersion(con, employee); + +            try (PreparedStatement pstmt = +                    con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { +                pstmt.setLong(1, versionId); +                pstmt.executeUpdate(); + +                try (ResultSet rs = pstmt.getGeneratedKeys()) { +                    if (!rs.next()) { +                        con.rollback(); +                        throw new PersistenceException("Failed to insert Employee"); +                    } + +                    con.commit(); +                    return rs.getLong(1); +                } +            } +        } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection(); +            throw new PersistenceException(e); +        } +    } + +    @Override +    public void update(Employee employee) throws ElementNotFoundException, PersistenceException { +        String sql = "UPDATE Employee SET version = ? WHERE id = ?"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            con.setAutoCommit(false); + +            long versionId = createEmployeeVersion(con, employee); + +            try (PreparedStatement pstmt = con.prepareStatement(sql)) { +                pstmt.setLong(1, versionId); +                pstmt.setLong(2, employee.id()); + +                if (pstmt.executeUpdate() != 1) { +                    con.rollback(); +                    throw new ElementNotFoundException("No such employeeId exists"); +                } +            } + +            con.commit(); +        } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection(); +            throw new PersistenceException(e); +        } +    } + +    @Override +    public Set<Employee> list() throws PersistenceException { +        String sql = +                "SELECT emp.id, v.name, v.birthday, v.educationLevel, v.isDriver, v.isPilot " +                        + "FROM employee emp " +                        + "JOIN EmployeeVersion v ON v.id = emp.version"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            Set<Employee> employees = new HashSet<>(); + +            try (PreparedStatement pstmt = con.prepareStatement(sql)) { +                try (ResultSet rs = pstmt.executeQuery()) { +                    while (rs.next()) { +                        employees.add( +                                Employee.builder() +                                        .id(rs.getLong(1)) +                                        .name(rs.getString(2)) +                                        .birthday(rs.getObject(3, LocalDate.class)) +                                        .educationLevel(EducationLevel.valueOf(rs.getString(4))) +                                        .isDriver(rs.getBoolean(5)) +                                        .isPilot(rs.getBoolean(6)) +                                        .build()); +                    } +                } +            } + +            return employees; +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } + +    @Override +    public void remove(long id) throws ElementNotFoundException, PersistenceException { +        throw new UnsupportedOperationException(); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java index d82f768..e496898 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAO.java @@ -1,9 +1,9 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -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.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status;  import java.util.EnumSet;  import java.util.Set; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java index 0a465f2..238a2a8 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDatabaseDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDatabaseDAO.java @@ -1,20 +1,22 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -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.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager;  import java.sql.Connection;  import java.sql.PreparedStatement;  import java.sql.ResultSet;  import java.sql.SQLException; -import java.sql.Timestamp; +import java.time.OffsetDateTime; +import java.time.ZoneId;  import java.util.EnumSet;  import java.util.HashSet; -import java.util.Objects;  import java.util.Set;  import java.util.stream.Collectors;  import org.springframework.lang.NonNull; @@ -25,11 +27,15 @@ public class OperationDatabaseDAO implements OperationDAO {      private JDBCConnectionManager jdbcConnectionManager;      private VehicleDAO vehicleDAO; +    private RegistrationDatabaseDAO registrationDAO;      public OperationDatabaseDAO( -            JDBCConnectionManager jdbcConnectionManager, VehicleDAO vehicleDAO) { +            JDBCConnectionManager jdbcConnectionManager, +            VehicleDAO vehicleDAO, +            RegistrationDatabaseDAO registrationDAO) {          this.jdbcConnectionManager = jdbcConnectionManager;          this.vehicleDAO = vehicleDAO; +        this.registrationDAO = registrationDAO;      }      @Override @@ -37,7 +43,6 @@ public class OperationDatabaseDAO implements OperationDAO {          String sql =                  "INSERT INTO Operation(opCode, severity, created, destination, additionalInfo,"                          + "            status) VALUES (?, ?, ?, ?, ?, ?)"; -        String sql2 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)";          long operationId;          try { @@ -46,7 +51,7 @@ public class OperationDatabaseDAO implements OperationDAO {              try (PreparedStatement pstmt = con.prepareStatement(sql)) {                  pstmt.setString(1, o.opCode());                  pstmt.setInt(2, o.severity().ordinal()); -                pstmt.setTimestamp(3, Timestamp.from(Objects.requireNonNull(o.created()))); +                pstmt.setObject(3, OffsetDateTime.ofInstant(o.created(), ZoneId.systemDefault()));                  pstmt.setString(4, o.destination());                  pstmt.setString(5, o.additionalInfo());                  pstmt.setInt(6, o.status().ordinal()); @@ -59,20 +64,11 @@ public class OperationDatabaseDAO implements OperationDAO {                  }              } -            try (PreparedStatement pstmt = con.prepareStatement(sql2)) { -                pstmt.setLong(2, operationId); - -                for (long id : (Iterable<Long>) o.vehicles().stream().map(Vehicle::id)::iterator) { -                    pstmt.setLong(1, id); -                    pstmt.addBatch(); -                } - -                pstmt.executeBatch(); -            } +            createVehicleOperation(con, operationId, o.vehicles());              con.commit(); -            con.setAutoCommit(true);              return operationId;          } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection();              throw new PersistenceException(e);          }      } @@ -84,7 +80,6 @@ public class OperationDatabaseDAO implements OperationDAO {                  "UPDATE Operation SET opCode = ?, severity = ?, destination = ?,"                          + " additionalInfo = ?, status = ? WHERE id = ?";          String sql2 = "DELETE FROM VehicleOperation WHERE operationId = ?"; -        String sql3 = "INSERT INTO VehicleOperation(vehicleId, operationId) VALUES (?, ?)";          try {              Connection con = jdbcConnectionManager.getConnection(); @@ -106,23 +101,39 @@ public class OperationDatabaseDAO implements OperationDAO {                  pstmt.executeUpdate();              } -            try (PreparedStatement pstmt = con.prepareStatement(sql3)) { -                pstmt.setLong(2, o.id()); - -                for (long id : (Iterable<Long>) o.vehicles().stream().map(Vehicle::id)::iterator) { -                    pstmt.setLong(1, id); -                    pstmt.addBatch(); -                } - -                pstmt.executeBatch(); -            } +            createVehicleOperation(con, o.id(), o.vehicles());              con.commit(); -            con.setAutoCommit(true);          } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection();              throw new PersistenceException(e);          }      } +    private void createVehicleOperation(Connection con, long operationId, Set<Vehicle> vehicles) +            throws SQLException { +        String sql = +                "INSERT INTO VehicleOperation(vehicleId, operationId)" +                        + " SELECT version, ? FROM Vehicle WHERE id = ?"; +        String sqlUpdateVehicleStatus = +                "UPDATE Vehicle SET status = 'ZUM_BERUFUNGSORT' WHERE id = ?"; + +        try (PreparedStatement pstmt = con.prepareStatement(sql); +                PreparedStatement stmtUpdateVehicleStatus = +                        con.prepareStatement(sqlUpdateVehicleStatus)) { +            pstmt.setLong(1, operationId); + +            for (long id : (Iterable<Long>) vehicles.stream().map(Vehicle::id)::iterator) { +                pstmt.setLong(2, id); +                stmtUpdateVehicleStatus.setLong(1, id); +                pstmt.addBatch(); +                stmtUpdateVehicleStatus.addBatch(); +            } + +            pstmt.executeBatch(); +            stmtUpdateVehicleStatus.executeBatch(); +        } +    } +      @Override      public Operation get(long operationId) throws ElementNotFoundException, PersistenceException {          String sql = "Select * from operation where id = ?"; @@ -150,11 +161,14 @@ public class OperationDatabaseDAO implements OperationDAO {          // This hack exists because H2 currently has a bug that prevents IN (?) with an array of          // ids, i.e. pstmt.setArray(1, con.createArrayOf("INT", intarray) from working. See          // commented code below. + +        // SELECT * FROM Operation WHERE status IN ('COMPLETED', 'CANCELLED') is BUGGED on H2! +        // for this reason we use the ordinal values instead          String str =                  statuses.stream() -                        .map(Enum::name) -                        .map(s -> "'" + s + "'") +                        .map(e -> Integer.toString(e.ordinal()))                          .collect(Collectors.joining(",")); +          String sql = "SELECT * FROM Operation WHERE status IN (" + str + ")";          Set<Operation> operations = new HashSet<>(); @@ -185,14 +199,19 @@ public class OperationDatabaseDAO implements OperationDAO {                  .severity(Severity.valueOf(rs.getString("severity")))                  .status(Status.valueOf(rs.getString("status")))                  .vehicles(getVehiclesFromOperationId(operationId)) -                .created(rs.getTimestamp("created").toInstant()) +                .created((rs.getObject("created", OffsetDateTime.class)).toInstant())                  .destination(rs.getString("destination"))                  .additionalInfo(rs.getString("additionalInfo"))                  .build();      }      private Set<Vehicle> getVehiclesFromOperationId(long operationId) throws PersistenceException { -        String sql = "SELECT vehicleId FROM VehicleOperation WHERE operationId = ?"; +        /*String sql = +        "SELECT id FROM Vehicle WHERE version IN" +                + " (SELECT vehicleId FROM VehicleOperation WHERE operationId = ?)";*/ +        String sql = +                "SELECT vv.* FROM VehicleOperation vo JOIN VehicleVersion vv ON vv.id = vo.vehicleId WHERE operationId = ?"; +          Set<Vehicle> vehicles = new HashSet<>();          try { @@ -203,7 +222,7 @@ public class OperationDatabaseDAO implements OperationDAO {                  try (ResultSet rs = pstmt.getResultSet()) {                      while (rs.next()) { -                        vehicles.add(vehicleDAO.get(rs.getLong("vehicleId"))); +                        vehicles.add(vehicleFromRS(rs));                      }                  }              } @@ -215,4 +234,20 @@ public class OperationDatabaseDAO implements OperationDAO {          return vehicles;      } + +    private Vehicle vehicleFromRS(ResultSet rs) +            throws SQLException, PersistenceException, ElementNotFoundException { +        String name = rs.getString("VehicleVersion.name"); +        long vehicleId = Long.parseLong(name.split("-")[1]); +        return Vehicle.builder() +                .id(vehicleId) +                .name(rs.getString("VehicleVersion.name")) +                .constructionType( +                        ConstructionType.values()[rs.getInt("VehicleVersion.constructionType")]) +                .type(VehicleType.valueOf(rs.getString("VehicleVersion.type"))) +                .status(vehicleDAO.get(vehicleId).status()) +                .hasNef(rs.getBoolean("VehicleVersion.hasNef")) +                .registrations(registrationDAO.list(rs.getLong("VehicleVersion.id"))) +                .build(); +    }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java index 36b6f1b..4a35f86 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAO.java @@ -1,8 +1,8 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration;  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.missioncontrol.dto.Registration;  import java.util.Set;  public interface RegistrationDAO { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java new file mode 100644 index 0000000..b624056 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDatabaseDAO.java @@ -0,0 +1,189 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +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.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.time.Instant; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +@Repository +public class RegistrationDatabaseDAO implements RegistrationDAO { + +    private JDBCConnectionManager jdbcConnectionManager; +    private EmployeeDAO employeePersistence; + +    @Autowired +    public RegistrationDatabaseDAO( +            JDBCConnectionManager jdbcConnectionManager, EmployeeDAO employeePersistence) { +        this.jdbcConnectionManager = jdbcConnectionManager; +        this.employeePersistence = employeePersistence; +    } + +    private long getVehicleVersionId(long vehicleId) throws PersistenceException { +        String sqlGetVehicleVersionId = "SELECT * FROM vehicle WHERE id = ?"; +        try (PreparedStatement stmt = +                jdbcConnectionManager.getConnection().prepareStatement(sqlGetVehicleVersionId)) { +            stmt.setLong(1, vehicleId); +            try (ResultSet rs = stmt.executeQuery()) { +                if (rs.next()) { +                    return rs.getLong("version"); +                } else { +                    throw new PersistenceException("vehicle id not found"); +                } +            } +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } + +    private long getEmployeeVersionId(long employeeId) throws PersistenceException { +        String sqlGetEmployeeVersionId = "SELECT * FROM employee WHERE id = ?"; +        try (PreparedStatement stmt = +                jdbcConnectionManager.getConnection().prepareStatement(sqlGetEmployeeVersionId)) { +            stmt.setLong(1, employeeId); +            try (ResultSet rs = stmt.executeQuery()) { +                if (rs.next()) { +                    return rs.getLong("version"); +                } else { +                    throw new PersistenceException("employee id not found"); +                } +            } +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } + +    @Override +    public Set<Long> add(long vehicleId, Set<Registration> registrations) +            throws PersistenceException { +        String sql = +                "INSERT INTO Registration (vehicleId, employeeId, start, end, active) VALUES (?,?,?,?,?)"; +        String sql2 = "UPDATE Vehicle SET status = 'FREI_WACHE' WHERE id = ?;"; + +        Set<Long> vehicleIds = new HashSet<>(); + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            con.setAutoCommit(false); + +            try (PreparedStatement pstmt = +                    con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { + +                // vehicleId is a Vehicle.id as it comes from GUI => fetch VehicleVersion.id +                pstmt.setLong(1, getVehicleVersionId(vehicleId)); + +                for (Registration r : registrations) { +                    pstmt.setLong(2, getEmployeeVersionId(r.employee().id())); +                    pstmt.setObject(3, OffsetDateTime.ofInstant(r.start(), ZoneId.systemDefault())); +                    pstmt.setObject(4, OffsetDateTime.ofInstant(r.end(), ZoneId.systemDefault())); +                    pstmt.setBoolean(5, true); +                    pstmt.addBatch(); +                } + +                pstmt.executeBatch(); + +                try (ResultSet rs = pstmt.getGeneratedKeys()) { +                    while (rs.next()) vehicleIds.add(rs.getLong(1)); +                } +            } + +            try (PreparedStatement pstmt = con.prepareStatement(sql2)) { +                pstmt.setLong(1, vehicleId); +                if (pstmt.executeUpdate() != 1) { +                    con.rollback(); +                    throw new PersistenceException("Failed to persist registration"); +                } +            } + +            con.commit(); +            return vehicleIds; +        } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection(); +            throw new PersistenceException(e); +        } +    } + +    @Override +    public void remove(long id) throws ElementNotFoundException, PersistenceException { +        String sql = "UPDATE Registration SET active = 0, end = ? WHERE id = ?"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); + +            try (PreparedStatement pstmt = con.prepareStatement(sql)) { +                pstmt.setObject(1, OffsetDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())); +                pstmt.setLong(2, id); + +                if (pstmt.executeUpdate() != 1) +                    throw new ElementNotFoundException("No such registrationId exists"); +            } + +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } + +    protected List<Registration> list(long vehicleId) throws PersistenceException { + +        String sql = +                "SELECT * FROM Registration r " +                        + "JOIN EmployeeVersion ev ON ev.id = r.employeeId " +                        + "JOIN VehicleVersion vv ON vv.id = r.vehicleId " +                        + "WHERE r.vehicleId = ?"; + +        try (PreparedStatement stmt = jdbcConnectionManager.getConnection().prepareStatement(sql)) { + +            List<Registration> registrationList = new ArrayList<>(); +            stmt.setLong(1, vehicleId); // is vehicle version id! +            ResultSet rs = stmt.executeQuery(); +            while (rs.next()) { + +                Employee employee = +                        Employee.builder() +                                .id(rs.getLong("EmployeeVersion.id")) +                                .name(rs.getString("EmployeeVersion.name")) +                                .birthday(rs.getObject("EmployeeVersion.birthday", LocalDate.class)) +                                .educationLevel( +                                        EducationLevel.valueOf( +                                                rs.getString("EmployeeVersion.educationLevel"))) +                                .isDriver(rs.getBoolean("EmployeeVersion.isDriver")) +                                .isPilot(rs.getBoolean("EmployeeVersion.isPilot")) +                                .build(); + +                Registration registration = +                        Registration.builder() +                                .id(rs.getLong("Registration.id")) +                                .start( +                                        (rs.getObject("Registration.start", OffsetDateTime.class)) +                                                .toInstant()) +                                .end( +                                        (rs.getObject("Registration.end", OffsetDateTime.class)) +                                                .toInstant()) +                                .employee(employee) +                                .build(); + +                registrationList.add(registration); +            } + +            return registrationList; +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java index 5782fd9..46d1853 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAO.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAO.java @@ -1,8 +1,8 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle;  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.missioncontrol.dto.Vehicle;  import java.util.Set;  public interface VehicleDAO { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java new file mode 100644 index 0000000..8cef65e --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDatabaseDAO.java @@ -0,0 +1,211 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +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.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType; +import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.HashSet; +import java.util.Set; +import org.springframework.stereotype.Repository; + +@Repository +public class VehicleDatabaseDAO implements VehicleDAO { + +    private final JDBCConnectionManager jdbcConnectionManager; +    private RegistrationDatabaseDAO registrationDatabaseDao; + +    public VehicleDatabaseDAO( +            JDBCConnectionManager j, RegistrationDatabaseDAO registrationDatabaseDao) { +        jdbcConnectionManager = j; +        this.registrationDatabaseDao = registrationDatabaseDao; +    } + +    @Override +    public long add(Vehicle v) throws PersistenceException { +        String sql = +                "INSERT INTO VehicleVersion (name,hasNef,constructionType,type) VALUES (?,?,?,?)"; +        String sql2 = "INSERT INTO Vehicle (version,status) VALUES (?,?)"; +        String sql3 = "UPDATE VehicleVersion SET name=? WHERE id=?"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            con.setAutoCommit(false); +            String name = ""; +            long version, id; + +            try (PreparedStatement pstmt = +                    con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS)) { +                pstmt.setString(1, name); +                pstmt.setBoolean(2, v.hasNef()); +                pstmt.setInt(3, v.constructionType().ordinal()); +                pstmt.setString(4, v.type().name()); +                pstmt.executeUpdate(); + +                try (ResultSet rs = pstmt.getGeneratedKeys()) { +                    if (!rs.next()) +                        throw new PersistenceException("Failed to insert into VehicleVersion"); + +                    version = rs.getLong(1); +                } +            } + +            try (PreparedStatement pstmt = +                    con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { +                pstmt.setLong(1, version); +                pstmt.setInt(2, Status.ABGEMELDET.ordinal()); +                pstmt.executeUpdate(); + +                try (ResultSet rs = pstmt.getGeneratedKeys()) { +                    if (!rs.next()) { +                        con.rollback(); +                        throw new PersistenceException("Failed to insert into Vehicle"); +                    } + +                    id = rs.getLong(1); +                } + +                name = v.type().name() + "-" + id; +            } + +            try (PreparedStatement pstmt = con.prepareStatement(sql3)) { +                pstmt.setString(1, name); +                pstmt.setLong(2, version); + +                if (pstmt.executeUpdate() != 1) { +                    con.rollback(); +                    throw new PersistenceException("Failed to update VehicleVersion"); +                } +            } + +            con.commit(); +            return id; +        } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection(); +            throw new PersistenceException(e); +        } +    } + +    @Override +    public void update(Vehicle v) throws ElementNotFoundException, PersistenceException { +        String sql = "SELECT version FROM Vehicle WHERE id = ?"; +        String sql2 = +                "MERGE INTO VehicleVersion(name, constructionType, type, hasNef)" +                        + " KEY(name, constructionType, type, hasNef) VALUES(?, ?, ?, ?)"; +        String sql3 = "UPDATE Vehicle SET version = ?, status = ? WHERE id = ?"; + +        long versionId; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            con.setAutoCommit(false); +            try (PreparedStatement pstmt = con.prepareStatement(sql)) { +                pstmt.setLong(1, v.id()); + +                try (ResultSet rs = pstmt.executeQuery()) { +                    if (!rs.next()) throw new ElementNotFoundException("No such vehicleId exists"); + +                    versionId = rs.getLong(1); +                } +            } + +            try (PreparedStatement pstmt = +                    con.prepareStatement(sql2, Statement.RETURN_GENERATED_KEYS)) { +                pstmt.setString(1, v.type().name() + "-" + v.id()); +                pstmt.setString(2, v.constructionType().name()); +                pstmt.setString(3, v.type().name()); +                pstmt.setBoolean(4, v.hasNef()); +                pstmt.executeUpdate(); + +                try (ResultSet rs = pstmt.getGeneratedKeys()) { +                    if (rs.next()) { +                        // version changed, update it +                        versionId = rs.getLong(1); +                    } +                } +            } + +            try (PreparedStatement pstmt = con.prepareStatement(sql3)) { +                pstmt.setLong(1, versionId); +                pstmt.setString(2, v.status().name()); +                pstmt.setLong(3, v.id()); +                pstmt.executeUpdate(); +            } + +            con.commit(); +        } catch (SQLException e) { +            jdbcConnectionManager.rollbackConnection(); +            throw new PersistenceException(e); +        } +    } + +    @Override +    public Set<Vehicle> list() throws PersistenceException { +        Set<Vehicle> result = new HashSet<>(); + +        String sql = +                "Select * from VehicleVersion, Vehicle where VehicleVersion.id=Vehicle.version"; + +        try (PreparedStatement pstmt = +                jdbcConnectionManager.getConnection().prepareStatement(sql)) { +            pstmt.executeQuery(); +            try (ResultSet rs = pstmt.getResultSet()) { +                while (rs.next()) { +                    result.add(vehicleFromRS(rs)); +                } +            } +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +        return result; +    } + +    @Override +    public Vehicle get(long id) throws ElementNotFoundException, PersistenceException { +        String sql = +                "SELECT *" +                        + " FROM Vehicle a" +                        + " INNER JOIN VehicleVersion b" +                        + " ON version = b.id" +                        + " WHERE a.id = ?"; + +        try { +            Connection con = jdbcConnectionManager.getConnection(); +            try (PreparedStatement pstmt = con.prepareStatement(sql)) { +                pstmt.setLong(1, id); + +                try (ResultSet rs = pstmt.executeQuery()) { +                    if (!rs.first()) throw new ElementNotFoundException("No such vehicle exists"); + +                    return vehicleFromRS(rs); +                } +            } +        } catch (SQLException e) { +            throw new PersistenceException(e); +        } +    } + +    @Override +    public void remove(long id) throws ElementNotFoundException, PersistenceException { +        throw new UnsupportedOperationException(); +    } + +    private Vehicle vehicleFromRS(ResultSet rs) throws SQLException, PersistenceException { +        return Vehicle.builder() +                .id(rs.getLong("Vehicle.id")) +                .name(rs.getString("name")) +                .constructionType(ConstructionType.values()[rs.getInt("constructionType")]) +                .type(VehicleType.valueOf(rs.getString("type"))) +                .status(Status.values()[rs.getInt("status")]) +                .hasNef(rs.getBoolean("hasNef")) +                .registrations(registrationDatabaseDao.list(rs.getLong("Vehicle.version"))) +                .build(); +    } +} diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java index 583bf5b..f45550e 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Employee.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Employee.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto;  import com.google.auto.value.AutoValue;  import java.time.LocalDate; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java index d7fa9aa..b03fa04 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/EmployeeValidator.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/EmployeeValidator.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException; @@ -7,15 +7,15 @@ public class EmployeeValidator {      public static boolean validate(Employee employee) throws InvalidEmployeeException {          if (employee.name() == null || employee.name().trim().length() == 0) { -            throw new InvalidEmployeeException("name not set"); +            throw new InvalidEmployeeException("Name darf nicht leer sein!");          }          if (employee.birthday() == null) { -            throw new InvalidEmployeeException("birthday not set"); +            throw new InvalidEmployeeException("Geburtsdatum darf nicht leer sein!");          }          if (employee.educationLevel() == null) { -            throw new InvalidEmployeeException("educationLevel not set"); +            throw new InvalidEmployeeException("Ausbildungsgrad darf nicht leer sein!");          }          return true; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java index 3a97dc7..e119622 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Operation.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Operation.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto;  import com.google.auto.value.AutoValue;  import java.time.Instant; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java index 8551266..a12c038 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Registration.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Registration.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto;  import com.google.auto.value.AutoValue;  import java.time.Instant; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java index 610426c..a2cb8c1 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/RegistrationValidator.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/RegistrationValidator.java @@ -1,20 +1,16 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.VehicleType;  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.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import java.util.HashMap;  import java.util.LinkedList;  import java.util.List;  import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory;  public class RegistrationValidator { -    private static final Logger LOG = LoggerFactory.getLogger(RegistrationValidator.class); -      private RegistrationValidator() {}      public static void validate(Vehicle vehicle, Set<Registration> registrations) @@ -47,11 +43,10 @@ public class RegistrationValidator {          for (Registration registration : registrations) {              total++;              if (found.put(registration.employee().id(), false) != null) { -                LOG.info("Employee with ID {} was added twice", registration.employee().id());                  throw new InvalidRegistrationException( -                        "Person with the ID: " +                        "Person mit der ID: "                                  + registration.employee().id() -                                + " was added more than once!"); +                                + " wurde mehrmals hinzugefügt!");              }              if (registration.employee().isPilot()) {                  pilotIds.add(registration.employee().id()); @@ -71,7 +66,6 @@ public class RegistrationValidator {              }          }          if (total <= 0) { -            LOG.info("No employees were added");              throw new InvalidRegistrationException("Kein Personal ausgewählt!");          }          if (vehicle.type() == VehicleType.NAH) { @@ -83,10 +77,8 @@ public class RegistrationValidator {              3-4 Personen               */              if (total < 3) { -                LOG.info("Too few employees for NAH");                  throw new InvalidRegistrationException("Zu wenig Personal für NAH!");              } else if (total > 4) { -                LOG.info("Too many employees for NAH");                  throw new InvalidRegistrationException("Zu viel Personal für NAH!");              }              for (long pilot_id : pilotIds) { @@ -96,14 +88,12 @@ public class RegistrationValidator {                      found.put(na_id, true);                      for (long nfs_id : nfsIds) {                          if (found.get(nfs_id)) continue; -                        LOG.info("Valid combination found for NAH");                          return;                      }                      found.put(na_id, false);                  }                  found.put(pilot_id, false);              } -            LOG.info("No valid combination of employees found for NAH");              throw new InvalidRegistrationException(                      "Keine gültige Kombination von Personen für NAH!");          } else if (vehicle.type() == VehicleType.NEF) { @@ -113,10 +103,8 @@ public class RegistrationValidator {              1 NA               */              if (total < 2) { -                LOG.info("Too few employees for NEF");                  throw new InvalidRegistrationException("Zu wenig Personal für NEF!");              } else if (total > 3) { -                LOG.info("Too many employees for NEF");                  throw new InvalidRegistrationException("Zu viel Personal für NEF!");              }              for (long driver_id : driverIds) { @@ -125,12 +113,10 @@ public class RegistrationValidator {                  found.put(driver_id, true);                  for (long na_id : naIds) {                      if (found.get(na_id)) continue; -                    LOG.info("Valid combinaion found for NEF");                      return;                  }                  found.put(driver_id, false);              } -            LOG.info("No valid combination of employees found for NEF");              throw new InvalidRegistrationException(                      "Keine gültige Kombination von Personen für NEF!");          } else if (vehicle.type() == VehicleType.BKTW) { @@ -139,14 +125,11 @@ public class RegistrationValidator {              1 Driver               */              if (total > 3) { -                LOG.info("Too many employees for BKTW");                  throw new InvalidRegistrationException("Zu viel Personal für BKTW!");              }              if (!driverIds.isEmpty()) { -                LOG.info("Valid combination found for BKTW");                  return;              } -            LOG.info("No driver was found for BKTW");              throw new InvalidRegistrationException("Kein Fahrer gefunden für BKTW!");          } else { // KTW or RTW, both have the same requirements              /* @@ -155,11 +138,9 @@ public class RegistrationValidator {              1 RS               */              if (total < 2) { -                LOG.info("Too few employees for {}", vehicle.type().name());                  throw new InvalidRegistrationException(                          "Zu wenig Personal für " + vehicle.type().name() + "!");              } else if (total > 4) { -                LOG.info("Too many employees for {}", vehicle.type().name());                  throw new InvalidRegistrationException(                          "Zu viel Persoanl für " + vehicle.type().name() + "!");              } @@ -167,11 +148,9 @@ public class RegistrationValidator {                  found.put(driver_id, true);                  for (long rs_id : rsIds) {                      if (found.get(rs_id)) continue; -                    LOG.info("Valid combination found for {}", vehicle.type().name());                      return;                  }              } -            LOG.info("No valid combination of employees found for {}", vehicle.type().name());              throw new InvalidRegistrationException(                      "Keine gültige Kombination von Personen für " + vehicle.type().name() + "!");          } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java index e81db0b..c2033f5 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dto/Vehicle.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dto/Vehicle.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto;  import com.google.auto.value.AutoValue;  import java.util.List; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java index f7f8e71..5beabaa 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeService.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeService.java @@ -1,8 +1,8 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee;  import java.util.Set;  public interface EmployeeService { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java index 31b5acd..a08b03e 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceImpl.java @@ -1,12 +1,12 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.EmployeeDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.EmployeeValidator;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException;  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.missioncontrol.dao.EmployeeDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.EmployeeValidator;  import java.util.Set;  import org.springframework.stereotype.Service; @@ -53,5 +53,7 @@ public class EmployeeServiceImpl implements EmployeeService {      }      @Override -    public void remove(long id) throws InvalidEmployeeException, ServiceException {} +    public void remove(long id) throws InvalidEmployeeException, ServiceException { +        throw new UnsupportedOperationException(); +    }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java index 4b7e630..42b23bb 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationService.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationService.java @@ -1,11 +1,11 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -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.exception.InvalidOperationException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle;  import java.util.EnumSet;  import java.util.Set;  import java.util.SortedSet; 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/missioncontrol/service/OperationServiceImpl.java index d07f46f..0c350fe 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/missioncontrol/service/OperationServiceImpl.java @@ -1,18 +1,17 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.OperationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -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.VehicleType;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException;  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 java.lang.invoke.MethodHandles; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.OperationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import java.time.Instant;  import java.util.ArrayList;  import java.util.Comparator; @@ -34,7 +33,7 @@ import org.springframework.stereotype.Service;  @Service  public class OperationServiceImpl implements OperationService { -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); +    private static final Logger LOG = LoggerFactory.getLogger(OperationServiceImpl.class);      private final OperationDAO operationDAO;      private final VehicleDAO vehicleDAO; @@ -49,19 +48,29 @@ public class OperationServiceImpl implements OperationService {      @Override      public long add(Operation o) throws InvalidOperationException, ServiceException { -        if (o.created() != null) throw new InvalidOperationException("Created must not be set"); +        if (o.created() != null) { +            throw new InvalidOperationException("Erstellungszeitpunkt darf nicht gesetzt sein"); +        } -        if (o.severity() != null) throw new InvalidOperationException("Severity must not be set"); +        if (o.severity() != null) { +            throw new InvalidOperationException("Der Schweregrad darf nicht gesetzt sein"); +        } -        if (o.id() != 0) throw new InvalidOperationException("Id must be 0"); +        if (o.id() != 0) { +            throw new InvalidOperationException("Einsatz-ID muss 0 sein"); +        }          if (o.status() != Status.ACTIVE) -            LOG.warn("Status was set but will be overridden"); // TODO: nullable instead?? +            LOG.info("Status was set but will be overridden"); // TODO: nullable instead??          try {              for (long id : (Iterable<Long>) o.vehicles().stream().map(Vehicle::id)::iterator) {                  Vehicle v = vehicleDAO.get(id);                  VehicleServiceImpl.validateVehicle(v); + +                if (v.status() != Vehicle.Status.FREI_FUNK +                        && v.status() != Vehicle.Status.FREI_WACHE) +                    throw new InvalidOperationException("Fahrzeug nicht verfügbar: " + v.status());              }              validateOperation(o); @@ -73,10 +82,10 @@ public class OperationServiceImpl implements OperationService {                              .status(Status.ACTIVE)                              .build());          } catch (PersistenceException e) { -            LOG.error("PersistenceException while adding operation: {}", e);              throw new ServiceException(e);          } catch (InvalidVehicleException e) { -            throw new InvalidOperationException("Enthaltenes Fahrzeug ist invalid", e); +            // already logged as invalid vehicle +            throw new InvalidOperationException("Enthaltenes Fahrzeug ist ungültig", e);          } catch (ElementNotFoundException e) {              throw new InvalidOperationException("Enthaltenes Fahrzeug existiert nicht", e);          } @@ -88,29 +97,37 @@ public class OperationServiceImpl implements OperationService {          Set<Vehicle> vs = new HashSet<>();          try { -            if (operationId <= 0) throw new InvalidOperationException("OperationId ist invalid"); +            if (operationId <= 0) { +                throw new InvalidOperationException("Einsatz-ID ist ungültig"); +            }              Operation o = operationDAO.get(operationId);              validateOperation(o);              if (o.opCode().trim().isEmpty() -                    || extractSeverityFromOpCode(o.opCode()) != o.severity()) -                throw new InvalidOperationException("Einsatzcode ist invalid"); +                    || extractSeverityFromOpCode(o.opCode()) != o.severity()) { +                throw new InvalidOperationException("Einsatzcode ist ungültig"); +            } -            if (o.status() != Status.ACTIVE) -                throw new InvalidOperationException("Einsatz ist inaktiv"); +            if (o.status() != Status.ACTIVE) { +                throw new InvalidOperationException("Einsatz ist ungültig"); +            } -            if (o.created() == null) -                throw new InvalidOperationException("Created darf nicht leer sein"); +            if (o.created() == null) { +                throw new InvalidOperationException("Erstellungszeitpunkt darf nicht leer sein"); +            }              for (Long id : vehicleIds) { -                if (id <= 0) throw new InvalidVehicleException("VehicleId ist invalid"); +                if (id <= 0) { +                    throw new InvalidVehicleException("Fahrzeug-ID ist ungültig"); +                }                  try {                      Vehicle v = vehicleDAO.get(id);                      VehicleServiceImpl.validateVehicle(v); -                    if (v.status() == Vehicle.Status.ABGEMELDET) -                        throw new InvalidVehicleException( -                                "Kann keine inaktiven Fahrzeuge anfordern"); +                    if (v.status() != Vehicle.Status.FREI_FUNK +                            && v.status() != Vehicle.Status.FREI_WACHE) +                        throw new InvalidOperationException( +                                "Fahrzeug nicht verfügbar: " + v.status());                      vs.add(v);                  } catch (ElementNotFoundException e) { @@ -123,9 +140,8 @@ public class OperationServiceImpl implements OperationService {              operationDAO.update(o.toBuilder().vehicles(vs).build());          } catch (ElementNotFoundException e) { -            throw new InvalidOperationException("Kein Einsatz mit dieser id existiert"); +            throw new InvalidOperationException("Kein Einsatz mit dieser ID existiert");          } catch (PersistenceException e) { -            LOG.error("PersistenceException while requesting vehicles: {}", e);              throw new ServiceException(e);          }      } @@ -139,7 +155,6 @@ public class OperationServiceImpl implements OperationService {          } catch (ElementNotFoundException e) {              throw new InvalidOperationException(e);          } catch (PersistenceException e) { -            LOG.error("PersistenceException while completing operation: {}", e);              throw new ServiceException(e);          }      } @@ -214,40 +229,45 @@ public class OperationServiceImpl implements OperationService {              return operations;          } catch (PersistenceException e) { -            LOG.error("PersistenceException while listing operations", e);              throw new ServiceException(e);          } catch (InvalidOperationException e) {              // database returned invalid values -            LOG.error("DB returned invalid operation: {}", e);              throw new ServiceException("DB returned invalid operation", e);          }      }      private static void validateOperation(Operation o) throws InvalidOperationException { -        if (o.vehicles().isEmpty()) +        if (o.vehicles().isEmpty()) {              throw new InvalidOperationException(                      "Es muss mindestens ein Fahrzeug ausgewählt werden!"); +        }          for (Vehicle v : o.vehicles()) {              try {                  VehicleServiceImpl.validateVehicle(v);              } catch (InvalidVehicleException e) { -                throw new InvalidOperationException("Fahrzeug " + v.name() + " ist invalid" + e); +                throw new InvalidOperationException("Fahrzeug " + v.name() + " ist ungültig", e);              } -            if (v.status() != Vehicle.Status.FREI_FUNK && v.status() != Vehicle.Status.FREI_WACHE) -                throw new InvalidOperationException( -                        "Fahrzeug nicht verfügbar (" + v.status() + ")"); -              // TODO: validate if NEF/RTW/NAH conditions?          }          Instant created = o.created(); -        if (created != null && created.isAfter(Instant.now())) -            throw new InvalidOperationException("Fahrzeug wurde in der Zukunft erstellt"); +        if (created != null && created.isAfter(Instant.now())) { +            throw new InvalidOperationException("Einsatz wurde in der Zukunft erstellt"); +        } -        if (o.destination().trim().isEmpty()) +        if (o.destination() == null || o.destination().trim().isEmpty()) {              throw new InvalidOperationException("Adresse darf nicht leer sein"); +        } + +        if (o.destination().length() > 100) { +            throw new InvalidOperationException("Adresse darf 100 Zeichen nicht überschreiten"); +        } + +        if (o.additionalInfo() != null && o.additionalInfo().length() > 100) { +            throw new InvalidOperationException("Anmerkung darf 100 Zeichen nicht überschreiten"); +        }      }      private static final Pattern opCodePattern = @@ -257,7 +277,9 @@ public class OperationServiceImpl implements OperationService {              throws InvalidOperationException {          Matcher m = opCodePattern.matcher(opCode); -        if (!m.matches()) throw new InvalidOperationException("Einsatzcode ist invalid"); +        if (!m.matches()) { +            throw new InvalidOperationException("Einsatzcode ist ungültig"); +        }          return Severity.valueOf(m.group(1));      } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java index b7d8eef..91577dc 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationService.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationService.java @@ -1,9 +1,9 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration;  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 at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration;  import java.util.Set;  public interface RegistrationService { diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java index 54d46e7..a6a1dfe 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceImpl.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceImpl.java @@ -1,26 +1,22 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.RegistrationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Registration; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.RegistrationValidator; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;  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.PersistenceException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.RegistrationValidator; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle;  import java.util.Set; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory;  import org.springframework.beans.factory.annotation.Autowired;  import org.springframework.stereotype.Service;  @Service  public class RegistrationServiceImpl implements RegistrationService { -    private static final Logger LOG = LoggerFactory.getLogger(RegistrationServiceImpl.class); -      private final RegistrationDAO registrationDAO;      private final VehicleDAO vehicleDAO; @@ -43,7 +39,6 @@ public class RegistrationServiceImpl implements RegistrationService {              return registrationDAO.add(vehicle.id(), registrations);          } catch (PersistenceException e) { -            LOG.warn("PersistenceException caught, throwing matching ServiceException");              throw new ServiceException(e);          } catch (ElementNotFoundException e) {              throw new InvalidVehicleException(e); @@ -52,6 +47,14 @@ public class RegistrationServiceImpl implements RegistrationService {      @Override      public void remove(long registrationId) throws InvalidRegistrationException, ServiceException { -        throw new UnsupportedOperationException(); +        if (registrationId <= 0) throw new InvalidRegistrationException("RegistrationId invalid"); + +        try { +            registrationDAO.remove(registrationId); +        } catch (PersistenceException e) { +            throw new ServiceException(e); +        } catch (ElementNotFoundException e) { +            throw new InvalidRegistrationException(e); +        }      }  } diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java index fe09ca1..f8e303d 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleService.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/VehicleService.java @@ -1,9 +1,9 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -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.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status;  import java.util.EnumSet;  import java.util.Set; 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/missioncontrol/service/VehicleServiceImpl.java index 61a24e5..a68720d 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/missioncontrol/service/VehicleServiceImpl.java @@ -1,13 +1,13 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; -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.ConstructionType; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Status;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;  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.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status;  import java.util.EnumSet;  import java.util.Set;  import java.util.stream.Collectors; @@ -24,8 +24,10 @@ public class VehicleServiceImpl implements VehicleService {      }      public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { -        if (!CollectionUtils.isEmpty(vehicle.registrations())) -            throw new InvalidVehicleException("Vehicle can't be created with registrations"); +        if (!CollectionUtils.isEmpty(vehicle.registrations())) { +            throw new InvalidVehicleException( +                    "Fahrzeug kann nicht mit Anmeldungen erstellt werden"); +        }          validateVehicle(vehicle);          try { @@ -41,7 +43,7 @@ public class VehicleServiceImpl implements VehicleService {          try {              vehiclePersistence.update(vehicle);          } catch (ElementNotFoundException e) { -            throw new ServiceException("Element not found"); +            throw new ServiceException("Element not found", e);          } catch (PersistenceException e) {              throw new ServiceException(e);          } @@ -91,7 +93,7 @@ public class VehicleServiceImpl implements VehicleService {      @Override      public Set<Vehicle> list(EnumSet<Status> statuses) throws ServiceException {          if (statuses == null) { -            throw new ServiceException("statuses may not be null"); +            throw new ServiceException("Statuses may not be null");          }          Set<Vehicle> vehicles; diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/util/JDBCConnectionManager.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/util/JDBCConnectionManager.java index 0ee3319..ea394ab 100644 --- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/util/JDBCConnectionManager.java +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/util/JDBCConnectionManager.java @@ -47,4 +47,12 @@ public class JDBCConnectionManager {          }          connection = null;      } + +    public void rollbackConnection() { +        try { +            connection.rollback(); +        } catch (SQLException e) { +            LOG.error("Failed to rollback connection", e); +        } +    }  } diff --git a/src/main/resources/fxml/ArchiveOperation.fxml b/src/main/resources/fxml/ArchiveOperation.fxml index 88b5b39..9c22803 100644 --- a/src/main/resources/fxml/ArchiveOperation.fxml +++ b/src/main/resources/fxml/ArchiveOperation.fxml @@ -1,41 +1,58 @@  <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?>  <?import javafx.scene.control.Hyperlink?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.ScrollPane?> +<?import javafx.scene.control.TextField?> +<?import javafx.scene.image.ImageView?>  <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.ColumnConstraints?>  <?import javafx.scene.layout.FlowPane?> +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.layout.RowConstraints?>  <?import javafx.scene.text.Font?> -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="1200.0" style="-fx-background-color: BLACK;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.ArchiveOperationController"> -  <children> -    <AnchorPane prefHeight="650.0" prefWidth="800.0" style="-fx-background-color: rgba(239,235,232,1);" AnchorPane.leftAnchor="200.0" /> -      <ScrollPane prefHeight="650.0" prefWidth="800.0" AnchorPane.leftAnchor="200.0"> +<AnchorPane fx:id="archiveOperationAP" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="1000.0" style="-fx-background-color: rgba(239,235,232,1);" visible="false" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.ArchiveOperationController"> +   <children> +      <ScrollPane hbarPolicy="NEVER" layoutX="43.0" layoutY="202.0" prefHeight="435.0" prefWidth="906.0" style="-fx-background-color:  rgba(239,235,232,1);" vbarPolicy="NEVER" AnchorPane.leftAnchor="43.0">           <content> -          <FlowPane fx:id="archiveOperationFlowPane" prefHeight="650.0" prefWidth="800.0" /> +            <FlowPane fx:id="archiveOperationFlowPane" hgap="12" prefHeight="598.0" prefWidth="906.0" style="-fx-background-color:  rgba(239,235,232,1);" vgap="12"> +               <padding> +                  <Insets left="40.0" top="20.0" /> +               </padding></FlowPane>           </content>        </ScrollPane> -      <AnchorPane fx:id="apDetails" layoutX="201.0" prefHeight="650.0" prefWidth="800.0" style="-fx-background-color: rgba(239,235,232,1);" visible="false" AnchorPane.leftAnchor="201.0" AnchorPane.topAnchor="0.0"> +      <AnchorPane fx:id="apDetails" layoutX="201.0" prefHeight="650.0" prefWidth="1000.0" style="-fx-background-color: rgba(239,235,232,1);" visible="false" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">           <children> -            <AnchorPane prefHeight="170.0" prefWidth="800.0" style="-fx-background-color: rgba(191,144,0,1);"> +            <ScrollPane fitToWidth="true" hbarPolicy="NEVER" layoutY="211.0" prefHeight="424.0" prefWidth="840.0" style="-fx-background-color: rgba(239,235,232,1);" vbarPolicy="NEVER" AnchorPane.leftAnchor="82.0" AnchorPane.topAnchor="211.0"> +               <content> +                  <FlowPane fx:id="fpVehicles" hgap="50" prefHeight="419.0" prefWidth="830.0" style="-fx-background-color: rgba(239,235,232,1);" vgap="50"> +                     <padding> +                        <Insets left="40.0" right="40.0" top="20.0" /> +                     </padding> +                  </FlowPane> +               </content> +            </ScrollPane> +            <AnchorPane fx:id="backApDetails" prefHeight="170.0" prefWidth="1000.0" style="-fx-background-color: rgba(191,144,0,1);">                 <children> -                  <Label layoutX="81.0" layoutY="20.0" prefHeight="34.0" prefWidth="116.0" text="Archiv-Eintrag:" textFill="WHITE"> +                  <Hyperlink layoutX="827.0" layoutY="33.0" onAction="#backClicked" text="Zurück" textFill="WHITE">                       <font> -                        <Font name="System Bold" size="16.0" /> +                        <Font name="System Bold" size="20.0" />                       </font> -                  </Label> -                  <Label fx:id="lblCodeHeader" layoutX="203.0" layoutY="20.0" prefHeight="34.0" prefWidth="116.0" textFill="WHITE"> +                  </Hyperlink> +                  <Label layoutX="80.0" layoutY="36.0" prefHeight="34.0" prefWidth="150.0" text="Archiv-Eintrag:" textFill="WHITE">                       <font> -                        <Font name="System Bold" size="16.0" /> +                        <Font name="System Bold" size="20.0" />                       </font>                    </Label> -                  <Hyperlink fx:id="hypBack" layoutX="656.0" layoutY="20.0" onAction="#backClicked" text="Zurück" textFill="WHITE"> +                  <Label fx:id="lblCodeHeader" layoutX="230.0" layoutY="36.0" prefHeight="34.0" prefWidth="116.0" textFill="WHITE">                       <font> -                        <Font name="System Bold" size="16.0" /> +                        <Font name="System Bold" size="20.0" />                       </font> -                  </Hyperlink> +                  </Label>                 </children></AnchorPane> -            <AnchorPane layoutX="82.0" layoutY="60.0" prefHeight="150.0" prefWidth="636.0" style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 5, 0, 0, 5);"> +            <AnchorPane layoutX="82.0" layoutY="81.0" prefHeight="99.0" prefWidth="822.0" style="-fx-background-color: white;" styleClass="shadowed">                 <children>                    <Label fx:id="lblOpCode" layoutX="25.0" layoutY="22.0" prefHeight="26.0" prefWidth="116.0" text="Label">                       <font> @@ -47,24 +64,80 @@                          <Font size="15.0" />                       </font>                    </Label> -                  <Label fx:id="lblVehicles" layoutX="58.0" layoutY="91.0" prefHeight="46.0" prefWidth="554.0" text="Label"> +                  <Label fx:id="lblVehicles" layoutX="83.0" layoutY="91.0" prefHeight="46.0" prefWidth="517.0" text="Label">                       <font>                          <Font size="15.0" />                       </font>                    </Label> -                  <Label fx:id="lblDate" alignment="CENTER_RIGHT" layoutX="482.0" layoutY="22.0" prefHeight="27.0" prefWidth="140.0" text="Label"> +                  <Label fx:id="lblDate" alignment="CENTER_RIGHT" layoutX="482.0" layoutY="22.0" prefHeight="27.0" prefWidth="140.0" text="Label" AnchorPane.rightAnchor="50.0">                       <font>                          <Font name="System Bold" size="18.0" />                       </font>                    </Label> +                  <ImageView fx:id="imvVehicleDetail" fitHeight="34.0" fitWidth="34.0" layoutX="26.0" layoutY="97.0" pickOnBounds="true" preserveRatio="true" /> +                  <Label fx:id="lblStatus" alignment="CENTER_RIGHT" layoutX="476.0" layoutY="91.0" prefHeight="27.0" prefWidth="301.0" text="Status: "> +                     <font> +                        <Font name="System Bold" size="15.0" /> +                     </font> +                  </Label>                 </children>              </AnchorPane> -            <ScrollPane fitToWidth="true" prefHeight="410.0" prefWidth="640.0" AnchorPane.leftAnchor="82.0" AnchorPane.topAnchor="225.0"> -               <content> -                  <FlowPane fx:id="fpVehicles" prefHeight="410.0" prefWidth="640.0" /> -               </content> -            </ScrollPane>           </children>        </AnchorPane> -  </children> +      <AnchorPane fx:id="backApMain" prefHeight="170.0" prefWidth="1000.0" style="-fx-background-color: rgba(191,144,0,1);" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0"> +         <children> +            <Hyperlink layoutX="827.0" layoutY="33.0" onAction="#backToMain" text="Zurück" textFill="WHITE"> +               <font> +                  <Font name="System Bold" size="20.0" /> +               </font> +            </Hyperlink> +            <Label layoutX="80.0" layoutY="36.0" prefHeight="34.0" prefWidth="150.0" text="Archiv" textFill="WHITE"> +               <font> +                  <Font name="System Bold" size="20.0" /> +               </font> +            </Label> +         </children> +      </AnchorPane> +      <AnchorPane fx:id="apMainDetails" layoutX="82.0" layoutY="80.0" prefHeight="138.0" prefWidth="822.0" style="-fx-background-color: white;" styleClass="shadowed"> +         <children> +            <GridPane layoutY="14.0" prefHeight="114.0" prefWidth="804.0"> +               <columnConstraints> +                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> +                  <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" /> +               </columnConstraints> +               <rowConstraints> +                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> +                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> +                  <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" /> +               </rowConstraints> +               <children> +                  <Label fx:id="lblOperations" text="Einsätze:"> +                     <font> +                        <Font name="System Bold" size="20.0" /> +                     </font> +                  </Label> +                  <Label fx:id="lblCompleted" text="abgeschlossen:" GridPane.rowIndex="1"> +                     <font> +                        <Font size="15.0" /> +                     </font> +                  </Label> +                  <Label fx:id="lblCancelled" text="storniert:" GridPane.rowIndex="2"> +                     <font> +                        <Font size="15.0" /> +                     </font> +                  </Label> +                  <Label text="Suche:" GridPane.columnIndex="1"> +                     <font> +                        <Font name="System Bold" size="20.0" /> +                     </font> +                  </Label> +                  <TextField fx:id="txtSearch" onKeyReleased="#searchInput" prefHeight="30.0" prefWidth="355.0" GridPane.columnIndex="1" GridPane.rowIndex="1" /> +               </children> +               <padding> +                  <Insets left="20.0" /> +               </padding> +            </GridPane> +         </children> +      </AnchorPane> +   </children>  </AnchorPane> diff --git a/src/main/resources/fxml/CreateOperationController.fxml b/src/main/resources/fxml/CreateOperationController.fxml index 0a09611..56e0c90 100644 --- a/src/main/resources/fxml/CreateOperationController.fxml +++ b/src/main/resources/fxml/CreateOperationController.fxml @@ -1,88 +1,83 @@  <?xml version="1.0" encoding="UTF-8"?> +<?import javafx.geometry.Insets?>  <?import javafx.scene.control.Button?>  <?import javafx.scene.control.Hyperlink?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.ListView?> +<?import javafx.scene.control.ScrollPane?>  <?import javafx.scene.control.TextField?>  <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.ColumnConstraints?>  <?import javafx.scene.layout.FlowPane?> +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.layout.RowConstraints?>  <?import javafx.scene.text.Font?> -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" -  prefHeight="650.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/9.0.1" -  xmlns:fx="http://javafx.com/fxml/1" -  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateOperationController" -  stylesheets="@/styles/main.css"> -  <AnchorPane prefHeight="182.0" style="-fx-background-color: #2D75B6;" AnchorPane.leftAnchor="0.0" -    AnchorPane.topAnchor="0.0" AnchorPane.rightAnchor="0.0"/> -  <AnchorPane fx:id="apCreateOperation" layoutX="40.0" layoutY="71.0" prefHeight="151.0" -    prefWidth="920.0" -    styleClass="bg-white, shadowed"> -    <Label layoutX="14.0" layoutY="14.0" prefHeight="30.0" prefWidth="62.0" text="Code" -      styleClass="text-medium"/> -    <Label layoutX="185.0" layoutY="14.0" prefHeight="30.0" prefWidth="94.0" text="Adresse" -      styleClass="text-medium"/> -    <Label layoutX="587.0" layoutY="14.0" prefHeight="30.0" prefWidth="121.0" text="Anmerkung" -      styleClass="text-medium"/> -    <TextField fx:id="txtCode" layoutX="14.0" layoutY="48.0" prefHeight="39.0" -      onKeyReleased="#onOperationCodeChanged" -      prefWidth="163.0" styleClass="text-big"> + +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="650.0" prefWidth="1200.0" styleClass="bg-gray-blue" stylesheets="@/styles/main.css" xmlns="http://javafx.com/javafx/8.0.121" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.CreateOperationController"> +  <AnchorPane prefHeight="182.0" styleClass="bg-blue" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> +  <AnchorPane fx:id="apCreateOperation" layoutX="40.0" layoutY="71.0" prefHeight="151.0" prefWidth="920.0" styleClass="bg-white, shadowed"> +    <Label layoutX="14.0" layoutY="14.0" prefHeight="30.0" prefWidth="62.0" styleClass="text-medium" text="Code" /> +    <Label layoutX="185.0" layoutY="14.0" prefHeight="30.0" prefWidth="94.0" styleClass="text-medium" text="Adresse" /> +    <Label layoutX="587.0" layoutY="14.0" prefHeight="30.0" prefWidth="121.0" styleClass="text-medium" text="Anmerkung" /> +    <TextField fx:id="txtCode" layoutX="14.0" layoutY="48.0" onKeyReleased="#onOperationCodeChanged" prefHeight="39.0" prefWidth="163.0" styleClass="text-big">        <font> -        <Font name="System Bold"/> +        <Font name="System Bold" />        </font>      </TextField> -    <TextField fx:id="txtAddress" layoutX="185.0" layoutY="48.0" prefHeight="39.0" -      prefWidth="396.0" styleClass="text-big"> +    <TextField fx:id="txtAddress" layoutX="185.0" layoutY="48.0" prefHeight="39.0" prefWidth="396.0" styleClass="text-big">        <font> -        <Font name="System Bold"/> +        <Font name="System Bold" />        </font>      </TextField> -    <TextField fx:id="txtNote" layoutX="587.0" layoutY="48.0" prefHeight="39.0" -      prefWidth="319.0" styleClass="text-big"> +    <TextField fx:id="txtNote" layoutX="587.0" layoutY="48.0" prefHeight="39.0" prefWidth="319.0" styleClass="text-big">        <font> -        <Font name="System Bold"/> +        <Font name="System Bold" />        </font>      </TextField> -    <Label layoutX="14.0" layoutY="101.0" prefHeight="30.0" prefWidth="102.0" -      text="Fahrzeuge:" styleClass="text-medium"/> -    <Label fx:id="lblChosenVehicles" layoutX="116.0" layoutY="102.0" prefHeight="30.0" -      prefWidth="610.0" text="keine ausgewählt" styleClass="text-big"/> -    <Button fx:id="btnCreateOperation" layoutX="747.0" styleClass="text-big, button-main" -      layoutY="95.0" mnemonicParsing="false" -      onAction="#createOperationClicked" prefHeight="0.0" prefWidth="158.0" text="Erstellen"> +    <Label layoutX="14.0" layoutY="101.0" prefHeight="30.0" prefWidth="102.0" styleClass="text-medium" text="Fahrzeuge:" /> +    <Label fx:id="lblChosenVehicles" layoutX="116.0" layoutY="102.0" prefHeight="30.0" prefWidth="610.0" styleClass="text-big" text="keine ausgewählt" /> +    <Button fx:id="btnCreateOperation" layoutX="747.0" layoutY="95.0" mnemonicParsing="false" onAction="#createOperationClicked" prefHeight="0.0" prefWidth="158.0" styleClass="text-big, button-main" text="Erstellen">        <font> -        <Font name="System Bold"/> +        <Font name="System Bold" />        </font>      </Button>    </AnchorPane> -  <Hyperlink layoutX="44.0" layoutY="38.0" onAction="#onRegistrationLinkClicked" text="Anmeldungen" -    textFill="WHITE" styleClass="text-small"> +  <Hyperlink layoutX="44.0" layoutY="38.0" onAction="#onRegistrationLinkClicked" styleClass="text-small" text="Anmeldungen" textFill="WHITE">    </Hyperlink> -  <Hyperlink layoutX="802.0" layoutY="38.0" onAction="#onEmployeeLinkClicked" text="Personen" -    styleClass="text-small" -    textFill="WHITE"> +  <Hyperlink layoutX="802.0" layoutY="38.0" onAction="#onEmployeeLinkClicked" styleClass="text-small" text="Personen" textFill="WHITE">    </Hyperlink> -  <Hyperlink layoutX="877.0" layoutY="38.0" onAction="#onVehicleLinkClicked" text="Fahrzeuge" -    styleClass="text-small" -    textFill="WHITE"> +  <Hyperlink layoutX="877.0" layoutY="38.0" onAction="#onVehicleLinkClicked" styleClass="text-small" text="Fahrzeuge" textFill="WHITE">    </Hyperlink> -  <!--<AnchorPane fx:id="apActiveOperations" layoutX="968.0" layoutY="71.0" prefHeight="315.0" prefWidth="207.0" style="-fx-background-color: white; -fx-effect: dropshadow(gaussian, rgba(0.5,0.5,0.5,0.8), 5, 0, 0, 3);">--> -  <AnchorPane fx:id="apActiveOperations" layoutX="968.0" layoutY="71.0" prefHeight="315.0" -    prefWidth="207.0" -    styleClass="bg-white, shadowed"> -    <ListView fx:id="lvActiveOperations" layoutX="4.0" layoutY="74.0" prefHeight="242.0" -      prefWidth="200.0" style="-fx-background-color: white;"/> -    <Label layoutX="10.0" layoutY="6.0" -      text="Aktive Einsätze" styleClass="text-big"> +  <AnchorPane layoutX="968.0" layoutY="71.0" prefHeight="315.0" prefWidth="207.0" styleClass="bg-white, shadowed"> +    <ListView fx:id="lvActiveOperations" layoutX="4.0" layoutY="74.0" prefHeight="242.0" prefWidth="200.0" style="-fx-background-color: white;" /> +    <Label layoutX="10.0" layoutY="6.0" styleClass="text-big" text="Aktive Einsätze">      </Label> -    <Hyperlink onAction="#onArchivLinkClicked" layoutY="7.0" text="Archiv" styleClass="text-medium" -      AnchorPane.rightAnchor="12"/> +    <Hyperlink layoutY="7.0" onAction="#onArchivLinkClicked" styleClass="text-medium" text="Archiv" AnchorPane.rightAnchor="12" />    </AnchorPane> -  <FlowPane fx:id="fpVehicles" hgap="12" layoutX="40.0" layoutY="228.0" prefHeight="388.0" -    prefWidth="920.0" vgap="12"> -  </FlowPane> -  <AnchorPane fx:id="apInvisible" prefHeight="650.0" prefWidth="1200.0" -    style="-fx-background-color: rgba(0,0,0,0.7);" visible="false"/> -  <fx:include fx:id="operationDetails" source="/fxml/OperationDetails.fxml" -    AnchorPane.leftAnchor="54.0" AnchorPane.topAnchor="50.0"/> +  <ScrollPane hbarPolicy="NEVER" layoutX="34.0" layoutY="222.0" prefHeight="388.0" prefWidth="920.0" vbarPolicy="ALWAYS"> +    <FlowPane fx:id="fpVehicles" hgap="12" vgap="12" prefWidth="920.0"> +      <padding> +        <Insets topRightBottomLeft="6" /> +      </padding> +    </FlowPane> +  </ScrollPane> +  <AnchorPane fx:id="apInvisible" style="-fx-background-color: rgba(0,0,0,0.7);" visible="false" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" /> + +  <GridPane fx:id="grdWindowContainer" alignment="CENTER" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0" AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"> +    <padding> +      <Insets topRightBottomLeft="12" /> +    </padding> +    <fx:include fx:id="registrationWindow" source="/fxml/RegistrationWindow.fxml" /> +      <columnConstraints> +         <ColumnConstraints /> +      </columnConstraints> +      <rowConstraints> +         <RowConstraints /> +      </rowConstraints> +  </GridPane> +  <fx:include fx:id="operationDetails" source="/fxml/OperationDetails.fxml" AnchorPane.leftAnchor="54.0" AnchorPane.topAnchor="50.0" /> +  <fx:include fx:id="manageEmployees" source="/fxml/manageEmployees.fxml" AnchorPane.leftAnchor="240.0" AnchorPane.topAnchor="60.0" /> +  <fx:include fx:id="createCar" source="/fxml/createCar.fxml" AnchorPane.leftAnchor="192.0" AnchorPane.topAnchor="57.0" /> +  <fx:include fx:id="archiveOperation" source="/fxml/ArchiveOperation.fxml" AnchorPane.leftAnchor="100.0" />  </AnchorPane> diff --git a/src/main/resources/fxml/DetailArchiveOperation.fxml b/src/main/resources/fxml/DetailArchiveOperation.fxml new file mode 100644 index 0000000..553dfd3 --- /dev/null +++ b/src/main/resources/fxml/DetailArchiveOperation.fxml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.VBox?> + +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.DetailArchiveOperationController"> +   <children> +      <HBox prefHeight="100.0" prefWidth="200.0" spacing="100.0"> +         <children> +            <VBox fx:id="vBoxVehicle" prefHeight="200.0" prefWidth="100.0" /> +            <VBox fx:id="vBoxPeople" prefHeight="200.0" prefWidth="100.0" spacing="10.0" /> +         </children> +         <padding> +            <Insets right="10.0" /> +         </padding> +      </HBox> +   </children> +</AnchorPane> diff --git a/src/main/resources/fxml/OperationDetails.fxml b/src/main/resources/fxml/OperationDetails.fxml index 3ac7d93..9d2fb5b 100644 --- a/src/main/resources/fxml/OperationDetails.fxml +++ b/src/main/resources/fxml/OperationDetails.fxml @@ -4,22 +4,25 @@  <?import javafx.scene.control.Hyperlink?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.ListView?> +<?import javafx.scene.control.ScrollPane?>  <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.FlowPane?>  <?import javafx.scene.text.Font?> -<AnchorPane fx:id="operationDetailsAP" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="542.0" prefWidth="1100.0" visible="false" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.OperationDetailsController"> +<?import javafx.scene.layout.VBox?> +<AnchorPane fx:id="operationDetailsAP" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="542.0" prefWidth="1100.0" visible="false" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.OperationDetailsController">    <children> -    <AnchorPane prefHeight="542.0" prefWidth="1100.0" style="-fx-background-color: white;" /> +    <AnchorPane prefHeight="542.0" prefWidth="1100.0" style="-fx-background-color: rgba(239,235,232,1);" />      <AnchorPane layoutX="10.0" layoutY="10.0" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="542.0" prefWidth="1000.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">        <children>          <AnchorPane layoutX="964.0" layoutY="-66.0" prefHeight="152.0" prefWidth="1100.0" style="-fx-background-color: green;" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">            <children> -            <Hyperlink layoutX="1023.0" layoutY="16.0" onAction="#closeWindow" text="Zurück" textFill="WHITE"> +            <Hyperlink layoutX="1023.0" layoutY="16.0" onAction="#closeWindow" styleClass="text-medium" text="Zurück" textFill="WHITE">                <font>                  <Font size="15.0" />                </font>              </Hyperlink> -            <Label layoutX="17.0" layoutY="13.0" prefHeight="34.0" prefWidth="174.0" text="Ausgewählter Einsatz:" textFill="WHITE"> +            <Label layoutX="17.0" layoutY="13.0" prefHeight="34.0" prefWidth="174.0" styleClass="text-big" text="Ausgewählter Einsatz:" textFill="WHITE">                <font>                  <Font size="17.0" />                </font> @@ -28,20 +31,14 @@          </AnchorPane>          <AnchorPane fx:id="apActiveOperations" layoutX="874.0" layoutY="50.0" prefHeight="298.0" prefWidth="200.0" style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 5);">            <children> -            <ListView fx:id="lvActiveOperations" layoutX="9.0" layoutY="55.0" prefHeight="242.0" prefWidth="182.0" style="-fx-background-color: white;" /> -            <Label layoutX="9.0" layoutY="11.0" prefHeight="46.0" prefWidth="103.0" text="Aktive Einsätze"> +            <ListView fx:id="lvActiveOperations" layoutX="9.0" layoutY="46.0" prefHeight="251.0" prefWidth="182.0" style="-fx-background-color: white;" /> +            <Label layoutX="9.0" layoutY="4.0" prefHeight="46.0" prefWidth="103.0" text="Aktive Einsätze">                <font>                  <Font name="System Bold" size="14.0" />                </font>              </Label> -            <Label layoutX="150.0" layoutY="24.0" text="Archiv"> -              <font> -                <Font size="13.0" /> -              </font> -            </Label>            </children>          </AnchorPane> -        <ListView fx:id="lvVehicles" layoutX="16.0" layoutY="185.0" prefHeight="355.0" prefWidth="846.0" style="-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 5);" />          <AnchorPane fx:id="apCreateOperation" layoutX="16.0" layoutY="49.0" prefHeight="134.0" prefWidth="845.0" style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 5, 0, 0, 5);">            <children>              <Label layoutX="14.0" layoutY="14.0" prefHeight="30.0" prefWidth="62.0" text="Code"> @@ -69,12 +66,12 @@                  <Font size="17.0" />                </font>              </Label> -            <Button fx:id="btnCloseOperation" layoutX="709.0" layoutY="89.0" mnemonicParsing="false" onAction="#closeOperationClicked" prefHeight="39.0" prefWidth="122.0" text="Abschließen"> +            <Button fx:id="btnCloseOperation" layoutX="657.0" layoutY="89.0" mnemonicParsing="false" onAction="#closeOperationClicked" prefHeight="39.0" prefWidth="174.0" styleClass="button-main" text="Abschließen">                <font>                  <Font name="System Bold" size="17.0" />                </font>              </Button> -            <Button fx:id="btnCancelOperation" layoutX="575.0" layoutY="90.0" mnemonicParsing="false" onAction="#cancelOperationClicked" prefHeight="38.0" prefWidth="122.0" text="Stornieren"> +            <Button fx:id="btnCancelOperation" layoutX="465.0" layoutY="89.0" mnemonicParsing="false" onAction="#cancelOperationClicked" prefHeight="38.0" prefWidth="174.0" style="-fx-background-color: rgba(82, 83, 87, 0.51); -fx-text-fill: white;" text="Stornieren">                <font>                  <Font name="System Bold" size="17.0" />                </font> @@ -96,6 +93,19 @@              </Label>            </children>          </AnchorPane> +            <ScrollPane layoutX="16.0" layoutY="195.0" prefHeight="345.0" prefWidth="846.0"> +               <content> +                 <VBox> +                  <FlowPane fx:id="fpVehicles" hgap="12" prefHeight="168.0" prefWidth="840.0" vgap="12" /> +                   <Label text="Weitere Fahrzeuge:" > +                     <font> +                       <Font name="System Bold" size="19.0" /> +                     </font> +                   </Label> +                  <FlowPane fx:id="fpAdditional" hgap="12" prefHeight="168.0" prefWidth="840.0" vgap="12" /> +                 </VBox> +               </content> +            </ScrollPane>        </children>      </AnchorPane>    </children> diff --git a/src/main/resources/fxml/OperationInArchive.fxml b/src/main/resources/fxml/OperationInArchive.fxml new file mode 100644 index 0000000..ebbaec8 --- /dev/null +++ b/src/main/resources/fxml/OperationInArchive.fxml @@ -0,0 +1,60 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.ColumnConstraints?> +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.RowConstraints?> +<?import javafx.scene.text.Font?> +<?import javafx.scene.text.Text?> + +<GridPane hgap="12.0" prefHeight="106.0" prefWidth="374.0" styleClass="bg-white, shadowed" vgap="12" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.OperationInArchiveController"> +   <columnConstraints> +      <ColumnConstraints maxWidth="249.6000518798828" minWidth="205.60003662109375" prefWidth="249.6000518798828" /> +      <ColumnConstraints maxWidth="182.39996337890625" minWidth="138.3999481201172" prefWidth="138.3999481201172" /> +      <ColumnConstraints /> +      <ColumnConstraints /> +      <ColumnConstraints /> +   </columnConstraints> +   <rowConstraints> +      <RowConstraints /> +      <RowConstraints /> +      <RowConstraints /> +   </rowConstraints> +   <padding> +      <Insets bottom="6.0" left="12.0" top="6.0" /> +   </padding> +   <children> +      <Text fx:id="txtAddress" text="Text" GridPane.rowIndex="1"> +         <font> +            <Font size="17.0" /> +         </font> +      </Text> +      <HBox prefHeight="23.0" prefWidth="139.0" spacing="7.0" GridPane.rowIndex="2"> +         <children> +            <ImageView fitHeight="23.0" fitWidth="32.0" pickOnBounds="true" preserveRatio="true"> +               <image> +                  <Image url="@../images/Vehicle.png" /> +               </image> +            </ImageView> +            <Text fx:id="txtVehicles" strokeType="OUTSIDE" strokeWidth="0.0" text="Text"> +               <font> +                  <Font size="17.0" /> +               </font> +            </Text> +         </children> +      </HBox> +      <Text fx:id="txtDate" nodeOrientation="RIGHT_TO_LEFT" strokeType="OUTSIDE" strokeWidth="0.0" text="Text" wrappingWidth="132.53673648834229" GridPane.columnIndex="1"> +         <font> +            <Font name="System Bold" size="17.0" /> +         </font> +      </Text> +      <Text fx:id="txtOpCode" strokeType="OUTSIDE" strokeWidth="0.0" text="Text"> +         <font> +            <Font name="System Bold" size="17.0" /> +         </font> +      </Text> +   </children> +</GridPane> diff --git a/src/main/resources/fxml/RegistrationWindow.fxml b/src/main/resources/fxml/RegistrationWindow.fxml index 0394ca7..1f57c11 100644 --- a/src/main/resources/fxml/RegistrationWindow.fxml +++ b/src/main/resources/fxml/RegistrationWindow.fxml @@ -3,74 +3,96 @@  <?import javafx.geometry.Insets?>  <?import javafx.scene.control.Button?>  <?import javafx.scene.control.ChoiceBox?> +<?import javafx.scene.control.Hyperlink?>  <?import javafx.scene.control.Label?> -<?import javafx.scene.control.SplitPane?> -<?import javafx.scene.control.TableColumn?> -<?import javafx.scene.control.TableView?> +<?import javafx.scene.control.ScrollPane?>  <?import javafx.scene.control.TextField?>  <?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.ColumnConstraints?> +<?import javafx.scene.layout.GridPane?>  <?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.RowConstraints?>  <?import javafx.scene.layout.VBox?> +<GridPane fx:id="root" stylesheets="@/styles/main.css" styleClass="bg-gray-orange" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.RegistrationWindowController"> +  <rowConstraints> +    <RowConstraints/> <!--"Neue Anmeldung", "von x bis x", Buttons--> +    <RowConstraints/> <!--"Fahrzeug", "Personen"--> +    <RowConstraints/> <!--"KTW-99", "Max Mustermann, ..."--> +    <RowConstraints prefHeight="15"/> <!--The overflow of the orange area--> +    <RowConstraints/> <!--Search--> +    <RowConstraints/> <!--Lists--> +  </rowConstraints> +  <columnConstraints> +    <ColumnConstraints/> +    <ColumnConstraints prefWidth="20"/> <!--The gap between the colums--> +    <ColumnConstraints prefWidth="320"/> <!--EmployeeListItem: 320--> +  </columnConstraints> +  <padding> +    <Insets topRightBottomLeft="12"/> +  </padding> +  <AnchorPane GridPane.columnIndex="0" GridPane.columnSpan="3" GridPane.rowIndex="0" +    GridPane.rowSpan="4" styleClass="bg-dark-orange"> +    <GridPane.margin> +      <Insets topRightBottomLeft="-12"/> +    </GridPane.margin> +  </AnchorPane> +  <VBox spacing="3"> <!--"Neue Anmeldung", "von bis"--> +    <Label text="Neue Anmeldung" styleClass="text-big, text-white, text-bold"/> +    <HBox spacing="6" alignment="CENTER_LEFT"> +      <Label text="von" styleClass="text-medium, text-white"/> +      <ChoiceBox fx:id="cbStart" value="8:00" styleClass="text-medium, text-bold"/> +      <Label text="bis" styleClass="text-medium, text-white"/> +      <ChoiceBox fx:id="cbEnd" value="16:00" styleClass="text-medium, text-bold"/> +    </HBox> +  </VBox> +  <VBox GridPane.columnIndex="2" GridPane.halignment="RIGHT" alignment="TOP_RIGHT"> +    <Hyperlink text="schließen" onMouseClicked="#cancel" styleClass="text-small, text-white"/> +    <Button text="ERSTELLEN" onMouseClicked="#create" styleClass="button-main, text-medium, shadowed"/> +  </VBox> +  <Label text="Fahrzeug" GridPane.rowIndex="1" styleClass="text-big, text-white, text-bold"> +    <GridPane.margin> +      <Insets top="12"/> +    </GridPane.margin> +  </Label> +  <Label text="Personen" GridPane.rowIndex="1" GridPane.columnIndex="2" +    styleClass="text-big, text-white, text-bold"> +    <GridPane.margin> +      <Insets top="12"/> +    </GridPane.margin> +  </Label> +  <Label fx:id="lVehicles" text="ZZZ-40821" GridPane.valignment="TOP" alignment="TOP_LEFT" GridPane.rowIndex="2" +    styleClass="text-medium, text-white"/> +  <Label fx:id="lEmployees" wrapText="true" alignment="TOP_LEFT" prefHeight="20" +    text="PERSONEN" GridPane.rowIndex="2" +    GridPane.columnIndex="2" styleClass="text-medium, text-white"/> -<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.RegistrationWindowController"> -   <children> -      <AnchorPane prefHeight="135.0" prefWidth="600.0"> -         <children> -            <Label layoutX="14.0" layoutY="14.0" text="Neue Anmeldung" /> -            <Label layoutX="14.0" layoutY="44.0" text="von" /> -            <Label layoutX="133.0" layoutY="44.0" text="bis" /> -            <ChoiceBox fx:id="cbStart" layoutX="42.0" layoutY="40.0" prefWidth="80.0" /> -            <ChoiceBox fx:id="cbEnd" layoutX="159.0" layoutY="40.0" prefWidth="80.0" /> -            <Label layoutX="10.0" layoutY="82.0" text="Fahrzeug" /> -            <Label fx:id="lVehicles" layoutX="10.0" layoutY="108.0" text="Fahrzeugname" /> -            <Label layoutX="216.0" layoutY="82.0" text="Personen" /> -            <Label fx:id="lEmployees" layoutX="216.0" layoutY="108.0" text="Namen" /> -         </children> -      </AnchorPane> -      <SplitPane dividerPositions="0.35" prefWidth="200.0"> -        <items> -            <VBox prefHeight="200.0" prefWidth="100.0"> -               <children> -                  <Label text="Fahrzeugsuche" /> -                  <TextField fx:id="tfVehicleSearch" /> -                  <TableView fx:id="tvVehicles" prefHeight="200.0" prefWidth="200.0"> -                    <columns> -                      <TableColumn fx:id="tcVehicles" prefWidth="75.0" text="Fahrzeuge" /> -                    </columns> -                     <columnResizePolicy> -                        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> -                     </columnResizePolicy> -                  </TableView> -               </children> -            </VBox> -            <VBox prefHeight="200.0" prefWidth="100.0"> -               <children> -                  <Label text="Personensuche" /> -                  <TextField fx:id="tfEmployeeSearch" /> -                  <TableView fx:id="tvEmployees" prefHeight="200.0" prefWidth="200.0"> -                    <columns> -                      <TableColumn fx:id="tcEmployees" prefWidth="75.0" text="Personen" /> -                    </columns> -                     <columnResizePolicy> -                        <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> -                     </columnResizePolicy> -                  </TableView> -               </children> -            </VBox> -        </items> -      </SplitPane> -      <HBox alignment="CENTER" prefWidth="200.0"> -         <children> -            <Button mnemonicParsing="false" onAction="#cancel" text="Abbrechen"> -               <HBox.margin> -                  <Insets bottom="8.0" left="8.0" right="8.0" top="8.0" /> -               </HBox.margin> -            </Button> -            <Button mnemonicParsing="false" onAction="#create" text="Erstellen"> -               <HBox.margin> -                  <Insets bottom="8.0" left="8.0" right="8.0" top="8.0" /> -               </HBox.margin> -            </Button> -         </children></HBox> -   </children> -</VBox> +  <ScrollPane GridPane.rowIndex="5" hbarPolicy="NEVER" vbarPolicy="ALWAYS" > +    <GridPane.margin> +      <Insets left="-7" right="-20" bottom="-12"/> +    </GridPane.margin> +    <VBox fx:id="vbVehicles" spacing="6"> +      <padding> +        <Insets top="6" left="6" right="6" bottom="6"/> +      </padding> +    </VBox> +  </ScrollPane> +  <ScrollPane fx:id="listEmployee" hbarPolicy="NEVER" vbarPolicy="ALWAYS" GridPane.rowIndex="5" GridPane.columnIndex="2"> +    <GridPane.margin> +      <Insets left="-7" right="-20" bottom="-12"/> +    </GridPane.margin> +  </ScrollPane> +  <VBox GridPane.rowIndex="4" spacing="6" styleClass="bg-white, shadowed"> +    <padding> +      <Insets topRightBottomLeft="6"/> +    </padding> +    <Label text="Fahrzeugsuche" styleClass="text-medium"/> +    <TextField fx:id="tfVehicleSearch" prefWidth="0" onKeyTyped="#tfVehicleSearch_TextChanged" styleClass="text-big, text-bold"/> +  </VBox> +  <VBox GridPane.rowIndex="4" spacing="6" GridPane.columnIndex="2" styleClass="bg-white, shadowed"> +    <padding> +      <Insets topRightBottomLeft="6"/> +    </padding> +    <Label text="Personensuche" styleClass="text-medium"/> +    <TextField fx:id="tfEmployeeSearch" onKeyTyped="#tfEmployeeSearch_TextChanged" styleClass="text-big, text-bold"/> +  </VBox> +</GridPane> diff --git a/src/main/resources/fxml/createCar.fxml b/src/main/resources/fxml/createCar.fxml index cefac82..399c9bc 100644 --- a/src/main/resources/fxml/createCar.fxml +++ b/src/main/resources/fxml/createCar.fxml @@ -3,16 +3,33 @@  <?import javafx.scene.control.Button?>  <?import javafx.scene.control.CheckBox?>  <?import javafx.scene.control.ChoiceBox?> +<?import javafx.scene.control.Hyperlink?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.ScrollPane?>  <?import javafx.scene.layout.AnchorPane?>  <?import javafx.scene.layout.FlowPane?> -<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateCarController"> +<AnchorPane fx:id="createCarAP" prefHeight="522.0" prefWidth="847.0" style="-fx-background-color: WHITE;" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.CreateCarController">     <children> -      <ChoiceBox fx:id="cmb_Ctyp" layoutX="14.0" layoutY="14.0" prefWidth="150.0" /> -      <ChoiceBox fx:id="cmb_typ" layoutX="191.0" layoutY="14.0" prefWidth="150.0" /> -      <Button fx:id="btn_cancel" layoutX="500.0" layoutY="14.0" mnemonicParsing="false" text="abbrechen" onAction="#cancelAction"/> -      <Button fx:id="btn_create" layoutX="500.0" layoutY="53.0" mnemonicParsing="false" onAction="#createCar" text="Erstellen" /> -      <CheckBox fx:id="cbx_NEF" layoutX="14.0" layoutY="57.0" mnemonicParsing="false" text="NEF - Halterung" /> -      <FlowPane fx:id="fp_vehicleList" layoutX="14.0" layoutY="94.0" prefHeight="298.0" prefWidth="571.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" /> +      <ScrollPane layoutX="29.0" layoutY="194.0" prefHeight="314.0" prefWidth="803.0"> +         <content> +            <FlowPane fx:id="fpVehicleList" prefHeight="312.0" prefWidth="787.0" /> +         </content> +      </ScrollPane> +      <AnchorPane prefHeight="87.0" prefWidth="847.0" styleClass="bg-light-orange"> +         <children> +            <Label layoutX="45.0" layoutY="26.0" styleClass="text-big" text="Fahrzeuge" textFill="WHITE" /> +            <Hyperlink fx:id="lBack" layoutX="749.0" layoutY="15.0" onAction="#backToMain" styleClass="text-big" text="zurück" textFill="WHITE" /> +         </children> +      </AnchorPane> +      <AnchorPane layoutX="29.0" layoutY="63.0" prefHeight="100.0" prefWidth="789.0" styleClass="bg-white, shadowed"> +         <children> +            <ChoiceBox fx:id="cmbCtype" layoutX="14.0" layoutY="26.0" prefWidth="150.0" styleClass="text-medium" /> +            <ChoiceBox fx:id="cmbTyp" layoutX="170.0" layoutY="26.0" prefWidth="150.0" styleClass="text-medium" /> +             +            <Button fx:id="btnCreate" layoutX="697.0" layoutY="54.0" mnemonicParsing="false" onAction="#createCar" prefHeight="31.0" prefWidth="78.0" styleClass="button-main,text-meium" text="Erstellen" /> +            <CheckBox fx:id="cbxNEF" layoutX="14.0" layoutY="69.0" mnemonicParsing="false" styleClass="text-medium" text="NEF - Halterung" /> +         </children> +      </AnchorPane>     </children>  </AnchorPane> diff --git a/src/main/resources/fxml/createNewEmployee.fxml b/src/main/resources/fxml/createNewEmployee.fxml index 4848c09..fd04ee1 100644 --- a/src/main/resources/fxml/createNewEmployee.fxml +++ b/src/main/resources/fxml/createNewEmployee.fxml @@ -8,16 +8,29 @@  <?import javafx.scene.control.TextField?>  <?import javafx.scene.layout.AnchorPane?> -<AnchorPane prefHeight="96.0" prefWidth="740.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.CreateNewEmployeeController"> -   <children> -      <Label fx:id="lblHeader" layoutX="14.0" layoutY="14.0" text="Neue Person erstellen" /> -      <Label layoutX="14.0" layoutY="38.0" text="Name" /> -      <Label layoutX="206.0" layoutY="38.0" text="Qualifikation" /> -      <CheckBox fx:id="inputIsDriver" layoutX="343.0" layoutY="37.0" mnemonicParsing="false" text="Fahrer" /> -      <CheckBox fx:id="inputIsPilot" layoutX="343.0" layoutY="62.0" mnemonicParsing="false" text="Pilot" /> -      <Hyperlink fx:id="btnCancel" layoutX="441.0" layoutY="31.0" onAction="#onCancelClicked" text="abbrechen" /> -      <Button fx:id="btnCreate" layoutX="441.0" layoutY="55.0" mnemonicParsing="false" onAction="#onCreateClicked" text="Erstellen" /> -      <TextField fx:id="inputName" layoutX="14.0" layoutY="57.0" prefHeight="25.0" prefWidth="179.0" /> -      <ChoiceBox fx:id="inputQualification" layoutX="199.0" layoutY="57.0" prefHeight="25.0" prefWidth="128.0" /> -   </children> +<AnchorPane fx:id="apCreateNewEmployee" prefHeight="100" +  prefWidth="${apCreateNewEmployee.parent.width}" styleClass="bg-edit-area-orange" +  stylesheets="@/styles/main.css" xmlns="http://javafx.com/javafx/9.0.1" +  xmlns:fx="http://javafx.com/fxml/1" +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.CreateNewEmployeeController"> +  <children> +    <Label fx:id="lblHeader" layoutX="14.0" layoutY="14.0" styleClass="text-bold, text-medium" +      text="Neue Person erstellen"/> +    <Label layoutX="14.0" layoutY="38.0" styleClass="text-small" text="Name"/> +    <Label layoutX="206.0" layoutY="38.0" styleClass="text-small" text="Qualifikation"/> +    <CheckBox fx:id="inputIsDriver" layoutX="355.0" layoutY="37.0" mnemonicParsing="false" +      styleClass="text-small" text="Fahrer"/> +    <CheckBox fx:id="inputIsPilot" layoutX="355.0" layoutY="62.0" mnemonicParsing="false" +      styleClass="text-small" text="Pilot"/> +    <Hyperlink fx:id="btnCancel" layoutX="441.0" layoutY="31.0" onAction="#onCancelClicked" +      styleClass="text-medium" text="abbrechen" textFill="black" AnchorPane.bottomAnchor="30.0" +      AnchorPane.rightAnchor="10.0"/> +    <Button fx:id="btnCreate" layoutX="441.0" layoutY="55.0" mnemonicParsing="false" +      onAction="#onCreateClicked" styleClass="button-main, bg-green, text-bold, text-big" +      text="ERSTELLEN" AnchorPane.bottomAnchor="-10.0" AnchorPane.rightAnchor="10.0"/> +    <TextField fx:id="inputName" layoutX="14.0" layoutY="57.0" prefHeight="25.0" prefWidth="179.0" +      style="-fx-background-color: transparent" styleClass="text-bold, text-medium"/> +    <ChoiceBox fx:id="inputQualification" layoutX="206.0" layoutY="57.0" prefHeight="25.0" +      prefWidth="128.0"/> +  </children>  </AnchorPane> diff --git a/src/main/resources/fxml/employeeList.fxml b/src/main/resources/fxml/employeeList.fxml new file mode 100644 index 0000000..85f693c --- /dev/null +++ b/src/main/resources/fxml/employeeList.fxml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.Insets?> +<?import javafx.scene.layout.FlowPane?> +<FlowPane +  xmlns="http://javafx.com/javafx/9.0.1" +  xmlns:fx="http://javafx.com/fxml/1" +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.EmployeeListController" +  fx:id="flowPaneEmployeeList" +  stylesheets="@/styles/main.css" +  prefWidth="${flowPaneEmployeeList.parent.width}" +  prefHeight="${flowPaneEmployeeList.parent.height}" +  styleClass="bg-gray-orange"> +  <padding> +    <Insets bottom="10.0"/> +  </padding> +</FlowPane> diff --git a/src/main/resources/fxml/employeeListItem.fxml b/src/main/resources/fxml/employeeListItem.fxml index 05354fc..7f6aabd 100644 --- a/src/main/resources/fxml/employeeListItem.fxml +++ b/src/main/resources/fxml/employeeListItem.fxml @@ -1,53 +1,56 @@  <?xml version="1.0" encoding="UTF-8"?> -<?import javafx.scene.control.Button?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.image.ImageView?>  <?import javafx.scene.layout.AnchorPane?>  <?import javafx.scene.layout.HBox?> -<?import javafx.scene.text.Font?>  <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" -  prefHeight="96.0" prefWidth="360.0" style="-fx-background-color: white;" +  onMouseClicked="#onEmployeeClicked" prefHeight="80.0" prefWidth="320.0" +  styleClass="bg-white, shadowed" stylesheets="@/styles/main.css"    xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" -  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.EmployeeListItemController"> +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.EmployeeListItemController">    <children> -    <Label fx:id="lblName" layoutX="8.0" layoutY="22.0" text="Peter Mustermann" -      AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="5.0"> -      <font> -        <Font name="System Bold" size="18.0"/> -      </font> +    <Label fx:id="lblName" layoutX="8.0" layoutY="22.0" styleClass="text-big, text-bold" +      text="Peter Mustermann" AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="5.0">      </Label> -    <Button layoutX="298.0" layoutY="5.0" mnemonicParsing="false" onAction="#onEditEmployeeClicked" -      text="bearbeiten" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="5.0"/> -    <HBox layoutX="10.0" layoutY="40.0" prefHeight="42.0" prefWidth="339.0" +    <HBox layoutX="10.0" layoutY="40.0" prefHeight="42.0" prefWidth="300.0"        AnchorPane.leftAnchor="10.0" AnchorPane.topAnchor="40.0">        <children> -        <AnchorPane prefHeight="42.0" prefWidth="112.0" style="-fx-background-color: white;"> +        <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" +          minWidth="-Infinity" prefHeight="42.0" prefWidth="100.0">            <children> -            <ImageView fx:id="imgQualification" fitHeight="25.0" fitWidth="25.0" layoutX="10.0" -              layoutY="11.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="10.0" -              AnchorPane.topAnchor="10.0"/> -            <Label fx:id="lblQualification" layoutX="45.0" layoutY="14.0" text="Notarzt" -              AnchorPane.leftAnchor="45.0" AnchorPane.topAnchor="14.0"/> +            <!-- TODO: update images to have transparent background! --> +            <ImageView fx:id="imgQualification" fitHeight="25.0" fitWidth="25.0" layoutX="2.0" +              pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="0.0" +              AnchorPane.topAnchor="0.0"/> +            <Label fx:id="lblQualification" layoutX="45.0" layoutY="14.0" styleClass="text-small" +              text="Notarzt" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="0.0"> +            </Label>            </children>          </AnchorPane> -        <AnchorPane prefHeight="42.0" prefWidth="112.0" style="-fx-background-color: white;"> +        <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" +          minWidth="-Infinity" prefHeight="42.0" prefWidth="100.0">            <children> +            <!-- TODO: update images to have transparent background! -->              <ImageView fx:id="imgPilot" fitHeight="25.0" fitWidth="25.0" layoutX="10.0" -              layoutY="11.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="10.0" -              AnchorPane.topAnchor="10.0"/> -            <Label fx:id="lblPilot" layoutX="53.0" layoutY="14.0" text="nicht Pilot" -              AnchorPane.leftAnchor="45.0" AnchorPane.topAnchor="14.0"/> +              layoutY="11.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="0.0" +              AnchorPane.topAnchor="0.0"/> +            <Label fx:id="lblPilot" layoutX="53.0" layoutY="14.0" styleClass="text-small" +              text="nicht Pilot" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="0.0"> +            </Label>            </children>          </AnchorPane> -        <AnchorPane prefHeight="42.0" prefWidth="112.0" style="-fx-background-color: white;"> +        <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" +          minWidth="-Infinity" prefHeight="42.0" prefWidth="100.0">            <children> +            <!-- TODO: update images to have transparent background! -->              <ImageView fx:id="imgDriver" fitHeight="25.0" fitWidth="25.0" layoutX="10.0" -              layoutY="11.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="10.0" -              AnchorPane.topAnchor="10.0"/> -            <Label fx:id="lblDriver" layoutX="54.0" layoutY="14.0" text="ist Fahrer" -              AnchorPane.leftAnchor="45.0" AnchorPane.topAnchor="14.0"/> +              layoutY="11.0" pickOnBounds="true" preserveRatio="true" AnchorPane.leftAnchor="0.0" +              AnchorPane.topAnchor="0.0"/> +            <Label fx:id="lblDriver" layoutX="54.0" layoutY="14.0" styleClass="text-small" +              text="ist Fahrer" AnchorPane.leftAnchor="30.0" AnchorPane.topAnchor="0.0"> +            </Label>            </children>          </AnchorPane>        </children> diff --git a/src/main/resources/fxml/filterEmployeesControl.fxml b/src/main/resources/fxml/filterEmployeesControl.fxml index 68a6f3e..8f7e72f 100644 --- a/src/main/resources/fxml/filterEmployeesControl.fxml +++ b/src/main/resources/fxml/filterEmployeesControl.fxml @@ -3,17 +3,31 @@  <?import javafx.scene.control.Button?>  <?import javafx.scene.control.Label?>  <?import javafx.scene.control.TextField?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?>  <?import javafx.scene.layout.AnchorPane?> - -<AnchorPane prefHeight="86.0" prefWidth="740.0" style="-fx-background-color: white;" +<AnchorPane fx:id="apFilterEmployees" prefHeight="80" prefWidth="${apFilterEmployees.parent.width}" +  style="-fx-background-color: white;" stylesheets="/styles/main.css"    xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" -  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.FilterEmployeesController"> +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.FilterEmployeesController">    <children> -    <Label layoutX="14.0" layoutY="14.0" text="Filtern nach Name"/> -    <TextField fx:id="inputFilterString" layoutX="22.0" layoutY="41.0" -      onKeyReleased="#onFilterTextChanged" promptText="Name eingeben"/> -    <Button layoutX="698.0" layoutY="48.0" mnemonicParsing="false" onAction="#onAddEmployeeClicked" -      onInputMethodTextChanged="#onFilterTextChanged" text="Person hinzufügen" -      AnchorPane.rightAnchor="10.0"/> +    <Label text="Filtern nach Name" AnchorPane.leftAnchor="20.0" +      AnchorPane.topAnchor="15.0" styleClass="text-medium, text-bold"/> +    <TextField fx:id="inputFilterString" +      onKeyReleased="#onFilterTextChanged" promptText="Name eingeben" +      styleClass="text-medium" +      AnchorPane.leftAnchor="20.0" AnchorPane.topAnchor="45.0"/> +    <Button mnemonicParsing="false" onAction="#onAddEmployeeClicked" +      onInputMethodTextChanged="#onFilterTextChanged" +      style="-fx-background-color: green; -fx-border-width: 1px; -fx-border-radius: 25px; -fx-background-radius: 25px; -fx-border-color: black; -fx-min-width: 50px; -fx-min-height: 50px; -fx-max-width: 50px; -fx-max-height: 50px;" +      AnchorPane.bottomAnchor="-10.0" AnchorPane.rightAnchor="10.0"> +      <graphic> +        <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true"> +          <image> +            <Image url="/images/PlusButton.png"/> +          </image> +        </ImageView> +      </graphic> +    </Button>    </children>  </AnchorPane> diff --git a/src/main/resources/fxml/listEmployees.fxml b/src/main/resources/fxml/listEmployees.fxml deleted file mode 100644 index ae815e1..0000000 --- a/src/main/resources/fxml/listEmployees.fxml +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.Insets?> -<?import javafx.scene.control.Label?> -<?import javafx.scene.control.ScrollPane?> -<?import javafx.scene.layout.AnchorPane?> -<?import javafx.scene.layout.FlowPane?> -<?import javafx.scene.layout.VBox?> -<?import javafx.scene.text.Font?> - -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" -  prefHeight="536.0" prefWidth="816.0" style="-fx-background-color: #EFEBE8;" -  xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" -  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.ListEmployeesController"> -  <children> -    <AnchorPane prefHeight="118.0" prefWidth="816.0" style="-fx-background-color: #C55A11;"> -      <children> -        <Label layoutX="39.0" layoutY="23.0" text="Personen" textFill="WHITE"> -          <font> -            <Font name="Calibri Bold" size="22.0"/> -          </font> -        </Label> -      </children> -    </AnchorPane> -    <VBox layoutX="37.0" layoutY="60.0" prefHeight="454.0" prefWidth="742.0"> -      <children> -        <AnchorPane fx:id="containerHeader" prefHeight="86.0" prefWidth="740.0" -          style="-fx-background-color: white; -fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 5);"/> -        <ScrollPane hbarPolicy="NEVER" style="-fx-background-color: #EFEBE8;" vbarPolicy="NEVER"> -          <VBox.margin> -            <Insets top="20.0"/> -          </VBox.margin> -          <content> -            <FlowPane fx:id="flowPaneEmployeeList" prefHeight="346.0" prefWidth="742.0" -              style="-fx-background-color: #EFEBE8;"/> -          </content> -        </ScrollPane> -      </children> -    </VBox> -  </children> -</AnchorPane> diff --git a/src/main/resources/fxml/manageEmployees.fxml b/src/main/resources/fxml/manageEmployees.fxml new file mode 100644 index 0000000..b0ce2fc --- /dev/null +++ b/src/main/resources/fxml/manageEmployees.fxml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Hyperlink?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.ScrollPane?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.VBox?> + +<AnchorPane fx:id="listEmployeesAP" prefHeight="536.0" prefWidth="702.0" styleClass="bg-gray-orange" +  stylesheets="@/styles/main.css" visible="false" xmlns="http://javafx.com/javafx/9.0.1" +  xmlns:fx="http://javafx.com/fxml/1" +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.ManageEmployeesController"> +  <children> +    <AnchorPane prefHeight="120.0" styleClass="bg-dark-orange" AnchorPane.leftAnchor="0.0" +      AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> +      <children> +        <Label styleClass="text-bold, text-big, text-white" text="Personen" +          AnchorPane.leftAnchor="25.0" AnchorPane.topAnchor="20.0"> +        </Label> +        <Hyperlink onAction="#backToMain" styleClass="text-medium, text-white" text="Zurück" +          AnchorPane.rightAnchor="25.0" AnchorPane.topAnchor="30.0"> +        </Hyperlink> +      </children> +    </AnchorPane> +    <VBox fx:id="containerVbox" alignment="BOTTOM_LEFT" rotate="180" AnchorPane.bottomAnchor="0.0" +      AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="60.0"> +      <children> +        <ScrollPane fx:id="employeeScrollPane" fitToHeight="true" fitToWidth="true" +          hbarPolicy="NEVER" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="336.0" +          prefWidth="662.0" rotate="180" vbarPolicy="NEVER"> +          <content> +            <fx:include fx:id="employeeList" source="employeeList.fxml"/> +          </content> +        </ScrollPane> +        <AnchorPane fx:id="containerHeader" minHeight="80.0" rotate="180" styleClass="shadowed" +          AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="0.0"/> +      </children> +    </VBox> +  </children> +</AnchorPane> diff --git a/src/main/resources/fxml/vehiclePane.fxml b/src/main/resources/fxml/vehiclePane.fxml index 784febc..752941a 100644 --- a/src/main/resources/fxml/vehiclePane.fxml +++ b/src/main/resources/fxml/vehiclePane.fxml @@ -1,65 +1,112 @@  <?xml version="1.0" encoding="UTF-8"?> +<?import java.lang.String?>  <?import javafx.geometry.Insets?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.Label?>  <?import javafx.scene.image.Image?>  <?import javafx.scene.image.ImageView?>  <?import javafx.scene.layout.ColumnConstraints?>  <?import javafx.scene.layout.GridPane?>  <?import javafx.scene.layout.RowConstraints?> +<?import javafx.scene.layout.VBox?>  <?import javafx.scene.text.Font?>  <?import javafx.scene.text.Text?>  <?import javafx.scene.text.TextFlow?> -<GridPane hgap="6.0" stylesheets="@/styles/main.css" styleClass="bg-white, shadowed" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller.VehiclePaneController"> +<?import javafx.scene.control.Label?> +<GridPane stylesheets="@/styles/main.css" minWidth="-Infinity" styleClass="bg-white, shadowed" +  xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1" +  fx:controller="at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.VehiclePaneController">    <columnConstraints> -    <ColumnConstraints /> -    <ColumnConstraints /> -    <ColumnConstraints /> -    <ColumnConstraints /> +    <ColumnConstraints/> +    <ColumnConstraints/> +    <ColumnConstraints prefWidth="60"/> +    <ColumnConstraints/>    </columnConstraints>    <rowConstraints> -    <RowConstraints /> -    <RowConstraints /> -    <RowConstraints /> -    <RowConstraints /> +    <RowConstraints/> +    <RowConstraints/> +    <RowConstraints/> +    <RowConstraints/>    </rowConstraints>    <padding> -    <Insets bottom="6.0" left="12.0" right="12.0" top="6.0" /> +    <Insets bottom="6.0" left="12.0" right="12.0" top="6.0"/>    </padding> -  <TextFlow GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.rowIndex="0"> -    <Text fx:id="txtType" text="RTW"> +  <!--<Text fx:id="txtType" text="NAH" GridPane.columnIndex="0" GridPane.columnSpan="2">--> +    <!--<font>--> +      <!--<Font name="System Bold" size="18.0"/>--> +    <!--</font>--> +  <!--</Text>--> +  <!--<Text fx:id="txtNumber" text="-10003" GridPane.halignment="LEFT" GridPane.columnIndex="2">--> +    <!--<font>--> +      <!--<Font size="16.0"/>--> +    <!--</font>--> +  <!--</Text>--> +  <TextFlow GridPane.columnIndex="0" GridPane.columnSpan="3" prefWidth="120"> +    <Text fx:id="txtType" text="RTWSDLK" >        <font> -        <Font name="System Bold" size="18.0" /> +        <Font name="System Bold" size="18.0"/>        </font>      </Text> -    <Text fx:id="txtNumber" text="-10003"> +    <Text fx:id="txtNumber" text="-1">        <font> -        <Font size="16.0" /> +        <Font size="16.0"/>        </font>      </Text>    </TextFlow> -  <ImageView fx:id="ivNEF" fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0" GridPane.rowIndex="1"> -    <Image url="@../images/NotNEF.png" /> +  <ImageView fx:id="ivNEF" fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" +    GridPane.columnIndex="0" GridPane.rowIndex="1"> +    <Image url="@../images/NotNEF.png"/>    </ImageView> -  <Text fx:id="txtNEF" text="keine NEF-Halterung" GridPane.columnIndex="1" GridPane.rowIndex="1"> +  <Text fx:id="txtNEF" text="keine NEF-Halterung" GridPane.columnIndex="1" GridPane.columnSpan="3" +    GridPane.rowIndex="1">      <font> -      <Font size="14.0" /> +      <Font size="14.0"/>      </font>    </Text> -  <ImageView fx:id="ivQualification" fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0" GridPane.rowIndex="2"> -    <Image url="@../images/Qualification.png" /> +  <ImageView fx:id="ivQualification" fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" +    preserveRatio="true" GridPane.columnIndex="0" GridPane.rowIndex="2"> +    <Image url="@../images/Qualification.png"/>    </ImageView> -  <Text fx:id="txtQualification" text="-" GridPane.columnIndex="1" GridPane.rowIndex="2"> +  <Text fx:id="txtQualification" text="-" GridPane.columnIndex="1" GridPane.columnSpan="3" +    GridPane.rowIndex="2">      <font> -      <Font size="14.0" /> +      <Font size="14.0"/>      </font>    </Text> -  <ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" GridPane.columnIndex="0" GridPane.rowIndex="3"> -    <Image url="@../images/Vehicle.png" /> +  <ImageView fitHeight="25.0" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" +    GridPane.columnIndex="0" GridPane.rowIndex="3"> +    <Image url="@../images/Vehicle.png"/> +    <GridPane.margin> +      <Insets right="6"/> +    </GridPane.margin>    </ImageView> -  <Text fx:id="txtRooftype" text="Hochdach" GridPane.columnIndex="1" GridPane.rowIndex="3"> +  <Text fx:id="txtRooftype" text="Mittelhochdach" GridPane.columnIndex="1" GridPane.columnSpan="3" +    GridPane.rowIndex="3">      <font> -      <Font size="14.0" /> +      <Font size="14.0"/>      </font>    </Text> +  <Label fx:id="txtStatus" text="ZUM_BERUFUNGSORT" prefWidth="100" alignment="CENTER" +    GridPane.valignment="CENTER" GridPane.columnIndex="3" +    GridPane.rowIndex="0" styleClass="text-medium, button"> +    <GridPane.margin> +      <Insets left="12"/> +    </GridPane.margin> +    <padding> +      <Insets topRightBottomLeft="3"/> +    </padding> +  </Label> +   <VBox alignment="CENTER_RIGHT" GridPane.columnIndex="3" GridPane.rowIndex="2"> +      <children> +         <Button fx:id="btnRequest" alignment="CENTER" mnemonicParsing="false" prefWidth="100.0" text="Nachfordern"> +            <styleClass> +               <String fx:value="text-medium" /> +               <String fx:value="button" /> +               <String fx:value="button-main" /> +            </styleClass> +         </Button> +      </children> +   </VBox>  </GridPane> diff --git a/src/main/resources/images/Driver.png b/src/main/resources/images/Driver.pngBinary files differ index 55d4f4a..3fd4394 100644 --- a/src/main/resources/images/Driver.png +++ b/src/main/resources/images/Driver.png diff --git a/src/main/resources/images/NotDriver.png b/src/main/resources/images/NotDriver.pngBinary files differ index b8492aa..e2d699d 100644 --- a/src/main/resources/images/NotDriver.png +++ b/src/main/resources/images/NotDriver.png diff --git a/src/main/resources/images/NotPilot.png b/src/main/resources/images/NotPilot.pngBinary files differ index 22d039f..c1a2aaf 100644 --- a/src/main/resources/images/NotPilot.png +++ b/src/main/resources/images/NotPilot.png diff --git a/src/main/resources/images/Pilot.png b/src/main/resources/images/Pilot.pngBinary files differ index 18049e8..173d9fd 100644 --- a/src/main/resources/images/Pilot.png +++ b/src/main/resources/images/Pilot.png diff --git a/src/main/resources/images/PlusButton.png b/src/main/resources/images/PlusButton.pngBinary files differ new file mode 100644 index 0000000..5bc51e7 --- /dev/null +++ b/src/main/resources/images/PlusButton.png diff --git a/src/main/resources/images/Qualification.png b/src/main/resources/images/Qualification.pngBinary files differ index c58a640..cb0965f 100644 --- a/src/main/resources/images/Qualification.png +++ b/src/main/resources/images/Qualification.png diff --git a/src/main/resources/images/Vehicle.png b/src/main/resources/images/Vehicle.pngBinary files differ index 2fe992d..9019ddf 100644 --- a/src/main/resources/images/Vehicle.png +++ b/src/main/resources/images/Vehicle.png diff --git a/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql b/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql deleted file mode 100644 index f43b641..0000000 --- a/src/main/resources/sql/H2RegistrationDAOTest_depopulate.sql +++ /dev/null @@ -1,5 +0,0 @@ -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 deleted file mode 100644 index 7e7b428..0000000 --- a/src/main/resources/sql/H2RegistrationDAOTest_populate.sql +++ /dev/null @@ -1,15 +0,0 @@ -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); -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 diff --git a/src/main/resources/sql/database.sql b/src/main/resources/sql/database.sql index 463e8ac..c7a99b5 100644 --- a/src/main/resources/sql/database.sql +++ b/src/main/resources/sql/database.sql @@ -33,8 +33,8 @@ 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, +  start TIMESTAMP WITH TIME ZONE NOT NULL, +  end TIMESTAMP WITH TIME ZONE NOT NULL,    active BOOLEAN NOT NULL,    FOREIGN KEY (vehicleId) REFERENCES VehicleVersion(id),    FOREIGN KEY (employeeId) REFERENCES EmployeeVersion(id), @@ -44,7 +44,7 @@ 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, +  created TIMESTAMP WITH TIME ZONE NOT NULL,    destination VARCHAR(100) NOT NULL,    additionalInfo VARCHAR(100),    status ENUM('ACTIVE', 'COMPLETED', 'CANCELLED'), diff --git a/src/main/resources/sql/testdata.sql b/src/main/resources/sql/testdata.sql new file mode 100644 index 0000000..ba32d0b --- /dev/null +++ b/src/main/resources/sql/testdata.sql @@ -0,0 +1,792 @@ +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (1, 'Klara Steiner', '1961-03-01', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (2, 'Theo Schneider', '1970-11-16', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (3, 'Cristiano Moser', '1970-12-20', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (4, 'Ahmad Schneider', '1959-12-09', 'NKV', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (5, 'Angel Auer', '1966-03-07', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (6, 'Levin Winter', '1963-09-01', 'NKI', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (7, 'Koray Bauer', '1969-12-25', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (8, 'Ceren Steiner', '1987-02-28', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (9, 'Eren Schwarz', '1975-03-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (10, 'Sofie Ebner', '1988-01-08', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (11, 'Timo Ebner', '1984-11-14', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (12, 'Otto Schmidt', '1969-12-25', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (13, 'Franz Auer', '1975-06-17', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (14, 'Livia Schmid', '1974-05-23', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (15, 'Levin Müller', '1980-12-14', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (16, 'Ronja Haas', '1955-11-11', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (17, 'Alan Maier', '1973-08-19', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (18, 'Melissa Wieser', '1986-04-21', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (19, 'Mina Stadler', '1988-09-30', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (20, 'August Holzer', '1972-01-29', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (21, 'Gloria Hofer', '1990-05-25', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (22, 'Mahmud Müller', '1970-04-26', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (23, 'Magdalena Koller', '1972-03-08', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (24, 'Zoé Moser', '1979-01-26', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (25, 'Jasper Strasser', '1998-09-07', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (26, 'Hannah Leitner', '1965-07-30', 'NKV', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (27, 'Metehan Auer', '1986-08-28', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (28, 'Hüseyin Eder', '1991-01-21', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (29, 'Gabriel Pichler', '1970-06-30', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (30, 'Melina Wimmer', '1955-01-14', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (31, 'Felix Holzer', '1969-12-14', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (32, 'Leonit Lang', '1989-07-18', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (33, 'Lorena Maier', '1968-04-25', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (34, 'Alejandro Gruber', '1960-11-26', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (35, 'Angel Lechner', '1982-10-29', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (36, 'Natalia Maurer', '1955-08-30', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (37, 'Iris Schmidt', '1999-01-09', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (38, 'Lejla Huber', '1986-08-28', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (39, 'Bernadette Lechner', '1964-06-26', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (40, 'Leonis Baumgartner', '1963-06-22', 'NKV', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (41, 'Zuzanna Lehner', '1999-11-27', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (42, 'Charlotte Wieser', '1973-07-28', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (43, 'Emre Müller', '1955-04-12', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (44, 'Ferhat Müller', '1994-09-28', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (45, 'Eliza Haas', '1963-11-15', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (46, 'Nils Riegler', '1972-10-02', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (47, 'Henry Holzer', '1971-08-14', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (48, 'Elise Gruber', '1966-03-31', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (49, 'Amina Schneider', '1983-09-24', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (50, 'Halima Holzer', '1972-08-17', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (51, 'Laetitia Wieser', '1975-08-24', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (52, 'Zuzanna Schwarz', '1966-01-16', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (53, 'Antonia Reiter', '1973-01-15', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (54, 'Wojciech Strasser', '1964-02-28', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (55, 'Samuel Mayr', '1988-03-03', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (56, 'Marla Ebner', '1986-01-01', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (57, 'Vasilije Mayr', '1969-10-01', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (58, 'Simon Reiter', '1984-06-11', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (59, 'Brian Müller', '1990-01-25', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (60, 'Lieselotte Lehner', '1989-02-05', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (61, 'Aaron Wimmer', '1956-09-19', 'NKV', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (62, 'Mahdi Mair', '1963-04-28', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (63, 'Bogdan Haider', '1983-12-23', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (64, 'Olivier Schmidt', '1993-06-29', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (65, 'Anita Stadler', '1956-12-14', 'NKV', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (66, 'Stella Riegler', '1972-02-25', 'NA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (67, 'Niklas Ebner', '1984-04-19', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (68, 'Artur Bauer', '1969-12-27', 'NA', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (69, 'Florian Eder', '1957-06-14', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (70, 'Jennifer Hofer', '1979-12-05', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (71, 'Kian Baumgartner', '1992-08-07', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (72, 'Jakub Mayr', '1959-08-11', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (73, 'Melissa Maier', '1988-12-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (74, 'Agnes Schneider', '1972-04-14', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (75, 'Nadin Riegler', '1957-02-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (76, 'Lian Gruber', '1979-12-14', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (77, 'Farhan Mair', '1976-07-07', 'NKA', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (78, 'Nicole Haider', '1972-12-10', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (79, 'Jason Lechner', '1971-08-14', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (80, 'Amelie Huber', '1997-10-05', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (81, 'Angelo Holzer', '1961-08-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (82, 'Eda Fischer', '1966-06-21', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (83, 'Meyra Gruber', '1968-09-17', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (84, 'Jelena Haas', '1965-08-14', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (85, 'Luca Winter', '1986-03-25', 'NA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (86, 'Ilyas Lechner', '1960-12-16', 'NKI', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (87, 'Ayse Wieser', '1999-10-21', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (88, 'Esther Leitner', '1969-09-27', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (89, 'Carl Winkler', '1993-11-19', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (90, 'Ayleen Gruber', '1956-04-12', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (91, 'Lieselotte Müller', '1966-11-25', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (92, 'Leyla Riegler', '1957-06-12', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (93, 'Hugo Wieser', '1987-12-22', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (94, 'Batuhan Hofer', '1986-01-10', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (95, 'Isa Baumgartner', '1988-01-04', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (96, 'Johann Fischer', '1973-08-23', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (97, 'Kalina Haider', '2000-01-13', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (98, 'Alicia Weiss', '1979-05-06', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (99, 'Amir Winkler', '1980-11-08', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (100, 'Harun Wolf', '1980-06-14', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (101, 'Luise Brunner', '1983-12-03', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (102, 'Kardelen Ebner', '1993-01-12', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (103, 'Katharina Binder', '1956-09-18', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (104, 'Hatice Reiter', '1983-04-08', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (105, 'Tiana Wolf', '1967-08-28', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (106, 'Tom Reiter', '1976-12-04', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (107, 'Stella Egger', '1987-08-04', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (108, 'Ilyas Huber', '1988-09-30', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (109, 'Dawid Aigner', '1965-08-30', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (110, 'Serafina Hofer', '1965-01-31', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (111, 'Noel Schwarz', '1976-07-27', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (112, 'Tarik Eder', '1982-07-10', 'NA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (113, 'Alisa Maurer', '1985-03-19', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (114, 'Leonora Steiner', '1997-06-02', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (115, 'Eldar Baumgartner', '1979-09-25', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (116, 'Violetta Bauer', '1993-12-27', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (117, 'Adele Wagner', '1988-06-11', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (118, 'Eleonore Holzer', '1987-08-04', 'NKA', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (119, 'Lias Maier', '1980-11-09', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (120, 'Noam Wagner', '1955-04-21', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (121, 'Amely Maurer', '1987-04-14', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (122, 'Mateo Moser', '1967-03-07', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (123, 'Anas Weiss', '1966-04-15', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (124, 'Cansu Schwarz', '1974-06-13', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (125, 'Hacai Schwarz', '1988-12-21', 'NA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (126, 'Samuel Bauer', '1974-05-02', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (127, 'Niko Pichler', '1974-01-25', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (128, 'Romeo Bauer', '1987-06-17', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (129, 'Marie Koller', '1996-05-22', 'NKI', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (130, 'Albert Huber', '1976-08-09', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (131, 'Isabella Schwarz', '1987-03-02', 'RS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (132, 'Hava Brunner', '1993-05-24', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (133, 'Ricardo Winter', '1997-07-07', 'NKA', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (134, 'Hugo Schuster', '1986-02-07', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (135, 'Elin Auer', '1977-06-17', 'NFS', true, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (136, 'Philipp Egger', '1969-01-26', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (137, 'Iva Auer', '1961-10-16', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (138, 'Elif Brunner', '1991-11-21', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (139, 'Teresa Schneider', '1967-10-15', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (140, 'Nour Haider', '1956-12-01', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (141, 'Nathalie Winter', '1990-02-12', 'NKA', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (142, 'Vladimir Winkler', '1979-01-25', 'NKI', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (143, 'Joshua Fuchs', '1979-03-02', 'NFS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (144, 'Yannis Wallner', '1960-12-30', 'NKV', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (145, 'Nikola Wagner', '1975-09-05', 'RS', true, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (146, 'Antonia Bauer', '2000-10-11', 'NFS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (147, 'Solomon Lehner', '1960-04-08', 'NFS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (148, 'Youssef Riegler', '1978-04-04', 'RS', false, false); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (149, 'Umut Strasser', '1999-06-01', 'RS', false, true); +insert into EmployeeVersion (id, name, birthday, educationLevel, isDriver, isPilot) values (150, 'Ensar Eder', '1966-11-11', 'NKA', true, true); + + +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 Employee (id, version) values (4, 4); +insert into Employee (id, version) values (5, 5); +insert into Employee (id, version) values (6, 6); +insert into Employee (id, version) values (7, 7); +insert into Employee (id, version) values (8, 8); +insert into Employee (id, version) values (9, 9); +insert into Employee (id, version) values (10, 10); +insert into Employee (id, version) values (11, 11); +insert into Employee (id, version) values (12, 12); +insert into Employee (id, version) values (13, 13); +insert into Employee (id, version) values (14, 14); +insert into Employee (id, version) values (15, 15); +insert into Employee (id, version) values (16, 16); +insert into Employee (id, version) values (17, 17); +insert into Employee (id, version) values (18, 18); +insert into Employee (id, version) values (19, 19); +insert into Employee (id, version) values (20, 20); +insert into Employee (id, version) values (21, 21); +insert into Employee (id, version) values (22, 22); +insert into Employee (id, version) values (23, 23); +insert into Employee (id, version) values (24, 24); +insert into Employee (id, version) values (25, 25); +insert into Employee (id, version) values (26, 26); +insert into Employee (id, version) values (27, 27); +insert into Employee (id, version) values (28, 28); +insert into Employee (id, version) values (29, 29); +insert into Employee (id, version) values (30, 30); +insert into Employee (id, version) values (31, 31); +insert into Employee (id, version) values (32, 32); +insert into Employee (id, version) values (33, 33); +insert into Employee (id, version) values (34, 34); +insert into Employee (id, version) values (35, 35); +insert into Employee (id, version) values (36, 36); +insert into Employee (id, version) values (37, 37); +insert into Employee (id, version) values (38, 38); +insert into Employee (id, version) values (39, 39); +insert into Employee (id, version) values (40, 40); +insert into Employee (id, version) values (41, 41); +insert into Employee (id, version) values (42, 42); +insert into Employee (id, version) values (43, 43); +insert into Employee (id, version) values (44, 44); +insert into Employee (id, version) values (45, 45); +insert into Employee (id, version) values (46, 46); +insert into Employee (id, version) values (47, 47); +insert into Employee (id, version) values (48, 48); +insert into Employee (id, version) values (49, 49); +insert into Employee (id, version) values (50, 50); +insert into Employee (id, version) values (51, 51); +insert into Employee (id, version) values (52, 52); +insert into Employee (id, version) values (53, 53); +insert into Employee (id, version) values (54, 54); +insert into Employee (id, version) values (55, 55); +insert into Employee (id, version) values (56, 56); +insert into Employee (id, version) values (57, 57); +insert into Employee (id, version) values (58, 58); +insert into Employee (id, version) values (59, 59); +insert into Employee (id, version) values (60, 60); +insert into Employee (id, version) values (61, 61); +insert into Employee (id, version) values (62, 62); +insert into Employee (id, version) values (63, 63); +insert into Employee (id, version) values (64, 64); +insert into Employee (id, version) values (65, 65); +insert into Employee (id, version) values (66, 66); +insert into Employee (id, version) values (67, 67); +insert into Employee (id, version) values (68, 68); +insert into Employee (id, version) values (69, 69); +insert into Employee (id, version) values (70, 70); +insert into Employee (id, version) values (71, 71); +insert into Employee (id, version) values (72, 72); +insert into Employee (id, version) values (73, 73); +insert into Employee (id, version) values (74, 74); +insert into Employee (id, version) values (75, 75); +insert into Employee (id, version) values (76, 76); +insert into Employee (id, version) values (77, 77); +insert into Employee (id, version) values (78, 78); +insert into Employee (id, version) values (79, 79); +insert into Employee (id, version) values (80, 80); +insert into Employee (id, version) values (81, 81); +insert into Employee (id, version) values (82, 82); +insert into Employee (id, version) values (83, 83); +insert into Employee (id, version) values (84, 84); +insert into Employee (id, version) values (85, 85); +insert into Employee (id, version) values (86, 86); +insert into Employee (id, version) values (87, 87); +insert into Employee (id, version) values (88, 88); +insert into Employee (id, version) values (89, 89); +insert into Employee (id, version) values (90, 90); +insert into Employee (id, version) values (91, 91); +insert into Employee (id, version) values (92, 92); +insert into Employee (id, version) values (93, 93); +insert into Employee (id, version) values (94, 94); +insert into Employee (id, version) values (95, 95); +insert into Employee (id, version) values (96, 96); +insert into Employee (id, version) values (97, 97); +insert into Employee (id, version) values (98, 98); +insert into Employee (id, version) values (99, 99); +insert into Employee (id, version) values (100, 100); +insert into Employee (id, version) values (101, 101); +insert into Employee (id, version) values (102, 102); +insert into Employee (id, version) values (103, 103); +insert into Employee (id, version) values (104, 104); +insert into Employee (id, version) values (105, 105); +insert into Employee (id, version) values (106, 106); +insert into Employee (id, version) values (107, 107); +insert into Employee (id, version) values (108, 108); +insert into Employee (id, version) values (109, 109); +insert into Employee (id, version) values (110, 110); +insert into Employee (id, version) values (111, 111); +insert into Employee (id, version) values (112, 112); +insert into Employee (id, version) values (113, 113); +insert into Employee (id, version) values (114, 114); +insert into Employee (id, version) values (115, 115); +insert into Employee (id, version) values (116, 116); +insert into Employee (id, version) values (117, 117); +insert into Employee (id, version) values (118, 118); +insert into Employee (id, version) values (119, 119); +insert into Employee (id, version) values (120, 120); +insert into Employee (id, version) values (121, 121); +insert into Employee (id, version) values (122, 122); +insert into Employee (id, version) values (123, 123); +insert into Employee (id, version) values (124, 124); +insert into Employee (id, version) values (125, 125); +insert into Employee (id, version) values (126, 126); +insert into Employee (id, version) values (127, 127); +insert into Employee (id, version) values (128, 128); +insert into Employee (id, version) values (129, 129); +insert into Employee (id, version) values (130, 130); +insert into Employee (id, version) values (131, 131); +insert into Employee (id, version) values (132, 132); +insert into Employee (id, version) values (133, 133); +insert into Employee (id, version) values (134, 134); +insert into Employee (id, version) values (135, 135); +insert into Employee (id, version) values (136, 136); +insert into Employee (id, version) values (137, 137); +insert into Employee (id, version) values (138, 138); +insert into Employee (id, version) values (139, 139); +insert into Employee (id, version) values (140, 140); +insert into Employee (id, version) values (141, 141); +insert into Employee (id, version) values (142, 142); +insert into Employee (id, version) values (143, 143); +insert into Employee (id, version) values (144, 144); +insert into Employee (id, version) values (145, 145); +insert into Employee (id, version) values (146, 146); +insert into Employee (id, version) values (147, 147); +insert into Employee (id, version) values (148, 148); +insert into Employee (id, version) values (149, 149); +insert into Employee (id, version) values (150, 150); + + +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (1, 'BKTW', 'NORMAL', 'BKTW-1', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (2, 'KTW', 'MITTELHOCHDACH', 'KTW-2', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (3, 'KTW', 'MITTELHOCHDACH', 'KTW-3', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (4, 'BKTW', 'NORMAL', 'BKTW-4', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (5, 'RTW', 'HOCHDACH', 'RTW-5', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (6, 'RTW', 'HOCHDACH', 'RTW-6', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (7, 'BKTW', 'NORMAL', 'BKTW-7', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (8, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-8', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (9, 'RTW', 'HOCHDACH', 'RTW-9', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (10, 'RTW', 'HOCHDACH', 'RTW-10', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (11, 'RTW', 'HOCHDACH', 'RTW-11', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (12, 'RTW', 'HOCHDACH', 'RTW-12', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (13, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-13', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (14, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-14', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (15, 'BKTW', 'NORMAL', 'BKTW-15', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (16, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-16', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (17, 'KTW', 'MITTELHOCHDACH', 'KTW-17', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (18, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-18', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (19, 'RTW', 'HOCHDACH', 'RTW-19', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (20, 'RTW', 'HOCHDACH', 'RTW-20', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (21, 'RTW', 'HOCHDACH', 'RTW-21', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (22, 'BKTW', 'NORMAL', 'BKTW-22', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (23, 'RTW', 'HOCHDACH', 'RTW-23', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (24, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-24', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (25, 'KTW', 'MITTELHOCHDACH', 'KTW-25', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (26, 'RTW', 'HOCHDACH', 'RTW-26', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (27, 'KTW', 'MITTELHOCHDACH', 'KTW-27', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (28, 'KTW', 'MITTELHOCHDACH', 'KTW-28', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (29, 'BKTW', 'NORMAL', 'BKTW-29', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (30, 'RTW', 'HOCHDACH', 'RTW-30', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (31, 'RTW', 'HOCHDACH', 'RTW-31', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (32, 'RTW', 'HOCHDACH', 'RTW-32', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (33, 'RTW', 'HOCHDACH', 'RTW-33', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (34, 'KTW', 'MITTELHOCHDACH', 'KTW-34', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (35, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-35', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (36, 'RTW', 'HOCHDACH', 'RTW-36', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (37, 'RTW', 'HOCHDACH', 'RTW-37', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (38, 'BKTW', 'NORMAL', 'BKTW-38', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (39, 'KTW_B', 'MITTELHOCHDACH', 'KTW_B-39', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (40, 'RTW', 'HOCHDACH', 'RTW-40', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (41, 'RTW', 'HOCHDACH', 'RTW-41', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (42, 'KTW', 'MITTELHOCHDACH', 'KTW-42', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (43, 'RTW', 'HOCHDACH', 'RTW-43', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (44, 'RTW', 'HOCHDACH', 'RTW-44', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (45, 'RTW', 'HOCHDACH', 'RTW-45', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (46, 'RTW', 'HOCHDACH', 'RTW-46', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (47, 'KTW', 'MITTELHOCHDACH', 'KTW-47', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (48, 'BKTW', 'NORMAL', 'BKTW-48', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (49, 'RTW', 'HOCHDACH', 'RTW-49', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (50, 'RTW', 'HOCHDACH', 'RTW-50', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (51, 'NEF', 'NORMAL', 'NEF-51', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (52, 'NEF', 'NORMAL', 'NEF-52', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (53, 'NEF', 'NORMAL', 'NEF-53', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (54, 'NEF', 'NORMAL', 'NEF-54', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (55, 'NEF', 'NORMAL', 'NEF-55', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (56, 'NEF', 'NORMAL', 'NEF-56', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (57, 'NEF', 'NORMAL', 'NEF-57', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (58, 'NEF', 'NORMAL', 'NEF-58', false); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (59, 'NAH', 'NORMAL', 'NAH-59', true); +insert into VehicleVersion (id, type, constructionType, name, hasNef) values (60, 'NAH', 'NORMAL', 'NAH-60', true); + + +insert into Vehicle (id, version, status) values (1, 1, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (2, 2, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (3, 3, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (4, 4, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (5, 5, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (6, 6, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (7, 7, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (8, 8, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (9, 9, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (10, 10, 'ZUM_ZIELORT'); +insert into Vehicle (id, version, status) values (11, 11, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (12, 12, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (13, 13, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (14, 14, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (15, 15, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (16, 16, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (17, 17, 'ZUM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (18, 18, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (19, 19, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (20, 20, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (21, 21, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (22, 22, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (23, 23, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (24, 24, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (25, 25, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (26, 26, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (27, 27, 'AM_ZIELORT'); +insert into Vehicle (id, version, status) values (28, 28, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (29, 29, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (30, 30, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (31, 31, 'ZUM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (32, 32, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (33, 33, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (34, 34, 'AM_ZIELORT'); +insert into Vehicle (id, version, status) values (35, 35, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (36, 36, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (37, 37, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (38, 38, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (39, 39, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (40, 40, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (41, 41, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (42, 42, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (43, 43, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (44, 44, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (45, 45, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (46, 46, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (47, 47, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (48, 48, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (49, 49, 'AM_BERUFUNGSORT'); +insert into Vehicle (id, version, status) values (50, 50, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (51, 51, 'ZUM_ZIELORT'); +insert into Vehicle (id, version, status) values (52, 52, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (53, 53, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (54, 54, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (55, 55, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (56, 56, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (57, 57, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (58, 58, 'ABGEMELDET'); +insert into Vehicle (id, version, status) values (59, 59, 'FREI_WACHE'); +insert into Vehicle (id, version, status) values (60, 60, 'FREI_WACHE'); + + +insert into Registration (id, vehicleId, employeeId, start, end, active) values (1, 5, 2, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (2, 5, 4, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (3, 46, 13, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (4, 46, 32, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (5, 32, 44, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (6, 32, 51, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (7, 45, 37, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (8, 45, 49, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (9, 14, 34, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (10, 14, 9, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (11, 11, 78, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (12, 11, 84, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (13, 47, 62, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (14, 47, 63, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (15, 41, 92, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (16, 41, 93, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (17, 50, 117, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (18, 50, 116, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (19, 17, 134, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (20, 17, 135, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (21, 42, 149, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (22, 42, 150, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (23, 12, 139, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (24, 12, 140, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (25, 34, 111, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (26, 34, 113, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (27, 22, 131, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (28, 31, 70, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (29, 31, 69, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (30, 38, 88, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (31, 49, 19, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (32, 49, 20, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (33, 40, 55, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (34, 40, 56, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (35, 26, 42, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (36, 26, 67, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (37, 36, 11, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (38, 36, 12, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (39, 37, 33, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (40, 37, 34, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (41, 37, 15, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (42, 20, 65, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (43, 20, 74, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (44, 44, 123, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (45, 44, 124, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (46, 28, 126, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (47, 28, 127, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (48, 10, 144, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (49, 10, 145, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (50, 2, 71, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (51, 2, 4, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (52, 23, 7, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (53, 23, 8, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (54, 9, 10, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (55, 9, 31, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (56, 59, 6, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (57, 59, 22, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (58, 59, 39, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (59, 60, 53, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (60, 60, 54, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (61, 60, 66, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (62, 51, 83, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (63, 51, 112, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (64, 52, 129, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (65, 52, 125, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (66, 53, 38, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (67, 53, 85, '2000-06-14 14:00:00.0', '2018-06-23 14:00:00.0', true); +/*insert into Registration (id, vehicleId, employeeId, start, end, active) values (68, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (69, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (70, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (71, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (72, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (73, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (74, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (75, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (76, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (77, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (78, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (79, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (80, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (81, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (82, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (83, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (84, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (85, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (86, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (87, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (88, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (89, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (90, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (91, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (92, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (93, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (94, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (95, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (96, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (97, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (98, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (99, , , , , true); +insert into Registration (id, vehicleId, employeeId, start, end, active) values (100, , , , , true);*/ + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (1, 'A', 'RD-10A4V', '2017-12-02T06:12:21Z', 'Ing.-Etzel-Straße 103', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (2, 'A', 'RD-26A6J', '2017-11-13T00:12:45Z', 'Fuggergasse 96', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (3, 'C', 'RD-65C9M', '2017-07-31T19:08:42Z', 'Gsetzbichlweg 128', 'Junction', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (4, 'A', 'RD-51A8F', '2018-04-15T08:45:33Z', 'Gutenbergstraße 143', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (5, 'C', 'RD-18C3J', '2017-07-25T03:15:18Z', 'Karl-Kapferer-Straße 87', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (6, 'A', 'RD-93A4D', '2017-11-07T22:33:38Z', 'Griesauweg 109', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (7, 'O', 'RD-70O3C', '2017-08-16T20:18:10Z', 'Ing.-Etzel-Straße 16', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (8, 'B', 'RD-76B9M', '2017-12-24T18:59:08Z', 'Erlerstraße 52', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (9, 'E', 'RD-40E5B', '2017-11-15T02:23:19Z', 'Gsetzbichlweg 29', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (10, 'O', 'RD-70O2F', '2018-05-20T10:57:13Z', 'Fennerstraße 83', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (11, 'A', 'RD-35A7U', '2018-05-27T04:41:52Z', 'Meinhardstraße 18', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (12, 'A', 'RD-22A8J', '2017-08-11T07:22:54Z', 'Botenthalweg 92', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (13, 'A', 'RD-43A6K', '2017-06-29T00:40:23Z', 'Arzler Straße 148', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (14, 'C', 'RD-74C8K', '2018-04-03T04:38:37Z', 'Schlerngasse 36', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (15, 'C', 'RD-93C6T', '2017-11-30T18:39:02Z', 'Am Roßsprung 79', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (16, 'D', 'RD-35D8P', '2017-12-08T23:39:15Z', 'Dörrstraße 124', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (17, 'A', 'RD-26A9L', '2017-08-05T18:25:13Z', 'Fallmerayerstraße 105', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (18, 'E', 'RD-57E7X', '2017-08-12T06:26:53Z', 'Feldstraße 67', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (19, 'B', 'RD-84B8A', '2018-06-09T07:45:21Z', 'Philippine-Welser-Straße 16', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (20, 'C', 'RD-99C9L', '2018-04-28T16:41:06Z', 'Schwindstraße 138', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (21, 'C', 'RD-85C9X', '2017-11-01T11:30:21Z', 'Hocheggweg 18', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (22, 'A', 'RD-16A4K', '2018-05-03T01:57:10Z', 'Siegmairstraße 61', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (23, 'B', 'RD-59B5Y', '2017-12-01T13:41:55Z', 'Dr.-Ferdinand-Kogler-Straße 36', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (24, 'C', 'RD-36C4V', '2018-05-02T14:45:08Z', 'Finkenbergweg 83', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (25, 'A', 'RD-54A3B', '2018-01-27T13:02:43Z', 'Innbrücke 116', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (26, 'A', 'RD-00A0Z', '2017-07-05T10:36:42Z', 'Mentlgasse 132', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (27, 'B', 'RD-99B3Z', '2017-10-31T13:58:54Z', 'Brixner Straße 70', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (28, 'E', 'RD-21E4B', '2018-03-06T15:19:53Z', 'Höttinger Gasse 116', 'Alley', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (29, 'A', 'RD-68A4E', '2017-07-16T11:54:29Z', 'Hirschberggasse 70', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (30, 'A', 'RD-44A9N', '2017-11-16T22:07:30Z', 'Etrichgasse 144', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (31, 'B', 'RD-28B1U', '2017-10-31T23:40:33Z', 'Karl-Rahner-Platz 135', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (32, 'A', 'RD-19A8V', '2017-07-13T02:46:28Z', 'Pechestraße 103', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (33, 'B', 'RD-03B9Q', '2017-08-21T06:54:03Z', 'Luis-Zuegg-Straße 118', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (34, 'A', 'RD-33A0C', '2017-12-16T13:31:21Z', 'Hutterweg 63', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (35, 'A', 'RD-54A1E', '2017-11-18T01:08:02Z', 'Universitätsstraße 53', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (36, 'B', 'RD-11B9D', '2017-07-16T14:58:14Z', 'Heiligwasserwiese 6', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (37, 'A', 'RD-20A7H', '2018-04-12T17:25:55Z', 'Ing.-Sigl-Straße 41', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (38, 'B', 'RD-74B2N', '2018-06-15T15:33:35Z', 'Gumppstraße 78', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (39, 'A', 'RD-14A2U', '2018-04-13T11:12:04Z', 'Kohlstattgasse 84', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (40, 'O', 'RD-85O8J', '2018-04-07T17:02:42Z', 'Renkstraße 100', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (41, 'B', 'RD-17B8G', '2017-11-12T07:42:07Z', 'Maria-Theresien-Straße 22', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (42, 'B', 'RD-16B1V', '2017-12-14T20:35:48Z', 'Hans-Maier-Straße 103', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (43, 'A', 'RD-99A7V', '2017-06-29T17:17:53Z', 'Glasmalereistraße 124', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (44, 'O', 'RD-61O2F', '2017-07-15T08:41:09Z', 'Angergasse 142', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (45, 'A', 'RD-18A8M', '2017-12-05T14:06:22Z', 'Glasmalereistraße 5', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (46, 'A', 'RD-97A2W', '2017-08-28T20:48:22Z', 'Fritz-Konzert-Straße 99', 'Lane', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (47, 'A', 'RD-30A3J', '2018-01-26T00:15:01Z', 'Türingstraße 122', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (48, 'O', 'RD-34O4J', '2018-06-01T01:21:24Z', 'Gänsbacherstraße 25', 'Pass', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (49, 'B', 'RD-18B6R', '2017-07-15T08:15:06Z', 'Bachgasse 39', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (50, 'A', 'RD-36A2Y', '2017-12-29T01:36:29Z', 'Karmelweg 52', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (51, 'A', 'RD-07A3U', '2017-10-23T11:03:53Z', 'Gsturnsteig 81', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (52, 'O', 'RD-62O3Y', '2018-04-05T00:45:16Z', 'Klostergasse 17', 'Center', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (53, 'A', 'RD-18A7D', '2017-10-17T00:32:46Z', 'Hugo-Wolf-Straße 29', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (54, 'A', 'RD-11A4A', '2017-09-20T03:12:38Z', 'Grenobler Brücke 133', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (55, 'A', 'RD-30A2Y', '2017-11-06T08:00:24Z', 'Montessoristraße 83', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (56, 'A', 'RD-17A3R', '2017-12-30T16:55:12Z', 'Technikerstraße 128', 'Parkway', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (57, 'O', 'RD-18O4D', '2018-02-04T12:33:46Z', 'Weingartnerstraße 137', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (58, 'A', 'RD-25A8I', '2017-09-26T20:36:01Z', 'Badgasse 116', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (59, 'B', 'RD-20B1G', '2018-04-05T04:58:38Z', 'Ing.-Thommen-Straße 12', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (60, 'A', 'RD-14A9B', '2017-06-27T04:49:09Z', 'Domanigweg 32', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (61, 'A', 'RD-03A6S', '2017-09-10T00:46:34Z', 'Schmerlingstraße 43', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (62, 'O', 'RD-41O3V', '2017-07-06T02:08:29Z', 'Gerhild-Diesner-Straße 84', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (63, 'O', 'RD-36O6T', '2018-04-20T08:06:43Z', 'Nageletal 81', 'Park', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (64, 'A', 'RD-42A2T', '2017-09-24T16:11:48Z', 'Herzog-Siegmund-Ufer 127', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (65, 'A', 'RD-21A9L', '2018-06-11T06:03:37Z', 'Anni-Kraus-Weg 72', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (66, 'C', 'RD-89C5M', '2018-03-10T16:46:56Z', 'Schmelzergasse 100', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (67, 'A', 'RD-10A6K', '2018-05-18T15:17:28Z', 'Alois-Schrott-Straße 83', 'Way', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (68, 'C', 'RD-09C7S', '2018-03-08T18:52:12Z', 'Falkstraße 97', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (69, 'B', 'RD-75B8D', '2017-09-26T00:11:54Z', 'Olympiabrücke 145', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (70, 'O', 'RD-43O2V', '2017-09-02T02:56:49Z', 'Gilmstraße 126', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (71, 'A', 'RD-24A0R', '2017-09-04T14:27:20Z', 'Wurmbachweg 98', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (72, 'B', 'RD-82B3A', '2018-06-03T20:09:15Z', 'Helfentalweg 148', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (73, 'A', 'RD-59A3A', '2017-11-11T20:43:16Z', 'Gehrnweg 102', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (74, 'B', 'RD-98B1G', '2017-06-20T12:39:45Z', 'Ing.-Thommen-Straße 77', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (75, 'A', 'RD-61A5L', '2018-03-09T18:55:16Z', 'Feldstraße 138', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (76, 'B', 'RD-72B8U', '2018-04-27T22:48:48Z', 'Schullernstraße 91', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (77, 'C', 'RD-63C3M', '2018-04-18T02:49:03Z', 'Stadtpark Rapoldi 26', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (78, 'A', 'RD-03A9D', '2017-10-20T16:01:25Z', 'Heiligwasserweg 38', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (79, 'A', 'RD-62A5V', '2018-01-02T14:59:58Z', 'Grätschenwinkelweg 146', 'Street', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (80, 'B', 'RD-36B2C', '2018-04-11T00:56:22Z', 'Mandelsbergerstraße 46', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (81, 'A', 'RD-19A7E', '2018-05-05T00:17:49Z', 'Helga-Krismer-Platz 131', 'Avenue', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (82, 'B', 'RD-90B8G', '2017-08-06T00:47:06Z', 'Schlachthofgasse 122', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (83, 'A', 'RD-28A0V', '2018-01-19T13:36:34Z', 'Haydnplatz 18', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (84, 'A', 'RD-71A0B', '2018-01-09T15:30:57Z', 'Rennweg 47', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (85, 'B', 'RD-49B7X', '2018-02-07T18:46:02Z', 'Otto-Gamper-Weg 34', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (86, 'B', 'RD-55B0F', '2018-02-02T03:23:51Z', 'Ing.-Sigl-Straße 104', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (87, 'A', 'RD-79A5X', '2017-08-02T02:50:44Z', 'Brixner Straße 123', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (88, 'A', 'RD-04A7T', '2017-11-06T07:18:03Z', 'Wilhelm-Greil-Straße 40', 'Way', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (89, 'C', 'RD-85C1G', '2017-12-17T18:50:36Z', 'Stiftgasse 48', 'Place', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (90, 'O', 'RD-40O9Z', '2017-11-19T08:07:26Z', 'Europaratsallee 73', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (91, 'C', 'RD-08C4Z', '2018-03-21T02:49:58Z', 'Mühlauer Brücke 76', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (92, 'A', 'RD-13A5U', '2017-09-29T05:21:06Z', 'Habichtstraße 92', 'Circle', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (93, 'B', 'RD-02B2E', '2017-08-04T17:00:43Z', 'Brandjochstraße 134', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (94, 'A', 'RD-11A9X', '2017-08-27T23:59:41Z', 'Gaswerkstraße 53', 'Avenue', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (95, 'B', 'RD-95B6D', '2018-01-07T01:49:50Z', 'Wiesengasse 131', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (96, 'A', 'RD-47A7T', '2017-07-02T09:57:56Z', 'Hocheggweg 32', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (97, 'O', 'RD-78O1Z', '2017-12-10T15:02:21Z', 'Robert-Stolz-Weg 22', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (98, 'A', 'RD-72A5Y', '2017-12-23T10:48:06Z', 'Klammstraße 111', 'Point', 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (99, 'C', 'RD-78C4D', '2017-12-26T03:29:27Z', 'Karmelitergasse 56', null, 'COMPLETED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (100, 'A', 'RD-17A9I', '2017-10-05T17:45:19Z', 'Lohbachweg C 97', 'Crossing', 'COMPLETED'); + + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (101, 'A', 'RD-74A1G', '2018-02-05T15:37:44Z', 'Etrichgasse 109', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (102, 'B', 'RD-15B1U', '2017-10-20T04:54:38Z', 'Lindenhof 14', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (103, 'O', 'RD-62O0B', '2018-02-05T12:18:43Z', 'Sillgasse 113', 'Court', 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (104, 'A', 'RD-45A0Y', '2018-05-17T17:08:18Z', 'Schlerngasse 7', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (105, 'A', 'RD-42A8G', '2018-05-03T01:52:39Z', 'König-Laurin-Straße 65', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (106, 'O', 'RD-03O0G', '2018-01-21T17:21:12Z', 'Maria-Theresien-Straße 25', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (107, 'A', 'RD-94A0W', '2017-11-08T06:11:31Z', 'Kirchgasse 43', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (108, 'A', 'RD-18A1E', '2018-02-20T15:51:48Z', 'Dreiheiligenstraße 50', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (109, 'A', 'RD-11A2I', '2018-02-07T06:42:04Z', 'Höttinger Au 123', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (110, 'O', 'RD-78O0A', '2018-01-02T21:11:05Z', 'Hans-Brenner-Platz 68', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (111, 'B', 'RD-70B6R', '2017-11-23T11:35:51Z', 'Girglweg 49', 'Road', 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (112, 'B', 'RD-95B9K', '2018-02-03T06:44:16Z', 'Johannesgasse 77', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (113, 'A', 'RD-58A3E', '2017-08-18T08:46:01Z', 'Gsetzbichlweg 91', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (114, 'B', 'RD-58B5V', '2017-06-19T12:47:16Z', 'Knollerstraße 146', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (115, 'A', 'RD-93A3V', '2018-03-04T16:46:37Z', 'Oberntalweg 10', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (116, 'B', 'RD-25B6N', '2018-01-05T13:49:50Z', 'Josef-Franz-Huter-Straße 5', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (117, 'A', 'RD-01A3J', '2017-08-08T05:23:13Z', 'Bürgerstraße 113', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (118, 'B', 'RD-70B9E', '2017-09-25T14:22:46Z', 'Montessoristraße 146', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (119, 'A', 'RD-18A6U', '2018-01-15T22:08:09Z', 'Gänsbacherstraße 148', null, 'CANCELLED'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (120, 'O', 'RD-27O6C', '2017-10-06T11:55:04Z', 'Arthur-Haidl-Promenade 17', null, 'CANCELLED'); + +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (121, 'C', 'RD-34C5U', '2018-06-18T02:58:38Z', 'Schulgasse 23', 'Hill', 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (122, 'B', 'RD-55B4X', '2018-06-18T03:55:21Z', 'Gerhart-Hauptmann-Straße 85', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (123, 'C', 'RD-41C0X', '2018-06-18T06:35:58Z', 'Hafelekar 132', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (124, 'A', 'RD-60A5T', '2018-06-18T14:33:37Z', 'Renkstraße 120', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (125, 'D', 'RD-95D8H', '2018-06-18T09:15:13Z', 'Herzog-Friedrich-Straße 81', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (126, 'A', 'RD-16A9F', '2018-06-18T01:28:09Z', 'Josef-Wilberger-Straße 7', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (127, 'A', 'RD-33A1C', '2018-06-18T16:49:43Z', 'Sparkassenplatz 133', null, 'ACTIVE'); +insert into Operation (id, severity, opCode, created, destination, additionalInfo, status) values (128, 'B', 'RD-49B4F', '2018-06-18T06:10:37Z', 'Höhenstraße 27', null, 'ACTIVE'); + +--(51|52|53|59|60|2|5|9|10|11|12|14|17|20|22|23|26|28|31|32|34|36|37|38|40|41|42|44|45|46|47|49|50) + +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,1); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,2); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,3); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,4); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,5); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,6); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,7); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,8); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,9); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,10); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,11); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,12); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,13); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,14); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,15); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,16); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,17); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,18); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,19); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,20); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,21); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,22); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,23); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,24); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,25); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,26); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,27); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,28); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,29); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,30); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,31); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,32); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,33); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,34); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,35); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,36); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,37); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,38); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,39); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,40); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,41); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,42); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,43); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,44); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,45); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,46); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,47); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,48); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,49); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,50); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,51); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,52); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,53); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,54); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,55); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,56); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,57); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,58); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,59); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,60); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,61); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (5,62); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,63); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (45,64); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,65); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,66); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,67); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,68); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,69); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (14,70); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (52,71); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,72); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,73); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (26,74); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,75); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,76); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,77); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,78); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,79); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (22,80); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,81); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,82); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (37,83); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (50,84); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,85); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (41,86); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,87); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,88); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,89); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (60,90); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,91); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (47,92); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,93); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (53,94); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (38,95); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,96); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (32,97); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,98); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,99); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (20,100); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (46,101); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (12,102); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,103); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (42,104); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,105); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,106); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,107); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,108); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,109); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (59,110); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,111); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,112); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,113); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (23,114); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (40,115); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,116); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (36,117); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,118); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (11,119); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (9,120); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (31,121); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (2,122); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (49,123); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (28,124); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (51,125); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (10,125); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (34,126); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (27,127); +INSERT INTO VehicleOperation (vehicleId,operationId) VALUES (17,128); diff --git a/src/main/resources/styles/main.css b/src/main/resources/styles/main.css index 886e756..db8076a 100644 --- a/src/main/resources/styles/main.css +++ b/src/main/resources/styles/main.css @@ -49,6 +49,7 @@  /* === text === */  .text-big {    -fx-font-size: 18px; +  }  .text-medium { @@ -59,6 +60,14 @@    -fx-font-size: 14px;  } +.text-bold { +  -fx-font-weight: bold; +} + +.text-white { +  -fx-text-fill: white; +} +  /* === button === */  .button {    -fx-background-radius: 0em; @@ -93,3 +102,48 @@    -fx-font-weight: bold;  } +/* === text field === */ +.text-field { +    /*-fx-text-box-border: transparent black black black;*/ +    -fx-background-color: -fx-control-inner-background; +    /*-fx-background-insets: 0;*/ +    -fx-padding: 1 3 1 3; +    -fx-border-color: transparent transparent black transparent; + +} + +.text-field:focused { +    -fx-focus-color: transparent; +    -fx-faint-focus-color: transparent; +} + +/* === scroll pane === */ +.scroll-pane { +  -fx-background-color:transparent; +} + +.scroll-pane .viewport { +    -fx-background-color: transparent; +} + +.scroll-pane .scroll-bar:vertical { +    -fx-opacity: 0; +} + +/* === choice box === +.choice-box { +  -fx-background-color: transparent; +  -fx-padding: 2 2 2 2; +} + +.choice-box .label { +  -fx-text-fill: white; +} + +.choice-box .arrow, .choice-box .arrow-button{ +    -fx-background-color: transparent; +    -fx-background-insets: 0; +    -fx-background-radius: 0; +    -fx-padding: 0; +}*/ + diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeApplication.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeApplication.java deleted file mode 100644 index e1b3714..0000000 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.lang.invoke.MethodHandles; -import javafx.application.Application; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.stereotype.Component; - -@Component -@ComponentScan("at.ac.tuwien.sepm.assignment.groupphase") -public final class CreateNewEmployeeApplication extends Application { - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - -    public static AnnotationConfigApplicationContext context; - -    @Override -    public void start(Stage primaryStage) throws Exception { -        // setup application -        primaryStage.setTitle("Person anlegen"); -        primaryStage.setWidth(1366); -        primaryStage.setHeight(768); -        primaryStage.centerOnScreen(); -        primaryStage.setOnCloseRequest(event -> LOG.debug("Application shutdown initiated")); - -        context = new AnnotationConfigApplicationContext(CreateNewEmployeeApplication.class); -        final var fxmlLoader = context.getBean(SpringFXMLLoader.class); -        primaryStage.setScene( -                new Scene( -                        (Parent) -                                fxmlLoader.load( -                                        getClass() -                                                .getResourceAsStream( -                                                        "/fxml/createNewEmployee.fxml")))); - -        // show application -        primaryStage.show(); -        primaryStage.toFront(); -        LOG.debug("Application startup complete"); -    } - -    @Override -    public void stop() { -        LOG.debug("Stopping application"); -        context.close(); -    } -} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleApplication.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleApplication.java deleted file mode 100644 index ff46938..0000000 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleApplication.java +++ /dev/null @@ -1,51 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.lang.invoke.MethodHandles; -import javafx.application.Application; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.stereotype.Component; - -@Component -@ComponentScan("at.ac.tuwien.sepm.assignment.groupphase") -public class CreateNewVehicleApplication extends Application { - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - -    public static AnnotationConfigApplicationContext context; - -    @Override -    public void start(Stage primaryStage) throws Exception { -        // setup application -        primaryStage.setTitle("Fahrzeug anlegen"); -        primaryStage.setWidth(1366); -        primaryStage.setHeight(768); -        primaryStage.centerOnScreen(); -        primaryStage.setOnCloseRequest(event -> LOG.debug("Application shutdown initiated")); - -        context = new AnnotationConfigApplicationContext(CreateNewVehicleApplication.class); -        final var fxmlLoader = context.getBean(SpringFXMLLoader.class); -        primaryStage.setScene( -                new Scene( -                        (Parent) -                                fxmlLoader.load( -                                        getClass().getResourceAsStream("/fxml/createCar.fxml")))); - -        // show application -        primaryStage.show(); -        primaryStage.toFront(); -        LOG.debug("Application startup complete"); -    } - -    @Override -    public void stop() { -        LOG.debug("Stopping application"); -        context.close(); -    } -} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowApplication.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowApplication.java deleted file mode 100644 index 3293ae9..0000000 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; - -import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; -import java.lang.invoke.MethodHandles; -import javafx.application.Application; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.stage.Stage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.stereotype.Component; - -@Component -@ComponentScan("at.ac.tuwien.sepm.assignment.groupphase") -public class RegistrationWindowApplication extends Application { - -    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - -    public static AnnotationConfigApplicationContext context; - -    @Override -    public void start(Stage primaryStage) throws Exception { -        // setup application -        primaryStage.setTitle("Person anlegen"); -        // primaryStage.setWidth(1366); -        // primaryStage.setHeight(768); -        primaryStage.centerOnScreen(); -        primaryStage.setOnCloseRequest(event -> LOG.debug("Application shutdown initiated")); - -        context = new AnnotationConfigApplicationContext(RegistrationWindowApplication.class); -        final var fxmlLoader = context.getBean(SpringFXMLLoader.class); -        primaryStage.setScene( -                new Scene( -                        (Parent) -                                fxmlLoader.load( -                                        getClass() -                                                .getResourceAsStream( -                                                        "/fxml/RegistrationWindow.fxml")))); - -        // show application -        primaryStage.show(); -        primaryStage.toFront(); -        LOG.debug("Application startup complete"); -    } - -    @Override -    public void stop() { -        LOG.debug("Stopping application"); -        context.close(); -    } -} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTestConfiguration.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTestConfiguration.java deleted file mode 100644 index 6bf2275..0000000 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTestConfiguration.java +++ /dev/null @@ -1,17 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import static org.mockito.Mockito.mock; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -@Configuration -public class EmployeeServiceTestConfiguration { - -    @Bean -    @Primary -    public EmployeeService employeeService() { -        return mock(EmployeeServiceImpl.class); -    } -} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceTestConfiguration.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceTestConfiguration.java deleted file mode 100644 index 895973a..0000000 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceTestConfiguration.java +++ /dev/null @@ -1,17 +0,0 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; - -import static org.mockito.Mockito.mock; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -@Configuration -public class VehicleServiceTestConfiguration { - -    @Bean -    @Primary -    public VehicleService vehicleService() { -        return mock(VehicleServiceImpl.class); -    } -} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeControllerTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeControllerTest.java index 7f95950..ccd37b4 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewEmployeeControllerTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewEmployeeControllerTest.java @@ -1,11 +1,14 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_SERVICE_EXCEPTION; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_SUCCESS; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_VALIDATION_ERROR;  import static org.mockito.ArgumentMatchers.any;  import static org.mockito.Mockito.when; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService;  import at.ac.tuwien.sepm.assignment.groupphase.util.Helper;  import at.ac.tuwien.sepm.assignment.groupphase.util.HighDpiAwareApplicationTest;  import javafx.scene.control.DialogPane; @@ -24,10 +27,9 @@ public class CreateNewEmployeeControllerTest extends HighDpiAwareApplicationTest      @Before      public void setup() throws Exception { -        // TODO: check if testfx can be run in headless mode on Jenkins          FxToolkit.registerPrimaryStage(); -        FxToolkit.setupApplication(CreateNewEmployeeApplication.class); -        employeeService = CreateNewEmployeeApplication.context.getBean(EmployeeService.class); +        FxToolkit.setupApplication(GuiTestApplication.class, "createNewEmployee.fxml"); +        employeeService = GuiTestApplication.context.getBean(EmployeeService.class);      }      @After @@ -48,7 +50,7 @@ public class CreateNewEmployeeControllerTest extends HighDpiAwareApplicationTest          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Erfolgreich angelegt", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_SUCCESS, dialogPane.getHeaderText());      }      @Test @@ -63,7 +65,7 @@ public class CreateNewEmployeeControllerTest extends HighDpiAwareApplicationTest          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Ungültige Eingabe", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_VALIDATION_ERROR, dialogPane.getHeaderText());      }      @Test @@ -80,6 +82,6 @@ public class CreateNewEmployeeControllerTest extends HighDpiAwareApplicationTest          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Speicherfehler", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_SERVICE_EXCEPTION, dialogPane.getHeaderText());      }  } diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleControllerTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewVehicleControllerTest.java index 08e3fde..4906d64 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/CreateNewVehicleControllerTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/CreateNewVehicleControllerTest.java @@ -1,11 +1,14 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.controller; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_SERVICE_EXCEPTION; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_SUCCESS; +import static at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller.Helper.ALERT_TITLE_VALIDATION_ERROR;  import static org.mockito.ArgumentMatchers.any;  import static org.mockito.Mockito.when; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service.VehicleService;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService;  import at.ac.tuwien.sepm.assignment.groupphase.util.Helper;  import at.ac.tuwien.sepm.assignment.groupphase.util.HighDpiAwareApplicationTest;  import javafx.scene.control.DialogPane; @@ -24,10 +27,9 @@ public class CreateNewVehicleControllerTest extends HighDpiAwareApplicationTest      @Before      public void setup() throws Exception { -        // TODO: check if testfx can be run in headless mode on Jenkins          FxToolkit.registerPrimaryStage(); -        FxToolkit.setupApplication(CreateNewVehicleApplication.class); -        vehicleService = CreateNewVehicleApplication.context.getBean(VehicleService.class); +        FxToolkit.setupApplication(GuiTestApplication.class, "createCar.fxml"); +        vehicleService = GuiTestApplication.context.getBean(VehicleService.class);      }      @After @@ -40,13 +42,13 @@ public class CreateNewVehicleControllerTest extends HighDpiAwareApplicationTest          when(vehicleService.add(any())).thenReturn(1L); -        clickOn("#btn_create", Motion.DIRECT, MouseButton.PRIMARY); +        clickOn("#btnCreate", Motion.DIRECT, MouseButton.PRIMARY);          Stage alertDialog = Helper.getTopModalStage(robotContext());          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Speichern Erfolgreich", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_SUCCESS, dialogPane.getHeaderText());      }      @Test @@ -54,13 +56,13 @@ public class CreateNewVehicleControllerTest extends HighDpiAwareApplicationTest          when(vehicleService.add(any())).thenThrow(InvalidVehicleException.class); -        clickOn("#btn_create", Motion.DIRECT, MouseButton.PRIMARY); +        clickOn("#btnCreate", Motion.DIRECT, MouseButton.PRIMARY);          Stage alertDialog = Helper.getTopModalStage(robotContext());          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Ungültige Eingabe", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_VALIDATION_ERROR, dialogPane.getHeaderText());      }      @Test @@ -68,12 +70,12 @@ public class CreateNewVehicleControllerTest extends HighDpiAwareApplicationTest          when(vehicleService.add(any())).thenThrow(ServiceException.class); -        clickOn("#btn_create", Motion.DIRECT, MouseButton.PRIMARY); +        clickOn("#btnCreate", Motion.DIRECT, MouseButton.PRIMARY);          Stage alertDialog = Helper.getTopModalStage(robotContext());          Assert.assertNotNull(alertDialog);          DialogPane dialogPane = (DialogPane) alertDialog.getScene().getRoot(); -        Assert.assertEquals("Fehler", dialogPane.getHeaderText()); +        Assert.assertEquals(ALERT_TITLE_SERVICE_EXCEPTION, dialogPane.getHeaderText());      }  } diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/GuiTestApplication.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/GuiTestApplication.java new file mode 100644 index 0000000..968141e --- /dev/null +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/GuiTestApplication.java @@ -0,0 +1,101 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import static org.mockito.Mockito.mock; + +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.EmployeeServiceImpl; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.OperationServiceImpl; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.RegistrationService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.RegistrationServiceImpl; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleService; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service.VehicleServiceImpl; +import at.ac.tuwien.sepm.assignment.groupphase.util.SpringFXMLLoader; +import java.lang.invoke.MethodHandles; +import javafx.application.Application; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@Component +@ComponentScan("at.ac.tuwien.sepm.assignment.groupphase") +public class GuiTestApplication extends Application { + +    private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + +    public static AnnotationConfigApplicationContext context; + +    @Configuration +    public static class ContextConfiguration { + +        @Bean +        @Primary +        public EmployeeService employeeService() { +            return mock(EmployeeServiceImpl.class); +        } + +        @Bean +        @Primary +        public VehicleService vehicleService() { +            return mock(VehicleServiceImpl.class); +        } + +        @Bean +        @Primary +        public OperationService operationService() { +            return mock(OperationServiceImpl.class); +        } + +        @Bean +        @Primary +        public RegistrationService registrationService() { +            return mock(RegistrationServiceImpl.class); +        } +    } + +    @Override +    public void start(Stage primaryStage) throws Exception { +        // setup application +        primaryStage.setTitle("Test window"); +        primaryStage.setWidth(1366); +        primaryStage.setHeight(768); +        primaryStage.centerOnScreen(); +        primaryStage.setOnCloseRequest(event -> LOG.debug("Application shutdown initiated")); + +        if (getParameters().getRaw().size() < 1) { +            throw new UnsupportedOperationException("FXML file not set"); +        } + +        context = new AnnotationConfigApplicationContext(GuiTestApplication.class); +        final var fxmlLoader = context.getBean(SpringFXMLLoader.class); +        primaryStage.setScene( +                new Scene( +                        (Parent) +                                fxmlLoader.load( +                                        getClass() +                                                .getResourceAsStream( +                                                        "/fxml/" +                                                                + getParameters() +                                                                        .getRaw() +                                                                        .get(0))))); + +        // show application +        primaryStage.show(); +        primaryStage.toFront(); +        LOG.debug("Application startup complete"); +    } + +    @Override +    public void stop() { +        LOG.debug("Stopping application"); +        context.close(); +    } +} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationControllerTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationControllerTest.java new file mode 100644 index 0000000..97fb0e7 --- /dev/null +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/controller/RegistrationControllerTest.java @@ -0,0 +1,22 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.controller; + +import at.ac.tuwien.sepm.assignment.groupphase.util.HighDpiAwareApplicationTest; +import org.junit.After; +import org.junit.Before; +import org.testfx.api.FxToolkit; + +public class RegistrationControllerTest extends HighDpiAwareApplicationTest { + +    @Before +    public void setup() throws Exception { +        FxToolkit.registerPrimaryStage(); +        FxToolkit.setupApplication(GuiTestApplication.class, "RegistrationWindow.fxml"); +    } + +    @After +    public void cleanup() throws Exception { +        FxToolkit.cleanupStages(); +    } + +    // TODO: implement GUI Tests +} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAOTest.java index 585e5ea..008ac57 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/EmployeeDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/EmployeeDAOTest.java @@ -1,9 +1,9 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel;  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.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel;  import at.ac.tuwien.sepm.assignment.groupphase.util.Helper;  import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;  import java.io.InputStream; @@ -23,7 +23,7 @@ public class EmployeeDAOTest extends JdbcTestCase {      private EmployeeDAO employeePersistence; -    public EmployeeDAOTest() throws PersistenceException { +    public EmployeeDAOTest() {          employeePersistence = new EmployeeDatabaseDAO(getJdbcConnectionManager());      } @@ -40,7 +40,6 @@ public class EmployeeDAOTest extends JdbcTestCase {      public void testListEmployees() throws PersistenceException {          Set<Employee> employees = employeePersistence.list(); -        System.out.println(LocalDate.parse("2010-10-10"));          Employee empOne =                  Employee.builder()                          .id(1) diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAOTest.java index f173376..d9e7fb7 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/OperationDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/OperationDAOTest.java @@ -1,21 +1,26 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao; + +import static org.junit.Assert.assertEquals; -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.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;  import java.time.Instant;  import java.util.Arrays;  import java.util.Collections;  import java.util.EnumSet; +import java.util.LinkedList;  import java.util.Set; +import java.util.TimeZone;  import org.dbunit.dataset.DataSetException;  import org.dbunit.dataset.IDataSet; +import org.junit.BeforeClass;  import org.junit.Test;  public class OperationDAOTest extends JdbcTestCase { @@ -27,6 +32,8 @@ public class OperationDAOTest extends JdbcTestCase {      private final Operation o; +    private final Operation originalOperation; +      public OperationDAOTest() throws PersistenceException {          // TODO: fix once everything properly uses dependency injection          EmployeeDAO employeeDAO = new EmployeeDatabaseDAO(getJdbcConnectionManager()); @@ -34,7 +41,9 @@ public class OperationDAOTest extends JdbcTestCase {                  new RegistrationDatabaseDAO(getJdbcConnectionManager(), employeeDAO);          VehicleDAO vehicleDAO =                  new VehicleDatabaseDAO(getJdbcConnectionManager(), registrationDatabaseDAO); -        this.operationDAO = new OperationDatabaseDAO(getJdbcConnectionManager(), vehicleDAO); +        this.operationDAO = +                new OperationDatabaseDAO( +                        getJdbcConnectionManager(), vehicleDAO, registrationDatabaseDAO);          Vehicle v1 =                  Vehicle.builder() @@ -56,12 +65,40 @@ public class OperationDAOTest extends JdbcTestCase {                          .severity(Severity.B)                          .status(Status.ACTIVE)                          .vehicles(Set.of(v1, v2, v3)) -                        .created(Instant.now()) -                        .destination("New description") -                        .additionalInfo("Test") +                        .created(Instant.ofEpochSecond(1514764800)) // 2018-01-01 00:00:00.0 +                        .destination("New destination") +                        .additionalInfo("New information") +                        .build(); + +        Vehicle vehicle = +                Vehicle.builder() +                        .id(4) +                        .name("BKTW-4") +                        .constructionType(ConstructionType.HOCHDACH) +                        .type(VehicleType.BKTW) +                        .hasNef(false) +                        .status(Vehicle.Status.ZUM_BERUFUNGSORT) +                        .registrations(new LinkedList<>()) +                        .build(); + +        originalOperation = +                Operation.builder() +                        .id(1) +                        .opCode("ALP-95E7") +                        .severity(Severity.E) +                        .created(Instant.parse("2000-01-01T00:00:00.0Z")) +                        .destination("Wiedner Hauptstraße 35, Wien") +                        .additionalInfo("Additional information") +                        .status(Status.ACTIVE) +                        .vehicles(Set.of(vehicle))                          .build();      } +    @BeforeClass +    public static void before() { +        TimeZone.setDefault(TimeZone.getTimeZone("UTC")); +    } +      @Override      protected IDataSet getDataSet() throws DataSetException {          return getDataSet("operationDAOUpdateSetup.xml"); @@ -94,16 +131,21 @@ public class OperationDAOTest extends JdbcTestCase {      public void testListOperations() throws Exception {          Set<Operation> operationSet = operationDAO.list(EnumSet.allOf(Status.class)); -        // TODO: operations.list() currently doesn't set the vehicles set -        // assertEquals(Set.of(o), operationSet); +        assertEquals(Set.of(originalOperation), operationSet);      }      @Test -    public void testAddOperation() throws Exception { -        operationDAO.add(o); +    public void testGetOperations() throws Exception { +        Operation gotOperation = operationDAO.get(originalOperation.id()); + +        assertEquals(originalOperation, gotOperation); +    } -        // TODO: won't work because id won't match -        // compareWith("operationDAOUpdateNormal.xml", COMPARE_TABLES); +    @Test +    public void testAddOperation() throws Exception { +        long id = operationDAO.add(o); +        assertEquals(2, id); +        compareWith("operationDAOAddOperation.xml", COMPARE_TABLES);      }      @Test(expected = PersistenceException.class) diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAOTest.java index e8ea809..2cb54f8 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/RegistrationDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/RegistrationDAOTest.java @@ -1,82 +1,35 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao;  import static org.junit.Assert.*; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -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.exception.PersistenceException; -import at.ac.tuwien.sepm.assignment.groupphase.util.JDBCConnectionManager; -import java.nio.charset.Charset; -import java.sql.SQLException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;  import java.time.Instant;  import java.time.LocalDate;  import java.util.HashSet;  import java.util.Set; -import org.h2.tools.RunScript; -import org.junit.AfterClass; -import org.junit.BeforeClass; +import org.dbunit.dataset.IDataSet;  import org.junit.Rule;  import org.junit.Test;  import org.junit.rules.ExpectedException; -public class RegistrationDAOTest { - -    // Base taken from EmployeeDAOTest - -    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 = ""; +public class RegistrationDAOTest extends JdbcTestCase {      private RegistrationDAO registrationDAO;      public RegistrationDAOTest() throws PersistenceException { -        JDBCConnectionManager jdbcConnectionManager = new JDBCConnectionManager(JDBC_URL);          this.registrationDAO =                  new RegistrationDatabaseDAO( -                        jdbcConnectionManager, new EmployeeDatabaseDAO(jdbcConnectionManager)); -        // TODO: Use Spring Dependency Injection here! +                        getJdbcConnectionManager(), +                        new EmployeeDatabaseDAO(getJdbcConnectionManager()));      } -    @BeforeClass -    public static void setupDatabase() throws SQLException { -        RunScript.execute( -                JDBC_URL, -                USER, -                PASSWORD, -                "classpath:sql/database.sql", -                Charset.forName("UTF8"), -                false); -        RunScript.execute( -                JDBC_URL, -                USER, -                PASSWORD, -                "classpath:sql/H2RegistrationDAOTest_populate.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); -        } -    */ -    @AfterClass -    public static void tearDown() throws SQLException { -        RunScript.execute( -                JDBC_URL, -                USER, -                PASSWORD, -                "classpath:sql/H2RegistrationDAOTest_depopulate.sql", -                Charset.forName("UTF8"), -                false); +    @Override +    protected IDataSet getDataSet() throws Exception { +        return getDataSet("registrationTestBaseData.xml");      }      @Rule public ExpectedException thrown = ExpectedException.none(); @@ -84,16 +37,6 @@ public class RegistrationDAOTest {      @Test      public void addRegistrationsShouldSucceed() throws PersistenceException {          Set<Registration> registrations = new HashSet<>(); -        /* -        Vehicle vehicle = Vehicle.builder() -                .id(1) -                .name("RTW-1") -                .constructionType(ConstructionType.HOCHDACH) -                .type(VehicleType.RTW) -                .status(Status.ABGEMELDET) -                .hasNef(true) -                .build(); -        */          Employee employee1 =                  Employee.builder()                          .id(1) @@ -162,8 +105,8 @@ public class RegistrationDAOTest {                          .build();          Registration registration =                  Registration.builder() -                        .start(Instant.MIN) -                        .end(Instant.MAX) +                        .start(Instant.now()) +                        .end(Instant.now())                          .employee(employee)                          .build();          registrations.add(registration); diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAOTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAOTest.java index 1862214..c4d7d86 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/dao/VehicleDAOTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/dao/VehicleDAOTest.java @@ -1,11 +1,11 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.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.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import at.ac.tuwien.sepm.assignment.groupphase.util.Helper;  import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase;  import java.io.InputStream; diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceTest.java index 90f0a44..17c0a47 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/EmployeeServiceTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/EmployeeServiceTest.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service;  import static org.hamcrest.CoreMatchers.is;  import static org.mockito.ArgumentMatchers.any; @@ -6,14 +6,14 @@ import static org.mockito.Mockito.doThrow;  import static org.mockito.Mockito.mock;  import static org.mockito.Mockito.when; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.EmployeeDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.EmployeeDatabaseDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee.EducationLevel;  import at.ac.tuwien.sepm.assignment.groupphase.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidEmployeeException;  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.missioncontrol.dao.EmployeeDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel;  import java.time.LocalDate;  import org.junit.Assert;  import org.junit.Test; diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceIntegrationTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceIntegrationTest.java new file mode 100644 index 0000000..008787f --- /dev/null +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceIntegrationTest.java @@ -0,0 +1,99 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +import static org.junit.Assert.assertEquals; + +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.missioncontrol.dao.EmployeeDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.OperationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.OperationDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.util.Helper; +import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase; +import java.util.Set; +import org.dbunit.Assertion; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.junit.Test; + +public class OperationServiceIntegrationTest extends JdbcTestCase { + +    private OperationService operationService; + +    private Operation o; + +    public OperationServiceIntegrationTest() { +        EmployeeDAO employeeDAO = new EmployeeDatabaseDAO(getJdbcConnectionManager()); +        RegistrationDAO registrationDAO = +                new RegistrationDatabaseDAO(getJdbcConnectionManager(), employeeDAO); +        VehicleDAO vehicleDAO = +                new VehicleDatabaseDAO( +                        getJdbcConnectionManager(), (RegistrationDatabaseDAO) registrationDAO); +        OperationDAO operationDAO = +                new OperationDatabaseDAO( +                        getJdbcConnectionManager(), +                        vehicleDAO, +                        (RegistrationDatabaseDAO) registrationDAO); + +        VehicleService vehicleService = new VehicleServiceImpl(vehicleDAO); + +        operationService = new OperationServiceImpl(operationDAO, vehicleDAO, vehicleService); + +        Vehicle v1 = +                Vehicle.builder() +                        .id(1) +                        .name("RTW-1") +                        .constructionType(Vehicle.ConstructionType.HOCHDACH) +                        .type(Vehicle.VehicleType.RTW) +                        .status(Vehicle.Status.FREI_FUNK) +                        .hasNef(true) +                        .build(); + +        Vehicle v2 = v1.toBuilder().id(2).build(); +        Vehicle v3 = v1.toBuilder().id(3).build(); + +        o = +                Operation.builder() +                        .opCode("RD-2B0M") +                        .status(Status.ACTIVE) +                        .vehicles(Set.of(v1, v2, v3)) +                        .destination("New destination") +                        .additionalInfo("New information") +                        .build(); +    } + +    @Override +    protected IDataSet getDataSet() throws Exception { +        return getDataSet("operationDAOUpdateSetup.xml"); +    } + +    @Test +    public void addValidOperation() throws Exception { + +        long id = operationService.add(o); +        assertEquals(2, id); + +        String tableName = "Operation"; +        String[] excludedColumns = new String[] {"created"}; + +        ITable actual = +                Helper.getActualFilteredTableData(getConnection(), tableName, excludedColumns); +        ITable expected = +                Helper.getExpectedFilteredTableData( +                        tableName, excludedColumns, "operationDAOAddOperation.xml"); + +        Assertion.assertEquals(expected, actual); +    } + +    @Test(expected = InvalidOperationException.class) +    public void addInvalidOperation() throws InvalidOperationException, ServiceException { +        operationService.add(o.toBuilder().opCode("").build()); +    } +} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceTest.java index 67fb77d..4c1eaf1 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/OperationServiceTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/OperationServiceTest.java @@ -1,4 +1,4 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service;  import static org.mockito.ArgumentMatchers.any;  import static org.mockito.ArgumentMatchers.anyLong; @@ -6,16 +6,16 @@ import static org.mockito.Mockito.times;  import static org.mockito.Mockito.verify;  import static org.mockito.Mockito.when; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.OperationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -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.exception.ElementNotFoundException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidOperationException;  import at.ac.tuwien.sepm.assignment.groupphase.exception.InvalidVehicleException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.OperationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Severity; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Operation.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType;  import java.time.Instant;  import java.util.Collections;  import java.util.Set; diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceIntegrationTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceIntegrationTest.java new file mode 100644 index 0000000..ac5c3fb --- /dev/null +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceIntegrationTest.java @@ -0,0 +1,55 @@ +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service; + +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.PersistenceException; +import at.ac.tuwien.sepm.assignment.groupphase.exception.ServiceException; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.EmployeeDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.RegistrationDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDatabaseDAO; +import at.ac.tuwien.sepm.assignment.groupphase.util.JdbcTestCase; +import org.dbunit.dataset.IDataSet; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +public class RegistrationServiceIntegrationTest extends JdbcTestCase { + +    private RegistrationDAO registrationDAO; +    private VehicleDAO vehicleDAO; + +    @Rule public ExpectedException thrown = ExpectedException.none(); + +    @Override +    protected IDataSet getDataSet() throws Exception { +        return getDataSet("registrationTestBaseData.xml"); +    } + +    @Before +    public void prepare() throws PersistenceException { + +        EmployeeDAO employeeDAO = new EmployeeDatabaseDAO(getJdbcConnectionManager()); +        registrationDAO = new RegistrationDatabaseDAO(getJdbcConnectionManager(), employeeDAO); +        vehicleDAO = +                new VehicleDatabaseDAO( +                        getJdbcConnectionManager(), (RegistrationDatabaseDAO) registrationDAO); +    } + +    @Test +    public void addValidRegistrationsShouldSucceed() +            throws InvalidRegistrationException, ServiceException, InvalidVehicleException { +        RegistrationServiceTest.addValidRegistrations(registrationDAO, vehicleDAO); +    } + +    @Test +    public void addOnlyOnePersonToRTWShouldFail() +            throws InvalidRegistrationException, ServiceException, InvalidVehicleException { +        RegistrationServiceTest.addOnlyOnePersonToRTW(thrown, registrationDAO, vehicleDAO); +    } + +    // TODO: also test real integration, e.g. add registration and delete afterwards (feedback) +} diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceTest.java index 4d3a251..b4bcff4 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/RegistrationServiceTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/missioncontrol/service/RegistrationServiceTest.java @@ -1,23 +1,23 @@ -package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.service; +package at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.service;  import static org.mockito.ArgumentMatchers.anyLong;  import static org.mockito.Mockito.when; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.RegistrationDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dao.VehicleDAO; -import at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Employee; -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 at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.dto.Vehicle.Builder; -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.InvalidRegistrationException;  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.missioncontrol.dao.RegistrationDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dao.VehicleDAO; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Employee.EducationLevel; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Registration; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Builder; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.ConstructionType; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.Status; +import at.ac.tuwien.sepm.assignment.groupphase.missioncontrol.dto.Vehicle.VehicleType;  import java.time.Instant;  import java.time.LocalDate;  import java.time.temporal.ChronoUnit; @@ -58,6 +58,17 @@ public class RegistrationServiceTest {      @Test      public void addValidRegistrationsShouldSucceed()              throws InvalidRegistrationException, ServiceException, InvalidVehicleException { +        addValidRegistrations(registrationDAO, vehicleDAO); +    } + +    @Test +    public void addOnlyOnePersonToRTWShouldFail() +            throws InvalidRegistrationException, ServiceException, InvalidVehicleException { +        addOnlyOnePersonToRTW(thrown, registrationDAO, vehicleDAO); +    } + +    static void addValidRegistrations(RegistrationDAO registrationDAO, VehicleDAO vehicleDAO) +            throws InvalidVehicleException, InvalidRegistrationException, ServiceException {          RegistrationService registrationService =                  new RegistrationServiceImpl(registrationDAO, vehicleDAO);          Set<Registration> registrations = new HashSet<>(); @@ -111,9 +122,9 @@ public class RegistrationServiceTest {          registrationService.add(vehicle.id(), registrations);      } -    @Test -    public void addOnlyOnePersonToRTWShouldFail() -            throws InvalidRegistrationException, ServiceException, InvalidVehicleException { +    static void addOnlyOnePersonToRTW( +            ExpectedException thrown, RegistrationDAO registrationDAO, VehicleDAO vehicleDAO) +            throws InvalidVehicleException, InvalidRegistrationException, ServiceException {          thrown.expect(InvalidRegistrationException.class);          RegistrationService registrationService =                  new RegistrationServiceImpl(registrationDAO, vehicleDAO); diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/HighDpiAwareApplicationTest.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/HighDpiAwareApplicationTest.java index c9816a1..2924b3f 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/HighDpiAwareApplicationTest.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/HighDpiAwareApplicationTest.java @@ -7,7 +7,7 @@ import org.testfx.framework.junit.ApplicationTest;  import org.testfx.service.locator.impl.BoundsLocatorImpl;  import org.testfx.service.locator.impl.PointLocatorImpl; -public class HighDpiAwareApplicationTest extends ApplicationTest { +public abstract class HighDpiAwareApplicationTest extends ApplicationTest {      public HighDpiAwareApplicationTest() {          FxRobotContext context = robotContext(); diff --git a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/JdbcTestCase.java b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/JdbcTestCase.java index c509a1f..e419ab0 100644 --- a/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/JdbcTestCase.java +++ b/src/test/java/at/ac/tuwien/sepm/assignment/groupphase/util/JdbcTestCase.java @@ -19,7 +19,7 @@ import org.dbunit.dataset.IDataSet;  import org.dbunit.dataset.datatype.DataType;  import org.dbunit.dataset.datatype.DataTypeException;  import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.ext.postgresql.PostgresqlDataTypeFactory; +import org.dbunit.ext.h2.H2DataTypeFactory;  import org.dbunit.operation.DatabaseOperation;  import org.junit.After;  import org.junit.Before; @@ -96,13 +96,14 @@ public abstract class JdbcTestCase {      // override DBUnit's enum handling      private void setUpDatabaseConfig(DatabaseConfig config) { -        PostgresqlDataTypeFactory factory = -                new PostgresqlDataTypeFactory() { -                    @Override -                    public boolean isEnumType(String sqlTypeName) { -                        if (sqlTypeName.equalsIgnoreCase("enum")) return true; +        H2DataTypeFactory factory = +                new H2DataTypeFactory() { +                    boolean isEnumType(String sqlTypeName) { +                        return sqlTypeName.equalsIgnoreCase("enum"); +                    } -                        return super.isEnumType(sqlTypeName); +                    boolean isTimestampWithTimeZoneType(String sqlTypeName) { +                        return sqlTypeName.equalsIgnoreCase("timestamp with time zone");                      }                      @Override @@ -110,6 +111,8 @@ public abstract class JdbcTestCase {                              throws DataTypeException {                          if (isEnumType(sqlTypeName)) {                              sqlType = Types.VARCHAR; +                        } else if (isTimestampWithTimeZoneType(sqlTypeName)) { +                            sqlType = Types.VARCHAR;                          }                          return super.createDataType(sqlType, sqlTypeName); @@ -130,7 +133,7 @@ public abstract class JdbcTestCase {          IDataSet expected = new FlatXmlDataSetBuilder().build(res);          for (String table : tables) { -            assertEquals(actual.getTable(table), expected.getTable(table)); +            assertEquals(expected.getTable(table), actual.getTable(table));          }      } diff --git a/src/test/resources/operationDAOAddOperation.xml b/src/test/resources/operationDAOAddOperation.xml new file mode 100644 index 0000000..752de67 --- /dev/null +++ b/src/test/resources/operationDAOAddOperation.xml @@ -0,0 +1,22 @@ +<dataset> +  <Operation id="1" opCode="ALP-95E7" severity="E" created="2000-01-01 00:00:00.0+00" +    destination="Wiedner Hauptstraße 35, Wien" additionalInfo="Additional information" status="ACTIVE"/> +  <Operation id="2" opCode="RD-2B0M" severity="B" created="2018-01-01 00:00:00.0+00" +    destination="New destination" additionalInfo="New information" status="ACTIVE"/> + +  <VehicleVersion id="1" name="RTW-1" constructionType="HOCHDACH" type="RTW" hasNef="true"/> +  <VehicleVersion id="2" name="KTW-2" constructionType="HOCHDACH" type="KTW" hasNef="true"/> +  <VehicleVersion id="3" name="KTW-3" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> +  <VehicleVersion id="4" name="BKTW-4" constructionType="HOCHDACH" type="BKTW" hasNef="false"/> +  <VehicleVersion id="5" name="NEF-1" constructionType="NORMAL" type="NEF" hasNef="true"/> + +  <Vehicle id="1" version="1" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="2" version="2" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="3" version="3" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="4" version="4" status="ZUM_BERUFUNGSORT"/> + +  <VehicleOperation vehicleId="1" operationId="2"/> +  <VehicleOperation vehicleId="2" operationId="2"/> +  <VehicleOperation vehicleId="3" operationId="2"/> +  <VehicleOperation vehicleId="4" operationId="1"/> +</dataset> diff --git a/src/test/resources/operationDAOUpdateNormal.xml b/src/test/resources/operationDAOUpdateNormal.xml index 025cdc2..accf97e 100644 --- a/src/test/resources/operationDAOUpdateNormal.xml +++ b/src/test/resources/operationDAOUpdateNormal.xml @@ -1,17 +1,17 @@  <dataset> -  <Operation id="1" opCode="RD-2B0M" severity="B" created="2000-01-01" -    destination="New description" status="ACTIVE" additionalInfo="Test"/> +  <Operation id="1" opCode="RD-2B0M" severity="B" created="2000-01-01 00:00:00.0+00" +    destination="New destination" additionalInfo="New information" status="ACTIVE"/>    <VehicleVersion id="1" name="RTW-1" constructionType="HOCHDACH" type="RTW" hasNef="true"/> -  <VehicleVersion id="2" name="KTW-1" constructionType="HOCHDACH" type="KTW" hasNef="true"/> -  <VehicleVersion id="3" name="KTW-2" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> -  <VehicleVersion id="4" name="BKTW-2" constructionType="HOCHDACH" type="BKTW" hasNef="false"/> +  <VehicleVersion id="2" name="KTW-2" constructionType="HOCHDACH" type="KTW" hasNef="true"/> +  <VehicleVersion id="3" name="KTW-3" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> +  <VehicleVersion id="4" name="BKTW-4" constructionType="HOCHDACH" type="BKTW" hasNef="false"/>    <VehicleVersion id="5" name="NEF-1" constructionType="NORMAL" type="NEF" hasNef="true"/> -  <Vehicle id="1" version="1" status="FREI_FUNK"/> -  <Vehicle id="2" version="2" status="FREI_WACHE"/> -  <Vehicle id="3" version="3" status="FREI_FUNK"/> -  <Vehicle id="4" version="4" status="FREI_WACHE"/> +  <Vehicle id="1" version="1" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="2" version="2" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="3" version="3" status="ZUM_BERUFUNGSORT"/> +  <Vehicle id="4" version="4" status="ZUM_BERUFUNGSORT"/>    <VehicleOperation vehicleId="1" operationId="1"/>    <VehicleOperation vehicleId="2" operationId="1"/> diff --git a/src/test/resources/operationDAOUpdateRemoveVehicles.xml b/src/test/resources/operationDAOUpdateRemoveVehicles.xml index 6f171b4..a23f86c 100644 --- a/src/test/resources/operationDAOUpdateRemoveVehicles.xml +++ b/src/test/resources/operationDAOUpdateRemoveVehicles.xml @@ -1,17 +1,17 @@  <dataset> -  <Operation id="1" opCode="RD-2B0M" severity="B" created="2000-01-01" -    destination="New description" status="ACTIVE" additionalInfo="Test"/> +  <Operation id="1" opCode="RD-2B0M" severity="B" created="2000-01-01 00:00:00.0+00" +    destination="New destination" status="ACTIVE" additionalInfo="New information"/>    <VehicleVersion id="1" name="RTW-1" constructionType="HOCHDACH" type="RTW" hasNef="true"/> -  <VehicleVersion id="2" name="KTW-1" constructionType="HOCHDACH" type="KTW" hasNef="true"/> -  <VehicleVersion id="3" name="KTW-2" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> -  <VehicleVersion id="4" name="BKTW-2" constructionType="HOCHDACH" type="BKTW" hasNef="false"/> +  <VehicleVersion id="2" name="KTW-2" constructionType="HOCHDACH" type="KTW" hasNef="true"/> +  <VehicleVersion id="3" name="KTW-3" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> +  <VehicleVersion id="4" name="BKTW-4" constructionType="HOCHDACH" type="BKTW" hasNef="false"/>    <VehicleVersion id="5" name="NEF-1" constructionType="NORMAL" type="NEF" hasNef="true"/>    <Vehicle id="1" version="1" status="FREI_FUNK"/>    <Vehicle id="2" version="2" status="FREI_WACHE"/>    <Vehicle id="3" version="3" status="FREI_FUNK"/> -  <Vehicle id="4" version="4" status="FREI_WACHE"/> +  <Vehicle id="4" version="4" status="ZUM_BERUFUNGSORT"/>    <VehicleOperation />  </dataset> diff --git a/src/test/resources/operationDAOUpdateSetup.xml b/src/test/resources/operationDAOUpdateSetup.xml index 23d1a25..533e58e 100644 --- a/src/test/resources/operationDAOUpdateSetup.xml +++ b/src/test/resources/operationDAOUpdateSetup.xml @@ -1,17 +1,17 @@  <dataset> -  <Operation id="1" opCode="ALP-95E7" severity="E" created="2000-01-01" -    destination="Wiedner Hauptstraße 35, Wien" status="ACTIVE"/> +  <Operation id="1" opCode="ALP-95E7" severity="E" created="2000-01-01 00:00:00.0+00" +    destination="Wiedner Hauptstraße 35, Wien" additionalInfo="Additional information" status="ACTIVE"/>    <VehicleVersion id="1" name="RTW-1" constructionType="HOCHDACH" type="RTW" hasNef="true"/> -  <VehicleVersion id="2" name="KTW-1" constructionType="HOCHDACH" type="KTW" hasNef="true"/> -  <VehicleVersion id="3" name="KTW-2" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> -  <VehicleVersion id="4" name="BKTW-2" constructionType="HOCHDACH" type="BKTW" hasNef="false"/> +  <VehicleVersion id="2" name="KTW-2" constructionType="HOCHDACH" type="KTW" hasNef="true"/> +  <VehicleVersion id="3" name="KTW-3" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> +  <VehicleVersion id="4" name="BKTW-4" constructionType="HOCHDACH" type="BKTW" hasNef="false"/>    <VehicleVersion id="5" name="NEF-1" constructionType="NORMAL" type="NEF" hasNef="true"/>    <Vehicle id="1" version="1" status="FREI_FUNK"/>    <Vehicle id="2" version="2" status="FREI_WACHE"/>    <Vehicle id="3" version="3" status="FREI_FUNK"/> -  <Vehicle id="4" version="4" status="FREI_WACHE"/> +  <Vehicle id="4" version="4" status="ZUM_BERUFUNGSORT"/> -  <VehicleOperation /> +  <VehicleOperation vehicleId="4" operationId="1"/>  </dataset> diff --git a/src/test/resources/operationIntegrationVehicles.xml b/src/test/resources/operationIntegrationVehicles.xml new file mode 100644 index 0000000..0e6f848 --- /dev/null +++ b/src/test/resources/operationIntegrationVehicles.xml @@ -0,0 +1,12 @@ +<dataset> +<VehicleVersion id="1" name="RTW-1" constructionType="HOCHDACH" type="RTW" hasNef="true"/> +<VehicleVersion id="2" name="KTW-2" constructionType="HOCHDACH" type="KTW" hasNef="true"/> +<VehicleVersion id="3" name="KTW-3" constructionType="MITTELHOCHDACH" type="KTW_B" hasNef="false"/> +<VehicleVersion id="4" name="BKTW-4" constructionType="HOCHDACH" type="BKTW" hasNef="false"/> +<VehicleVersion id="5" name="NEF-1" constructionType="NORMAL" type="NEF" hasNef="true"/> + +<Vehicle id="1" version="1" status="FREI_FUNK"/> +<Vehicle id="2" version="2" status="FREI_WACHE"/> +<Vehicle id="3" version="3" status="FREI_FUNK"/> +<Vehicle id="4" version="4" status="ZUM_BERUFUNGSORT"/> +</dataset>
\ No newline at end of file diff --git a/src/test/resources/registrationTestBaseData.xml b/src/test/resources/registrationTestBaseData.xml new file mode 100644 index 0000000..7ef1912 --- /dev/null +++ b/src/test/resources/registrationTestBaseData.xml @@ -0,0 +1,18 @@ +<dataset> +  <EmployeeVersion id="1" name="John Doe" birthday="2000-01-01" educationLevel="RS" isDriver="true" +    isPilot="false"/> +  <EmployeeVersion id="2" name="Nick Verily" birthday="1990-01-01" educationLevel="NKV" +    isDriver="true" isPilot="false"/> +  <EmployeeVersion id="3" name="Nicht Arzt" birthday="1980-01-01" educationLevel="NA" +    isDriver="false" isPilot="false"/> + +  <Employee id="1" version="1"/> +  <Employee id="2" version="2"/> +  <Employee id="3" version="3"/> + +  <VehicleVersion id="1" name="RTW-1" hasNef="true" constructionType="HOCHDACH" type="RTW"/> +  <VehicleVersion id="2" name="NEF-1" hasNef="false" constructionType="NORMAL" type="NEF"/> + +  <Vehicle id="1" version="1" status="ABGEMELDET"/> +  <Vehicle id="2" version="2" status="ABGEMELDET"/> +</dataset>
\ No newline at end of file | 
