use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class GetLocationsTest method testGetLocation.
@Test
public void testGetLocation() {
setUser(1);
LocationDTO location = execute(new GetLocations(1)).getData().get(0);
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"));
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class ResourceLocatorAdaptorTest method updateLocation.
@Test
public void updateLocation() {
// <location locationId="1" name="Penekusu Kivu" locationTypeId="1"
// X="1.532" Y="27.323" timeEdited="1"/>
// <locationAdminLink locationId="1" adminEntityId="2"/>
// <locationAdminLink locationId="1" adminEntityId="12"/>
FormInstance instance = assertResolves(locator.getFormInstance(HEALTH_CENTER_CLASS, locationInstanceId(1)));
instance.set(field(HEALTH_CENTER_CLASS, NAME_FIELD), "New Penekusu");
assertResolves(locator.persist(instance));
GetLocations query = new GetLocations(1);
LocationResult result = execute(query);
LocationDTO location = result.getData().get(0);
assertThat(location.getName(), equalTo("New Penekusu"));
assertThat(location.getLocationTypeId(), equalTo(1));
assertThat(location.getLatitude(), equalTo(27.323));
assertThat(location.getLongitude(), equalTo(1.532));
// 12 admin level is not returned because we eliminate redundant information org.activityinfo.store.mysql.side.AdminColumnBuilder.emit(int[])
assertThat(location.getAdminEntity(1).getId(), equalTo(2));
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocationFilterPanel method createFilterToolBar.
private void createFilterToolBar() {
filterToolBar = new FilterToolBar();
filterToolBar.add(removeSelectedItem);
filterToolBar.addApplyFilterHandler(new ApplyFilterHandler() {
@Override
public void onApplyFilter(ApplyFilterEvent deleteEvent) {
applyFilter();
}
});
filterToolBar.addRemoveFilterHandler(new RemoveFilterHandler() {
@Override
public void onRemoveFilter(RemoveFilterEvent deleteEvent) {
clearFilter();
ValueChangeEvent.fire(LocationFilterPanel.this, value);
}
});
setTopComponent(filterToolBar);
removeSelectedItem.setEnabled(false);
removeSelectedItem.addSelectionListener(new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
for (LocationDTO location : listSelectionModel.getSelection()) {
store.remove(location);
}
}
});
listSelectionModel.addSelectionChangedListener(new SelectionChangedListener<LocationDTO>() {
@Override
public void selectionChanged(SelectionChangedEvent<LocationDTO> se) {
removeSelectedItem.setEnabled(se.getSelectedItem() != null);
}
});
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method createNew.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() {
synchronize();
// create a new detached, client model
SiteDTO newSite = SiteDTOs.newSite();
LocationDTO location = LocationDTOs.newLocation();
executeLocally(new CreateLocation(location));
newSite.setLocation(location);
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
CreateResult result = executeLocally(cmd);
// let the client know the command has succeeded
newSite.setId(result.getNewId());
// try to retrieve what we've created FROM OUR CLIENT SIDE DATABASE
SiteResult loadResult = executeLocally(GetSites.byId(newSite.getId()));
Assert.assertEquals(1, loadResult.getData().size());
SiteDTO secondRead = loadResult.getData().get(0);
// confirm that the changes are there
SiteDTOs.validateNewSite(secondRead);
newRequest();
// now Sync with the server
synchronize();
// Confirm that paging works client side
GetSites pagingRequest = new GetSites();
pagingRequest.setLimit(1);
executeLocally(pagingRequest);
}
Aggregations