final PositionsModel positionsModel,
final int[] rows,
final OverwritePredicate predicate) {
executeOperation(positionsTable, positionsModel, rows, true, predicate,
new Operation() {
private GoogleMapsService googleMapsService = new GoogleMapsService();
public String getName() {
return "CoordinatesPositionAugmenter";
}
public int getColumnIndex() {
return ALL_COLUMNS; // LONGITUDE_COLUMN_INDEX + LATITUDE_COLUMN_INDEX;
}
public void performOnStart() {
}
public boolean run(int index, NavigationPosition position) throws Exception {
NavigationPosition coordinates = googleMapsService.getPositionFor(position.getDescription());
if (coordinates != null)
positionsModel.edit(index,
new PositionColumnValues(asList(LONGITUDE_COLUMN_INDEX, LATITUDE_COLUMN_INDEX),
Arrays.<Object>asList(coordinates.getLongitude(), coordinates.getLatitude())), false, true);
return coordinates != null;