use of de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId in project metasfresh-webui-api by metasfresh.
the class ViewGeoLocationsRestController method retrieveGeoLocationsForBPartnerLocationId.
private List<JsonViewRowGeoLocation> retrieveGeoLocationsForBPartnerLocationId(final ImmutableSetMultimap<Integer, DocumentId> rowIdsByBPartnerLocationRepoId) {
if (rowIdsByBPartnerLocationRepoId.isEmpty()) {
return ImmutableList.of();
}
final List<JsonViewRowGeoLocation> result = new ArrayList<>();
final ImmutableSet<Integer> bpartnerLocationRepoIds = rowIdsByBPartnerLocationRepoId.keySet();
for (final GeographicalCoordinatesWithBPartnerLocationId bplCoordinates : bpartnersRepo.getGeoCoordinatesByBPartnerLocationIds(bpartnerLocationRepoIds)) {
final int bpartnerLocationRepoId = bplCoordinates.getBpartnerLocationId().getRepoId();
final ImmutableSet<DocumentId> rowIds = rowIdsByBPartnerLocationRepoId.get(bpartnerLocationRepoId);
if (rowIds.isEmpty()) {
// shall not happen
logger.warn("Ignored unexpected bpartnerLocationId={}. We have no rows for it.", bpartnerLocationRepoId);
continue;
}
final GeographicalCoordinates coordinate = bplCoordinates.getCoordinate();
for (final DocumentId rowId : rowIds) {
result.add(JsonViewRowGeoLocation.builder().rowId(rowId).latitude(coordinate.getLatitude()).longitude(coordinate.getLongitude()).build());
}
}
return result;
}
use of de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId in project metasfresh-webui-api by metasfresh.
the class ViewGeoLocationsRestController method retrieveGeoLocationsForBPartnerId.
private List<JsonViewRowGeoLocation> retrieveGeoLocationsForBPartnerId(final ImmutableSetMultimap<BPartnerId, DocumentId> rowIdsByBPartnerId) {
if (rowIdsByBPartnerId.isEmpty()) {
return ImmutableList.of();
}
final List<JsonViewRowGeoLocation> result = new ArrayList<>();
final ImmutableSet<BPartnerId> bpartnerIds = rowIdsByBPartnerId.keySet();
for (final GeographicalCoordinatesWithBPartnerLocationId bplCoordinates : bpartnersRepo.getGeoCoordinatesByBPartnerIds(bpartnerIds)) {
final BPartnerId bpartnerId = bplCoordinates.getBPartnerId();
final ImmutableSet<DocumentId> rowIds = rowIdsByBPartnerId.get(bpartnerId);
if (rowIds.isEmpty()) {
// shall not happen
logger.warn("Ignored unexpected bpartnerId={}. We have no rows for it.", bpartnerId);
continue;
}
final GeographicalCoordinates coordinate = bplCoordinates.getCoordinate();
for (final DocumentId rowId : rowIds) {
result.add(JsonViewRowGeoLocation.builder().rowId(rowId).latitude(coordinate.getLatitude()).longitude(coordinate.getLongitude()).build());
}
}
return result;
}
Aggregations