use of org.activityinfo.shared.dto.LocationDTO in project activityinfo by bedatadriven.
the class SiteDialog method showExisting.
public void showExisting(SiteDTO site, SiteDialogCallback callback) {
this.newSite = false;
this.site = site;
this.callback = callback;
LocationDTO location = site.getLocation();
location.setLocationTypeId(activity.getLocationTypeId());
locationForm.updateForm(location, false);
updateForms(site);
show();
}
use of org.activityinfo.shared.dto.LocationDTO in project activityinfo by bedatadriven.
the class SiteDialogLauncher method chooseLocationThenAddSite.
private void chooseLocationThenAddSite(final ActivityDTO activity, final SiteDialogCallback callback) {
LocationDialog dialog = new LocationDialog(dispatcher, activity.getDatabase().getCountry(), activity.getLocationType());
dialog.show(new LocationDialog.Callback() {
@Override
public void onSelected(LocationDTO location, boolean isNew) {
SiteDTO newSite = new SiteDTO();
newSite.setActivityId(activity.getId());
newSite.setLocation(location);
SiteDialog dialog = new SiteDialog(dispatcher, activity);
dialog.showNew(newSite, location, isNew, callback);
}
});
}
use of org.activityinfo.shared.dto.LocationDTO in project activityinfo by bedatadriven.
the class FormSubmissionResource method createCreateLocationCommand.
private CreateLocation createCreateLocationCommand(SiteFormData data, SchemaDTO schemaDTO, ActivityDTO activity) {
// create the dto
LocationDTO loc = new LocationDTO();
loc.setId(new KeyGenerator().generateInt());
loc.setLocationTypeId(activity.getLocationTypeId());
loc.setName(data.getLocationname());
loc.setLatitude(data.getLatitude());
loc.setLongitude(data.getLongitude());
CreateLocation cmd = new CreateLocation(loc);
// get adminentities that contain the specified coordinates
List<AdminEntity> adminentities = geocoder.geocode(data.getLatitude(), data.getLongitude());
if (adminentities.isEmpty()) {
AdminEntity adminEntity = createDebugAdminEntity();
if (adminEntity != null) {
adminentities.add(adminEntity);
}
}
if (!adminentities.isEmpty()) {
RpcMap map = cmd.getProperties();
for (AdminEntity entity : adminentities) {
map.put(AdminLevelDTO.getPropertyName(entity.getLevel().getId()), entity.getId());
}
}
return cmd;
}
use of org.activityinfo.shared.dto.LocationDTO 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.dto.LocationDTO in project activityinfo by bedatadriven.
the class GetLocationsTest method testGetLocation.
@Test
public void testGetLocation() {
setUser(1);
LocationDTO location = execute(new GetLocations(1)).getLocation();
assertThat(location, notNullValue());
assertThat(location.getName(), equalTo("Penekusu Kivu"));
assertThat(location.getAxe(), nullValue());
assertThat(location.getAdminEntity(1).getName(), equalTo("Sud Kivu"));
assertThat(location.getAdminEntity(2).getName(), equalTo("Shabunda"));
}
Aggregations