use of org.activityinfo.shared.command.result.LocationResult in project activityinfo by bedatadriven.
the class SearchLocationsHandler method retrieveLocations.
private void retrieveLocations(final SearchLocations command, final ExecutionContext context, final AsyncCallback<LocationResult> callback) {
SqlQuery query = baseQuery(command).appendColumns("LocationId", "Name", "Axe", "X", "Y").setLimitClause(dialect.limitClause(0, 26));
query.execute(context.getTransaction(), new SqlResultCallback() {
@Override
public void onSuccess(SqlTransaction tx, SqlResultSet results) {
// Create a list of locations from query result
List<LocationDTO> locations = Lists.newArrayList();
Map<Integer, LocationDTO> locationsById = Maps.newHashMap();
for (SqlResultSetRow row : results.getRows()) {
LocationDTO location = LocationDTO.fromSqlRow(row);
locations.add(location);
locationsById.put(location.getId(), location);
}
LocationResult result = new LocationResult(locations);
result.setOffset(0);
result.setTotalLength(results.getRows().size());
callback.onSuccess(result);
}
});
}
use of org.activityinfo.shared.command.result.LocationResult in project activityinfo by bedatadriven.
the class CreateLocationTest method test.
@Test
public void test() throws CommandException {
LocationDTO location = LocationDTOs.newLocation();
execute(new CreateLocation(location));
SearchLocations getLocations = new SearchLocations().setName(location.getName());
LocationResult locations = execute(getLocations);
LocationDTO newLocation = locations.getData().get(0);
assertEquals(location.getName(), newLocation.getName());
assertEquals(location.getAxe(), newLocation.getAxe());
assertEquals(location.getLongitude(), newLocation.getLongitude());
assertEquals(location.getLatitude(), newLocation.getLatitude());
}
use of org.activityinfo.shared.command.result.LocationResult in project activityinfo by bedatadriven.
the class SearchLocationsHandlerTest method test.
@Test
public void test() throws CommandException {
SearchLocations getLocations = new SearchLocations().setAdminEntityIds(Arrays.asList(3, 12)).setName("Sh");
LocationResult result = execute(getLocations);
assertTrue(result.getData().size() == 1);
}
Aggregations