@@ -68,35 +68,6 @@ public Collection<CompanySite> findCompanySiteByTitleAndYear(String title, Long
68
68
title = title .trim ().toLowerCase ();
69
69
List <CompanySite > companySites = this .companySiteRepository .findByTitleFromTo (title , beginOfYear , endOfYear )
70
70
.stream ().peek (this .entityManager ::detach ).toList ();
71
- // companySites = addEntities(withPolygons, withRings, withLocations, companySites);
72
- return companySites ;
73
- }
74
-
75
-
76
-
77
- private List <CompanySite > addEntities (boolean withPolygons , boolean withRings , boolean withLocations ,
78
- List <CompanySite > companySites ) {
79
- if (withPolygons ) {
80
- Map <Long , List <Polygon >> fetchPolygons = this .fetchPolygonEntitys (companySites );
81
- Map <Long , List <Ring >> fetchRings = !withRings ? Map .of ()
82
- : this .fetchRings (fetchPolygons .values ().stream ().flatMap (List ::stream ).toList ());
83
- Map <Long , List <Location >> fetchLocations = !withLocations ? Map .of ()
84
- : this .fetchLocations (fetchRings .values ().stream ().flatMap (List ::stream ).toList ());
85
- companySites .forEach (myCompanySite -> {
86
- myCompanySite .setPolygons (new HashSet <>(fetchPolygons .getOrDefault (myCompanySite .getId (), List .of ())));
87
- if (withRings ) {
88
- myCompanySite .getPolygons ().forEach (myPolygon -> {
89
- myPolygon .setRings (new HashSet <>(fetchRings .getOrDefault (myPolygon .getId (), List .of ())));
90
- if (withLocations ) {
91
- myPolygon .getRings ().forEach (myRing -> {
92
- myRing .setLocations (
93
- new HashSet <>(fetchLocations .getOrDefault (myRing .getId (), List .of ())));
94
- });
95
- }
96
- });
97
- }
98
- });
99
- }
100
71
return companySites ;
101
72
}
102
73
@@ -108,7 +79,6 @@ public Optional<CompanySite> findCompanySiteById(Long id) {
108
79
public Optional <CompanySite > findCompanySiteByIdDetached (Long id , boolean withPolygons , boolean withRings ,
109
80
boolean withLocations ) {
110
81
return Optional .ofNullable (id ).flatMap (myId -> this .companySiteRepository .findById (myId )).stream ()
111
- // .peek(myCompanySite -> this.addEntities(withPolygons, withRings, withLocations, List.of(myCompanySite)))
112
82
.findFirst ();
113
83
}
114
84
@@ -208,7 +178,7 @@ public LinkedHashMap<RingDto, List<Location>> fetchLocationDtos(List<RingDto> ri
208
178
.findAllByRingIds (ringDtos .stream ().map (RingDto ::getId ).collect (Collectors .toList ())).stream ()
209
179
.peek (this .entityManager ::detach ).toList ();
210
180
return ringDtos .stream ()
211
- .map (myRi -> Map .entry (myRi , findLocations (locations , myRi .getId ())))
181
+ .map (myRi -> Map .entry (myRi , findLocations (locations , myRi .getId ())))
212
182
.collect (Collectors .toMap (Map .Entry ::getKey , Map .Entry ::getValue , (e1 , e2 ) -> {throw new RuntimeException ();}, LinkedHashMap ::new ));
213
183
}
214
184
@@ -236,6 +206,7 @@ public Map<Long, List<Location>> fetchLocations(List<Ring> rings) {
236
206
237
207
private List <Location > findLocations (List <Location > locations , Long myRiId ) {
238
208
return locations .stream ().filter (myLocation -> myLocation .getRing ().getId ().equals (myRiId ))
209
+ .sorted ((a ,b ) -> a .getOrderId ().compareTo (b .getOrderId ()))
239
210
.collect (Collectors .toList ());
240
211
}
241
212
}
0 commit comments