use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.
the class IndicatorLinkPage method onToggleLink.
protected void onToggleLink() {
IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
final boolean isLinked = !linkGraph.linked(source, dest);
linkButton.toggle(isLinked);
LinkIndicators updateCommand = new LinkIndicators();
updateCommand.setLink(isLinked);
updateCommand.setSourceIndicatorId(source.getId());
updateCommand.setDestIndicatorId(dest.getId());
if (isLinked) {
linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
} else {
linkGraph.unlink(source, dest);
}
destDatabaseGrid.setLinked(linkGraph.destDatabases());
sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
onDatabaseLinksChanged();
dispatcher.execute(updateCommand, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
Log.error(caught.getMessage(), caught);
}
@Override
public void onSuccess(VoidResult result) {
Info.displayText(I18N.CONSTANTS.saved(), isLinked ? I18N.CONSTANTS.linkCreated() : I18N.CONSTANTS.linkRemoved());
}
});
}
use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.
the class ShareReportDialog method populateGrid.
private void populateGrid(IndicatorResult indicators, ReportVisibilityResult visibility) {
gridStore.removeAll();
Map<Integer, ReportVisibilityDTO> databases = Maps.newHashMap();
for (ReportVisibilityDTO model : visibility.getList()) {
databases.put(model.getDatabaseId(), model);
}
for (IndicatorDTO indicator : indicators.getIndicators()) {
if (!databases.containsKey(indicator.getDatabaseId())) {
ReportVisibilityDTO model = new ReportVisibilityDTO();
model.setDatabaseId(indicator.getDatabaseId());
model.setDatabaseName(indicator.getDatabaseName());
databases.put(indicator.getDatabaseId(), model);
}
}
for (ReportVisibilityDTO model : databases.values()) {
gridStore.add(model);
}
if (gridStore.getCount() == 0) {
MessageBox.alert(I18N.CONSTANTS.share(), I18N.CONSTANTS.emptyReportsCannotBeShared(), new Listener<MessageBoxEvent>() {
@Override
public void handleEvent(MessageBoxEvent be) {
hide();
}
});
}
}
use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.
the class ItextMapRenderer method addSingleIndicatorDescription.
private void addSingleIndicatorDescription(MapReportElement element, MapLayer layer, Cell descriptionCell) {
int indicatorId = layer.getIndicatorIds().get(0);
IndicatorDTO indicator = element.getContent().getIndicatorById(indicatorId);
if (indicator == null) {
throw new NullPointerException("indicatorId:" + indicatorId);
}
descriptionCell.add(ThemeHelper.filterDescription(indicator.getName()));
}
use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.
the class GetIndicatorsHandler method createDto.
private IndicatorDTO createDto(SqlResultSetRow rs) {
IndicatorDTO indicator = new IndicatorDTO();
indicator.setId(rs.getInt("indicatorId"));
indicator.setActivityId(rs.getInt("activityId"));
indicator.setDatabaseId(rs.getInt("databaseId"));
indicator.setDatabaseName(rs.getString("databaseName"));
indicator.setName(rs.getString("name"));
indicator.setTypeId(rs.getString("type"));
indicator.setExpression(rs.getString("expression"));
indicator.setRelevanceExpression(rs.getString("skipExpression"));
indicator.setNameInExpression(rs.getString("nameInExpression"));
indicator.setCalculatedAutomatically(rs.getBoolean("calculatedAutomatically"));
indicator.setCategory(rs.getString("category"));
indicator.setListHeader(rs.getString("listHeader"));
indicator.setDescription(rs.getString("description"));
indicator.setAggregation(rs.getInt("aggregation"));
indicator.setUnits(rs.getString("units"));
indicator.setMandatory(rs.getBoolean("mandatory"));
indicator.setVisible(rs.getBoolean("visible"));
indicator.setSortOrder(rs.getInt("sortOrder"));
return indicator;
}
use of org.activityinfo.legacy.shared.model.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");
IndicatorDTO indicator3 = new IndicatorDTO();
indicator3.setAggregation(IndicatorDTO.AGGREGATE_SUM);
indicator3.setType(FieldTypeClass.NARRATIVE);
indicator3.setId(3);
indicator3.setName("Third indicator");
indicator3.setCategory("Second group");
ActivityFormDTO activity = new ActivityFormDTO();
activity.setId(1);
activity.getIndicators().add(indicator1);
activity.getIndicators().add(indicator2);
activity.getIndicators().add(indicator3);
SiteDTO site = new SiteDTO();
site.setIndicatorValue(1, 1000d);
site.setIndicatorValue(2, 2000d);
site.setIndicatorValue(3, "Some help but not a huge amount.\nHowever there was " + "some other information that I'd like to present in " + "second paragraph.");
String html = siteRenderer.renderSite(site, activity, true);
System.out.println(html);
assertTrue(html.contains(indicator1.getName()));
assertTrue(html.contains(indicator2.getName()));
assertTrue(html.contains(indicator3.getName()));
}
Aggregations