aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Weick <e1627760@student.tuwien.ac.at>2018-05-14 10:31:22 +0200
committerTharre <tharre3@gmail.com>2018-05-22 15:02:27 +0200
commit043c2fcfe24f933be9fed49d74bd11a23ed655b8 (patch)
tree58ba07e1ffb5dd4bf6d6fb2583d288c322911868 /src
parentac1f1a80e3ae69e3d183175d24d0d7f182d0798e (diff)
downloadsepm-groupproject-043c2fcfe24f933be9fed49d74bd11a23ed655b8.tar.gz
sepm-groupproject-043c2fcfe24f933be9fed49d74bd11a23ed655b8.tar.xz
sepm-groupproject-043c2fcfe24f933be9fed49d74bd11a23ed655b8.zip
Implement Service UpdateCar
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java
index ac8a626..47a2520 100644
--- a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java
+++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleServiceImpl.java
@@ -4,6 +4,7 @@ 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;
@@ -69,7 +70,51 @@ public class VehicleServiceImpl implements VehicleService {
}
public Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException {
- throw new UnsupportedOperationException();
+ switch (vehicle.type()) {
+ case RTW:
+ if (vehicle.constructionType() == ConstructionType.NORMAL) {
+ throw new InvalidVehicleException("RTW darf kein Normales Dach haben");
+ } else if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) {
+ throw new InvalidVehicleException("RTW darf kein Mittelhochdach haben");
+ }
+ break;
+ case KTW:
+ if (vehicle.constructionType() == ConstructionType.NORMAL) {
+ throw new InvalidVehicleException("KTW darf kein Normales Dach haben");
+ }
+ break;
+ case KTW_B:
+ if (vehicle.constructionType() == ConstructionType.NORMAL) {
+ throw new InvalidVehicleException("KTW-B darf kein Normales Dach haben");
+ }
+ break;
+ case NEF:
+ if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) {
+ throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben");
+ } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) {
+ throw new InvalidVehicleException("NEF darf kein Hochdach haben");
+ }
+ break;
+ case NAH:
+ if (vehicle.constructionType() == ConstructionType.MITTELHOCHDACH) {
+ throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben");
+ } else if (vehicle.constructionType() == ConstructionType.HOCHDACH) {
+ throw new InvalidVehicleException("NEF darf kein Hochdach haben");
+ }
+ break;
+ case BKTW:
+ break;
+ default:
+ throw new ServiceException("not a Valid type");
+ }
+ try {
+ vehiclePersistence.update(vehicle);
+ } catch (ElementNotFoundException e) {
+ throw new ServiceException("Element not found");
+ } catch (PersistenceException e) {
+ throw new ServiceException(e);
+ }
+ return vehicle;
}
@Override