summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorMartin Weick <e1627760@student.tuwien.ac.at>2018-05-24 13:58:43 +0200
committerTharre <tharre3@gmail.com>2018-05-24 15:47:51 +0200
commita2b0959767bcb9c4412f7886d4b07b3fc5078bab (patch)
treeda0ea3ede3a447eed05a799fbe3890034893fe5d /src/main/java
parent3921e1bb05b7fa449bc72f136b3ede62984614af (diff)
downloadsepm-groupproject-a2b0959767bcb9c4412f7886d4b07b3fc5078bab.tar.gz
sepm-groupproject-a2b0959767bcb9c4412f7886d4b07b3fc5078bab.tar.xz
sepm-groupproject-a2b0959767bcb9c4412f7886d4b07b3fc5078bab.zip
Fix NPE when choseVehicle is null
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/controller/RegistrationWindowController.java39
1 files changed, 21 insertions, 18 deletions
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
index ac6470e..4653663 100644
--- 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
@@ -149,25 +149,28 @@ public class RegistrationWindowController {
LOG.debug("Create Button clicked");
Set<Registration> registrations = new HashSet<>();
-
- 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());
- }
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();