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)) {