use of org.activityinfo.shared.dto.SiteHistoryDTO in project activityinfo by bedatadriven.
the class SiteHistoryRenderer method items.
private List<Item> items(SchemaDTO schema, List<LocationDTO> locations, SiteDTO site, List<SiteHistoryDTO> histories) {
List<Item> items = new ArrayList<Item>();
Map<String, Object> baselineState = histories.get(0).getJsonMap();
RenderContext ctx = new RenderContext(schema, locations, site, baselineState);
boolean first = true;
for (SiteHistoryDTO history : histories) {
ctx.setHistory(history);
Item item = new Item();
if (first) {
if (history.isInitial()) {
// only show if the entry was created when the actual site
// was created, don't show stub baselines
item.setMsg(I18N.MESSAGES.siteHistoryCreated(history.getDateCreated(), history.getUserName(), history.getUserEmail()));
}
first = false;
} else {
item.setMsg(I18N.MESSAGES.siteHistoryUpdated(history.getDateCreated(), history.getUserName(), history.getUserEmail()));
item.setDetails(details(ctx));
}
items.add(item);
}
Collections.reverse(items);
return items;
}
use of org.activityinfo.shared.dto.SiteHistoryDTO 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