From 79e1f313ec6298982351e7f1e7a0989284f79b75 Mon Sep 17 00:00:00 2001 From: Angular2guy Date: Fri, 2 Aug 2024 11:50:25 +0200 Subject: [PATCH] fix: cleanup --- .../usecase/service/CompanySiteService.java | 33 +------------------ 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/backend/src/main/java/ch/xxx/maps/usecase/service/CompanySiteService.java b/backend/src/main/java/ch/xxx/maps/usecase/service/CompanySiteService.java index d9a282c..a85826f 100644 --- a/backend/src/main/java/ch/xxx/maps/usecase/service/CompanySiteService.java +++ b/backend/src/main/java/ch/xxx/maps/usecase/service/CompanySiteService.java @@ -143,25 +143,12 @@ public LinkedHashMap> fetchPolygonDtos(List Map.entry(myCs, findPolygons(polygons, myCs.getId()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new)); - } - - public LinkedHashMap> fetchPolygonEntitys(List companySites) { - List polygons = this.polygonRepository - .findAllByCompanySiteIds(companySites.stream().map(myDto -> myDto.getId()).toList()) - .stream().peek(this.entityManager::detach).toList(); - return companySites.stream() - .map(myCs -> Map.entry(myCs.getId(), findPolygons(polygons, myCs.getId()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new)); - } + } private List findPolygons(List polygons, Long myCsId) { return polygons.stream().filter(myPolygon -> myPolygon.getCompanySite().getId().equals(myCsId)).toList(); } - private T findEntity(List companySites, Long myCsId) { - return companySites.stream().filter(myCs -> myCs.getId().equals(myCsId)).findFirst().orElseThrow(); - } - public LinkedHashMap> fetchRingDtos(List polygonDtos) { List rings = this.ringRepository .findAllByPolygonIds(polygonDtos.stream().map(PolygonDto::getId).collect(Collectors.toList())).stream() @@ -179,29 +166,11 @@ public LinkedHashMap> fetchLocationDtos(List ri .map(myRi -> Map.entry(myRi, findLocations(locations, myRi.getId()))) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new)); } - - public Map> fetchRings(List polygons) { - List rings = this.ringRepository - .findAllByPolygonIds(polygons.stream().map(Polygon::getId).collect(Collectors.toList())).stream() - .peek(this.entityManager::detach).toList(); - return polygons.stream().map(Polygon::getId) - .map(myPgId -> Map.entry(this.findEntity(polygons, myPgId).getId(), findRings(rings, myPgId))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } private List findRings(List rings, Long myPgId) { return rings.stream().filter(myRing -> myRing.getPolygon().getId().equals(myPgId)).collect(Collectors.toList()); } - public Map> fetchLocations(List rings) { - List locations = this.locationRepository - .findAllByRingIds(rings.stream().map(Ring::getId).collect(Collectors.toList())).stream() - .peek(this.entityManager::detach).toList(); - return rings.stream().map(Ring::getId) - .map(myRiId -> Map.entry(this.findEntity(rings, myRiId).getId(), findLocations(locations, myRiId))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - private List findLocations(List locations, Long myRiId) { return locations.stream().filter(myLocation -> myLocation.getRing().getId().equals(myRiId)) .sorted((a,b) -> a.getOrderId().compareTo(b.getOrderId()))