diff options
author | Martin Weick <e1627760@student.tuwien.ac.at> | 2018-05-04 08:36:52 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2018-05-04 20:37:04 +0200 |
commit | 81fcb1db23217dff24f50945cf066a37cff0999a (patch) | |
tree | a40e9b8dfb8955762d608fabaf16468a62615bc6 /src | |
parent | 0ab36507fffe98c9ec7d60f29a9c7b0391fc9532 (diff) | |
download | sepm-groupproject-81fcb1db23217dff24f50945cf066a37cff0999a.tar.gz sepm-groupproject-81fcb1db23217dff24f50945cf066a37cff0999a.tar.xz sepm-groupproject-81fcb1db23217dff24f50945cf066a37cff0999a.zip |
Validate Vehicles
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleAdd.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleAdd.java b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleAdd.java new file mode 100644 index 0000000..a0fadd5 --- /dev/null +++ b/src/main/java/at/ac/tuwien/sepm/assignment/groupphase/einsatzverwaltung/service/VehicleAdd.java @@ -0,0 +1,65 @@ +package at.ac.tuwien.sepm.assignment.groupphase.einsatzverwaltung.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 java.util.EnumSet; +import java.util.List; + +public class VehicleAdd implements VehicleService { + + public long add(Vehicle vehicle) throws InvalidVehicleException, ServiceException { + final String normal="Normal"; + final String mhd="Mittelhochdach"; + + switch (vehicle.type().toString()){ + case "RTW": + if(vehicle.constructionType().name().contains(normal)){ + throw new InvalidVehicleException("RTW darf kein Normales Dach haben"); + }else if(vehicle.constructionType().name().contains(mhd)){ + throw new InvalidVehicleException("RTW darf kein Mittelhochdach haben"); + } + break; + case "KTW": + if(vehicle.constructionType().name().contains(normal)){ + throw new InvalidVehicleException("KTW darf kein Normales Dach haben"); + } + break; + case "KTW_B": + if(vehicle.constructionType().name().contains(normal)){ + throw new InvalidVehicleException("KTW-B darf kein Normales Dach haben"); + } + break; + case "NEF": + if(vehicle.constructionType().name().contains(mhd)){ + throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); + }else if(vehicle.constructionType().name().contains("Hochdach")){ + throw new InvalidVehicleException("NEF darf kein Hochdach haben"); + } + break; + case "NAH": + if(vehicle.constructionType().name().contains(mhd)){ + throw new InvalidVehicleException("NEF darf kein Mittelhochdach haben"); + }else if(vehicle.constructionType().name().contains("Hochdach")){ + throw new InvalidVehicleException("NEF darf kein Hochdach haben"); + } + break; + default: + throw new ServiceException("not a Valid type"); + } + return 0; + } + + public Vehicle update(Vehicle vehicle) throws InvalidVehicleException, ServiceException { + throw new UnsupportedOperationException(); + } + + public List<Vehicle> list(EnumSet<Status> statuses) throws ServiceException { + throw new UnsupportedOperationException(); + } + + public void remove(long id) throws InvalidVehicleException, ServiceException { + throw new UnsupportedOperationException(); + } +} |