From 159f8e67a5e97c7749f0ab515b13e216ce526716 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 11:12:47 +0200 Subject: [PATCH] more changes --- .../util/CacheConstructionUtil.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 198c429..8534159 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -137,14 +137,15 @@ public class CacheConstructionUtil { List newCreatedStationList = new ArrayList(); 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()) {