more changes
This commit is contained in:
parent
159f8e67a5
commit
7be8b265bd
@ -125,10 +125,10 @@ public class CacheConstructionUtil {
|
||||
public static ResponseEntity editCacheUtil(Cache cache) {
|
||||
Optional<Cache> oldCacheOptional = cacheRepository.findById(cache.getId());
|
||||
Cache oldCache;
|
||||
List<Station> oldStationen;
|
||||
// List<Station> 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)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user