Search in sources :

Example 1 with GetLocations

use of org.activityinfo.shared.command.GetLocations in project activityinfo by bedatadriven.

the class SiteHistoryTab method setSite.

// retrieve all needed data: sitehistoryresult, schema, and locations
public void setSite(final SiteDTO site) {
    renderLoading();
    dispatcher.execute(new GetSiteHistory(site.getId()), new AsyncCallback<GetSiteHistoryResult>() {

        @Override
        public void onFailure(Throwable caught) {
            renderNotAvailable(site);
        }

        @Override
        public void onSuccess(final GetSiteHistoryResult historyResult) {
            if (historyResult.hasHistories()) {
                dispatcher.execute(new GetLocations(historyResult.collectLocationIds()), new AsyncCallback<GetLocationsResult>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        renderNotAvailable(site);
                    }

                    @Override
                    public void onSuccess(final GetLocationsResult locationsResult) {
                        dispatcher.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

                            @Override
                            public void onFailure(Throwable caught) {
                                renderNotAvailable(site);
                            }

                            @Override
                            public void onSuccess(SchemaDTO schema) {
                                render(schema, locationsResult.getLocations(), site, historyResult.getSiteHistories());
                            }
                        });
                    }
                });
            } else {
                renderNotAvailable(site);
            }
        }
    });
}
Also used : GetLocations(org.activityinfo.shared.command.GetLocations) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) GetLocationsResult(org.activityinfo.shared.command.GetLocations.GetLocationsResult) GetSiteHistory(org.activityinfo.shared.command.GetSiteHistory) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) GetSiteHistoryResult(org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult)

Example 2 with GetLocations

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

Aggregations

GetLocations (org.activityinfo.shared.command.GetLocations)2 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 GetLocationsResult (org.activityinfo.shared.command.GetLocations.GetLocationsResult)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 GetSiteHistory (org.activityinfo.shared.command.GetSiteHistory)1 GetSiteHistoryResult (org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult)1 LocationDTO (org.activityinfo.shared.dto.LocationDTO)1 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)1 Test (org.junit.Test)1