more changes
This commit is contained in:
parent
159f8e67a5
commit
7be8b265bd
@ -125,10 +125,10 @@ public class CacheConstructionUtil {
|
|||||||
public static ResponseEntity editCacheUtil(Cache cache) {
|
public static ResponseEntity editCacheUtil(Cache cache) {
|
||||||
Optional<Cache> oldCacheOptional = cacheRepository.findById(cache.getId());
|
Optional<Cache> oldCacheOptional = cacheRepository.findById(cache.getId());
|
||||||
Cache oldCache;
|
Cache oldCache;
|
||||||
List<Station> oldStationen;
|
// List<Station> oldStationen;
|
||||||
if (oldCacheOptional.isPresent()) {
|
if (oldCacheOptional.isPresent()) {
|
||||||
oldCache = oldCacheOptional.get();
|
oldCache = oldCacheOptional.get();
|
||||||
oldStationen = new ArrayList<>(oldCache.getStationen());
|
// oldStationen = new ArrayList<>(oldCache.getStationen());
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId());
|
return ResponseEntity.status(404).body("There isnt a cache with the id " + cache.getId());
|
||||||
}
|
}
|
||||||
@ -153,12 +153,13 @@ public class CacheConstructionUtil {
|
|||||||
newCreatedStationList.add(station);
|
newCreatedStationList.add(station);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.getStatusCodeValue() == 400) {
|
if (response.getStatusCodeValue() == 400) {
|
||||||
// neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt
|
// neu erzeugte Stationen werden gelöscht, falls es einen Fehler gibt
|
||||||
// alle veränderten Stationen werden resettet
|
// alle veränderten Stationen werden resettet
|
||||||
for (Station oldStation : oldStationen) {
|
// for (Station oldStation : oldStationen) {
|
||||||
stationRepository.save(oldStation);
|
// stationRepository.save(oldStation);
|
||||||
}
|
// }
|
||||||
deleteNewCreatedStationsUtil(newCreatedStationList);
|
deleteNewCreatedStationsUtil(newCreatedStationList);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -191,7 +192,7 @@ public class CacheConstructionUtil {
|
|||||||
|
|
||||||
cacheRepository.save(cache);
|
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()) {
|
// for (Station oldStation : oldCache.getStationen()) {
|
||||||
// // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht
|
// // wenn Station entfernt wurde, wird diese auch aus der Datenbank gelöscht
|
||||||
// if (!cache.getStationen().contains(station)) {
|
// if (!cache.getStationen().contains(station)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user