more changes

This commit is contained in:
Michael 2019-05-14 11:12:47 +02:00
parent ea7a02e9f6
commit 159f8e67a5

View File

@ -137,14 +137,15 @@ public class CacheConstructionUtil {
List<Station> newCreatedStationList = new ArrayList<Station>();
for (Station station : cache.getStationen()) {
boolean stationIsNew = true;
// wenn Station schon vorher vorhanden war, wird nur nach validen Daten geprüft
for (Station oldStation : oldCache.getStationen()) {
// wenn Station schon vorher vorhanden war, wird diese mit den neuen Daten geupdatet
if (oldStation.getId() == station.getId()) {
response = createStationUtil(station);
stationIsNew = false;
break;
}
}
// wenn Station neu hinzugefügt wurde, wird die Station zusätzlich in die Datenbank gespeichert
if (stationIsNew) {
response = createStationUtil(station);
@ -201,21 +202,21 @@ public class CacheConstructionUtil {
return ResponseEntity.status(200).body(new Gson().toJson(cache));
}
public static ResponseEntity checkStationUtil(Station station) {
if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
return ResponseEntity.status(400).body("station fields can´t be empty");
}
if (station.getLattitude() < 9 || station.getLattitude() > 10) {
return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees");
}
if (station.getLongitude() < 49 || station.getLongitude() > 50) {
return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees");
}
return ResponseEntity.status(200).body(new Gson().toJson(station));
}
// public static ResponseEntity checkStationUtil(Station station) {
// if (station.getDescription().length() == 0 || station.getLattitude() == 0.0 || station.getLongitude() == 0.0 /*|| station.getSolution().length() == 0*/) {
// return ResponseEntity.status(400).body("station fields can´t be empty");
// }
//
// if (station.getLattitude() < 9 || station.getLattitude() > 10) {
// return ResponseEntity.status(400).body("Lattitude has to be between 9 and 10 degrees");
// }
//
// if (station.getLongitude() < 49 || station.getLongitude() > 50) {
// return ResponseEntity.status(400).body("Longitude has to be in the range of 49 to 50 degrees");
// }
//
// return ResponseEntity.status(200).body(new Gson().toJson(station));
// }
public static void deleteStationenUtil(Cache cache) {
for (Station station : cache.getStationen()) {