Skip to content

Commit 79e1f31

Browse files
committed
fix: cleanup
1 parent 1ba63f7 commit 79e1f31

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

backend/src/main/java/ch/xxx/maps/usecase/service/CompanySiteService.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -143,25 +143,12 @@ public LinkedHashMap<CompanySiteDto, List<Polygon>> fetchPolygonDtos(List<Compan
143143
return companySiteDtos.stream()
144144
.map(myCs -> Map.entry(myCs, findPolygons(polygons, myCs.getId())))
145145
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new));
146-
}
147-
148-
public LinkedHashMap<Long, List<Polygon>> fetchPolygonEntitys(List<CompanySite> companySites) {
149-
List<Polygon> polygons = this.polygonRepository
150-
.findAllByCompanySiteIds(companySites.stream().map(myDto -> myDto.getId()).toList())
151-
.stream().peek(this.entityManager::detach).toList();
152-
return companySites.stream()
153-
.map(myCs -> Map.entry(myCs.getId(), findPolygons(polygons, myCs.getId())))
154-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new));
155-
}
146+
}
156147

157148
private List<Polygon> findPolygons(List<Polygon> polygons, Long myCsId) {
158149
return polygons.stream().filter(myPolygon -> myPolygon.getCompanySite().getId().equals(myCsId)).toList();
159150
}
160151

161-
private <T extends BaseEntity> T findEntity(List<T> companySites, Long myCsId) {
162-
return companySites.stream().filter(myCs -> myCs.getId().equals(myCsId)).findFirst().orElseThrow();
163-
}
164-
165152
public LinkedHashMap<PolygonDto, List<Ring>> fetchRingDtos(List<PolygonDto> polygonDtos) {
166153
List<Ring> rings = this.ringRepository
167154
.findAllByPolygonIds(polygonDtos.stream().map(PolygonDto::getId).collect(Collectors.toList())).stream()
@@ -179,29 +166,11 @@ public LinkedHashMap<RingDto, List<Location>> fetchLocationDtos(List<RingDto> ri
179166
.map(myRi -> Map.entry(myRi, findLocations(locations, myRi.getId())))
180167
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> {throw new RuntimeException();}, LinkedHashMap::new));
181168
}
182-
183-
public Map<Long, List<Ring>> fetchRings(List<Polygon> polygons) {
184-
List<Ring> rings = this.ringRepository
185-
.findAllByPolygonIds(polygons.stream().map(Polygon::getId).collect(Collectors.toList())).stream()
186-
.peek(this.entityManager::detach).toList();
187-
return polygons.stream().map(Polygon::getId)
188-
.map(myPgId -> Map.entry(this.findEntity(polygons, myPgId).getId(), findRings(rings, myPgId)))
189-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
190-
}
191169

192170
private List<Ring> findRings(List<Ring> rings, Long myPgId) {
193171
return rings.stream().filter(myRing -> myRing.getPolygon().getId().equals(myPgId)).collect(Collectors.toList());
194172
}
195173

196-
public Map<Long, List<Location>> fetchLocations(List<Ring> rings) {
197-
List<Location> locations = this.locationRepository
198-
.findAllByRingIds(rings.stream().map(Ring::getId).collect(Collectors.toList())).stream()
199-
.peek(this.entityManager::detach).toList();
200-
return rings.stream().map(Ring::getId)
201-
.map(myRiId -> Map.entry(this.findEntity(rings, myRiId).getId(), findLocations(locations, myRiId)))
202-
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
203-
}
204-
205174
private List<Location> findLocations(List<Location> locations, Long myRiId) {
206175
return locations.stream().filter(myLocation -> myLocation.getRing().getId().equals(myRiId))
207176
.sorted((a,b) -> a.getOrderId().compareTo(b.getOrderId()))

0 commit comments

Comments
 (0)