diff options
| -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(); +    } +}  | 
