use of org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult 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);
}
}
});
}
use of org.activityinfo.shared.command.GetSiteHistory.GetSiteHistoryResult 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"));
}
Aggregations