From 7be8b265bd2a506a99a1fab82c5e43e9b32661a5 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 14 May 2019 11:30:15 +0200 Subject: [PATCH] more changes --- .../bugageocaching/util/CacheConstructionUtil.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java index 8534159..f488eb6 100644 --- a/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java +++ b/src/main/java/hhn/labsw/bugageocaching/util/CacheConstructionUtil.java @@ -125,10 +125,10 @@ public class CacheConstructionUtil { public static ResponseEntity editCacheUtil(Cache cache) { Optional oldCacheOptional = cacheRepository.findById(cache.getId()); Cache oldCache; - List oldStationen; +// List oldStationen; if (oldCacheOptional.isPresent()) { oldCache = oldCacheOptional.get(); - oldStationen = new ArrayList<>(oldCache.getStationen()); +// oldStationen = new ArrayList<>(oldCache.getStationen()); } else { return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId()); } @@ -153,12 +153,13 @@ public class CacheConstructionUtil { newCreatedStationList.add(station); } } + if (response.getStatusCodeValue() == 400) { // neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt // alle veränderten Stationen werden resettet - for (Station oldStation : oldStationen) { - stationRepository.save(oldStation); - } +// for (Station oldStation : oldStationen) { +// stationRepository.save(oldStation); +// } deleteNewCreatedStationsUtil(newCreatedStationList); return response; } @@ -191,7 +192,7 @@ public class CacheConstructionUtil { cacheRepository.save(cache); -// nicht gebrauchte Stationen müssen noch gelöscht werden +// nicht gebrauchte Stationen müssen noch aus der DB gelöscht werden // for (Station oldStation : oldCache.getStationen()) { // // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht // if (!cache.getStationen().contains(station)) {