Search in sources :

Example 11 with LocationDTO

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"));
}
Also used : GetLocations(org.activityinfo.legacy.shared.command.GetLocations) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO) Test(org.junit.Test)

Example 12 with LocationDTO

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));
}
Also used : GetLocations(org.activityinfo.legacy.shared.command.GetLocations) FormInstance(org.activityinfo.model.form.FormInstance) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO) LocationResult(org.activityinfo.legacy.shared.command.result.LocationResult) Test(org.junit.Test)

Example 13 with LocationDTO

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);
        }
    });
}
Also used : ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent) RemoveFilterEvent(org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterEvent) ApplyFilterHandler(org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterHandler) ApplyFilterEvent(org.activityinfo.ui.client.component.filter.FilterToolBar.ApplyFilterEvent) RemoveFilterHandler(org.activityinfo.ui.client.component.filter.FilterToolBar.RemoveFilterHandler) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO)

Example 14 with LocationDTO

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);
}
Also used : CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) SiteResult(org.activityinfo.legacy.shared.command.result.SiteResult) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) LocationDTO(org.activityinfo.legacy.shared.model.LocationDTO) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

LocationDTO (org.activityinfo.legacy.shared.model.LocationDTO)14 LocationResult (org.activityinfo.legacy.shared.command.result.LocationResult)6 Test (org.junit.Test)5 GetLocations (org.activityinfo.legacy.shared.command.GetLocations)4 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)2 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)2 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)2 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)2 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)2 AdminEntityDTO (org.activityinfo.legacy.shared.model.AdminEntityDTO)2 FormInstance (org.activityinfo.model.form.FormInstance)2 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 ListStore (com.extjs.gxt.ui.client.store.ListStore)1 RowData (com.extjs.gxt.ui.client.widget.layout.RowData)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1