use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class SiteRendererTest method multipleGroupsRender.
@Test
public void multipleGroupsRender() {
IndicatorDTO indicator1 = new IndicatorDTO();
indicator1.setId(1);
indicator1.setAggregation(IndicatorDTO.AGGREGATE_SUM);
indicator1.setName("First indicator");
indicator1.setCategory("First group");
IndicatorDTO indicator2 = new IndicatorDTO();
indicator2.setAggregation(IndicatorDTO.AGGREGATE_SUM);
indicator2.setId(2);
indicator2.setName("Second indicator");
indicator2.setCategory("Second group");
ActivityDTO activity = new ActivityDTO();
activity.setId(1);
activity.getIndicators().add(indicator1);
activity.getIndicators().add(indicator2);
SiteDTO site = new SiteDTO();
site.setIndicatorValue(1, 1000d);
site.setIndicatorValue(2, 2000d);
String html = siteRenderer.renderSite(site, activity, false, true);
assertTrue(html.contains(indicator1.getName()));
assertTrue(html.contains(indicator2.getName()));
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method createIndicator.
@Test
public void createIndicator() {
synchronizeFirstTime();
SchemaDTO schema = executeLocally(new GetSchema());
Map<String, Object> indicator = Maps.newHashMap();
indicator.put("name", "New Indicator");
indicator.put("units", "bricks");
indicator.put("activityId", 2);
CreateResult createResult = executeRemotely(new CreateEntity("Indicator", indicator));
synchronize();
schema = executeLocally(new GetSchema());
IndicatorDTO createdIndicator = schema.getIndicatorById(createResult.getNewId());
assertThat(createdIndicator, is(not(nullValue())));
assertThat(createdIndicator.getName(), equalTo("New Indicator"));
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class GetSchemaTest method testIndicators.
@Test
public void testIndicators() throws CommandException {
// Alex
setUser(1);
SchemaDTO schema = execute(new GetSchema());
assertTrue("no indicators case", schema.getActivityById(2).getIndicators().size() == 0);
ActivityDTO nfi = schema.getActivityById(1);
assertThat("indicators are present", nfi.getIndicators().size(), equalTo(4));
IndicatorDTO test = nfi.getIndicatorById(2);
assertThat("property:name", test.getName(), equalTo("baches"));
assertThat("property:units", test.getUnits(), equalTo("menages"));
assertThat("property:aggregation", test.getAggregation(), equalTo(IndicatorDTO.AGGREGATE_SUM));
assertThat("property:category", test.getCategory(), equalTo("outputs"));
assertThat("property:listHeader", test.getListHeader(), equalTo("header"));
assertThat("property:description", test.getDescription(), equalTo("desc"));
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class IndicatorTreePanel method applySelection.
private void applySelection() {
for (ModelData model : tree.getStore().getAllItems()) {
if (model instanceof IndicatorDTO) {
IndicatorDTO indicator = (IndicatorDTO) model;
boolean selected = selection.contains(indicator.getId());
setChecked(indicator, selected);
}
}
}
use of org.activityinfo.shared.dto.IndicatorDTO in project activityinfo by bedatadriven.
the class DesignPresenter method fillStore.
private void fillStore(UIConstants messages) {
for (ActivityDTO activity : db.getActivities()) {
ActivityDTO activityNode = new ActivityDTO(activity);
treeStore.add(activityNode, false);
AttributeGroupFolder attributeFolder = new AttributeGroupFolder(messages.attributes());
treeStore.add(activityNode, attributeFolder, false);
for (AttributeGroupDTO group : activity.getAttributeGroups()) {
if (group != null) {
AttributeGroupDTO groupNode = new AttributeGroupDTO(group);
treeStore.add(attributeFolder, groupNode, false);
for (AttributeDTO attribute : group.getAttributes()) {
AttributeDTO attributeNode = new AttributeDTO(attribute);
treeStore.add(groupNode, attributeNode, false);
}
}
}
IndicatorFolder indicatorFolder = new IndicatorFolder(messages.indicators());
treeStore.add(activityNode, indicatorFolder, false);
for (IndicatorDTO indicator : activity.getIndicators()) {
IndicatorDTO indicatorNode = new IndicatorDTO(indicator);
treeStore.add(indicatorFolder, indicatorNode, false);
}
}
}
Aggregations