Search in sources :

Example 1 with GeographicalCoordinatesWithBPartnerLocationId

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;
}
Also used : GeographicalCoordinatesWithBPartnerLocationId(de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId) ArrayList(java.util.ArrayList) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JsonViewRowGeoLocation(de.metas.ui.web.document.geo_location.json.JsonViewRowGeoLocation) GeographicalCoordinates(de.metas.location.geocoding.GeographicalCoordinates)

Example 2 with GeographicalCoordinatesWithBPartnerLocationId

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;
}
Also used : GeographicalCoordinatesWithBPartnerLocationId(de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId) ArrayList(java.util.ArrayList) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) BPartnerId(de.metas.bpartner.BPartnerId) JsonViewRowGeoLocation(de.metas.ui.web.document.geo_location.json.JsonViewRowGeoLocation) GeographicalCoordinates(de.metas.location.geocoding.GeographicalCoordinates)

Aggregations

GeographicalCoordinatesWithBPartnerLocationId (de.metas.bpartner.GeographicalCoordinatesWithBPartnerLocationId)2 GeographicalCoordinates (de.metas.location.geocoding.GeographicalCoordinates)2 JsonViewRowGeoLocation (de.metas.ui.web.document.geo_location.json.JsonViewRowGeoLocation)2 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)2 ArrayList (java.util.ArrayList)2 BPartnerId (de.metas.bpartner.BPartnerId)1