use of com.arnaugarcia.uplace.domain.Marker in project uplace.es by Uplace.
the class MarkerService method getAllMarkers.
@Transactional(readOnly = true)
public List<MarkerDTO> getAllMarkers() {
List<Marker> markerList = propertyRepository.findAllMarkers();
List<MarkerDTO> markerDTOS = markerList.parallelStream().map(markerToMarkerDTO).collect(Collectors.toList());
// This can be made with JPA 1.7 findTop or inner join query
Pageable limit = new PageRequest(0, 1);
markerDTOS.parallelStream().forEach((markerDTO -> {
List<Photo> photos = propertyRepository.findThumbnailByReference(markerDTO.getPropertyReference(), limit);
if (!photos.isEmpty())
markerDTO.setPhoto(photos.get(0));
}));
/*markerDTOList.parallelStream().forEach((markerDTO -> {
if (markerDTO.getDate() != null) {
LocalDate localDate = markerDTO.getDate().toLocalDate();
LocalDate today = LocalDate.now();
Period period = Period.between(localDate, today);
if (period.getMonths() >= 1) {
markerDTO.setNew(false);
} else {
markerDTO.setNew(true);
}
} else {
markerDTO.setNew(false);
}
}));
List<MarkerDTO> result = markerDTOList.parallelStream()
.filter(markerDTO -> Objects.nonNull(markerDTO.getLatitude()))
.filter(markerDTO -> markerDTO.getLatitude() > 0)
.filter(markerDTO -> Objects.nonNull(markerDTO.getLongitude()))
.filter(markerDTO -> markerDTO.getLongitude() > 0)
.collect(Collectors.toList());*/
return markerDTOS;
}
Aggregations