@@ -143,25 +143,12 @@ public LinkedHashMap<CompanySiteDto, List<Polygon>> fetchPolygonDtos(List<Compan
143
143
return companySiteDtos .stream ()
144
144
.map (myCs -> Map .entry (myCs , findPolygons (polygons , myCs .getId ())))
145
145
.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
+ }
156
147
157
148
private List <Polygon > findPolygons (List <Polygon > polygons , Long myCsId ) {
158
149
return polygons .stream ().filter (myPolygon -> myPolygon .getCompanySite ().getId ().equals (myCsId )).toList ();
159
150
}
160
151
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
-
165
152
public LinkedHashMap <PolygonDto , List <Ring >> fetchRingDtos (List <PolygonDto > polygonDtos ) {
166
153
List <Ring > rings = this .ringRepository
167
154
.findAllByPolygonIds (polygonDtos .stream ().map (PolygonDto ::getId ).collect (Collectors .toList ())).stream ()
@@ -179,29 +166,11 @@ public LinkedHashMap<RingDto, List<Location>> fetchLocationDtos(List<RingDto> ri
179
166
.map (myRi -> Map .entry (myRi , findLocations (locations , myRi .getId ())))
180
167
.collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue , (e1 , e2 ) -> {throw new RuntimeException ();}, LinkedHashMap ::new ));
181
168
}
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
- }
191
169
192
170
private List <Ring > findRings (List <Ring > rings , Long myPgId ) {
193
171
return rings .stream ().filter (myRing -> myRing .getPolygon ().getId ().equals (myPgId )).collect (Collectors .toList ());
194
172
}
195
173
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
-
205
174
private List <Location > findLocations (List <Location > locations , Long myRiId ) {
206
175
return locations .stream ().filter (myLocation -> myLocation .getRing ().getId ().equals (myRiId ))
207
176
.sorted ((a ,b ) -> a .getOrderId ().compareTo (b .getOrderId ()))
0 commit comments