Search in sources :

Example 1 with GetSiteHistory

use of org.activityinfo.shared.command.GetSiteHistory 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 GetSiteHistory

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

the class GetSiteHistoryTest method testGetSiteHistory.

@Test
public void testGetSiteHistory() {
    setUser(1);
    int siteId = 1;
    GetSiteHistoryResult result = execute(new GetSiteHistory(siteId));
    assertNotNull(result);
    assertEquals(2, result.getSiteHistories().size());
    SiteHistoryDTO dto1 = result.getSiteHistories().get(0);
    assertEquals(1, dto1.getId());
    assertTrue(dto1.isInitial());
    Map<String, Object> map = dto1.getJsonMap();
    assertEquals(new Integer(1), map.get("id"));
    assertEquals("1", String.valueOf(map.get("id")));
    assertEquals("54.0", String.valueOf(map.get("I4925")));
    assertEquals("site 1 my first comment", map.get("comments"));
    SiteHistoryDTO dto2 = result.getSiteHistories().get(1);
    assertEquals(2, dto2.getId());
    assertFalse(dto2.isInitial());
    map = dto2.getJsonMap();
    assertNull(map.get("id"));
    assertNull(map.get("I4925"));
    assertEquals("site 1 changed comment", map.get("comments"));
}
Also used : SiteHistoryDTO(org.activityinfo.shared.dto.SiteHistoryDTO) GetSiteHistory(org.activityinfo.shared.command.GetSiteHistory) GetSiteHistoryResult(org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult) Test(org.junit.Test)

Aggregations

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