use of org.activityinfo.shared.dto.IndicatorGroup in project activityinfo by bedatadriven.
the class IndicatorTreePanel method createActivityChildren.
private List<ModelData> createActivityChildren(ActivityDTO acitvity) {
List<IndicatorGroup> groupIndicators = acitvity.groupIndicators();
List<ModelData> children = new ArrayList<ModelData>();
for (IndicatorGroup group : groupIndicators) {
if (group.getName() == null) {
for (IndicatorDTO indicator : group.getIndicators()) {
children.add(indicator);
}
} else {
children.add(group);
}
}
return children;
}
use of org.activityinfo.shared.dto.IndicatorGroup in project activityinfo by bedatadriven.
the class PrintDataEntryForm method addIndicators.
private String addIndicators(ActivityDTO activity) {
StringBuilder builder = new StringBuilder();
builder.append("<table border=\"1px\" align=\"left\" cellpadding=\"0\" cellspacing=\"0\" class=\"form-detail\">");
for (IndicatorGroup group : activity.groupIndicators()) {
if (group.getName() != null) {
builder.append("<tr><td colspan='3'><h3 class='indicatorGroup'> " + group.getName() + "</h3><td></tr>");
}
builder.append("<tr>");
builder.append("<td>Indicator</td>");
builder.append("<td>Valeur</td>");
builder.append("<td>Units</td>");
builder.append("</tr>");
for (IndicatorDTO indicator : group.getIndicators()) {
addIndicator(indicator, builder);
}
}
builder.append("</table>");
return builder.toString();
}
use of org.activityinfo.shared.dto.IndicatorGroup in project activityinfo by bedatadriven.
the class SiteRenderer method renderIndicators.
private String renderIndicators(SiteDTO site, ActivityDTO activity, boolean showEmptyRows) {
StringBuilder html = new StringBuilder();
html.append("<br/><p><span class='groupName'>");
html.append(I18N.CONSTANTS.indicators());
html.append(":</p>");
html.append("<table class='indicatorTable' cellspacing='0'>");
boolean hasContent = false;
for (IndicatorGroup group : activity.groupIndicators()) {
boolean groupHasContent = renderIndicatorGroup(html, group, site, showEmptyRows);
hasContent = hasContent || groupHasContent;
}
html.append("</table>");
return hasContent ? html.toString() : "";
}
use of org.activityinfo.shared.dto.IndicatorGroup in project activityinfo by bedatadriven.
the class SiteExporter method createHeaders.
private void createHeaders(ActivityDTO activity, HSSFSheet sheet) {
// / The HEADER rows
Row headerRow1 = sheet.createRow(0);
Row headerRow2 = sheet.createRow(1);
headerRow2.setHeightInPoints(HEADER_CELL_HEIGHT);
// Create a title cell with the complete database + activity name
Cell titleCell = headerRow1.createCell(0);
titleCell.setCellValue(creationHelper.createRichTextString(activity.getDatabase().getName() + " - " + activity.getName()));
titleCell.setCellStyle(titleStyle);
int column = 0;
createHeaderCell(headerRow2, column++, "Date1", CellStyle.ALIGN_RIGHT);
createHeaderCell(headerRow2, column++, "Date2", CellStyle.ALIGN_RIGHT);
createHeaderCell(headerRow2, column, "Partner");
sheet.setColumnWidth(column, characters(PARTNER_COLUMN_WIDTH));
column++;
createHeaderCell(headerRow2, column, activity.getLocationType().getName());
sheet.setColumnWidth(column, characters(LOCATION_COLUMN_WIDTH));
column++;
createHeaderCell(headerRow2, column++, "Axe");
indicators = new ArrayList<Integer>(activity.getIndicators().size());
if (activity.getReportingFrequency() == ActivityDTO.REPORT_ONCE) {
for (IndicatorGroup group : activity.groupIndicators()) {
if (group.getName() != null) {
// create a merged cell on the top row spanning all members
// of the group
createHeaderCell(headerRow1, column, group.getName());
sheet.addMergedRegion(new CellRangeAddress(0, 0, column, column + group.getIndicators().size() - 1));
}
for (IndicatorDTO indicator : group.getIndicators()) {
indicators.add(indicator.getId());
createHeaderCell(headerRow2, column, indicator.getName(), indicatorHeaderStyle);
sheet.setColumnWidth(column, characters(INDICATOR_COLUMN_WIDTH));
column++;
}
}
}
attributes = new ArrayList<Integer>();
for (AttributeGroupDTO group : activity.getAttributeGroups()) {
if (group.getAttributes().size() != 0) {
createHeaderCell(headerRow1, column, group.getName(), CellStyle.ALIGN_CENTER);
sheet.addMergedRegion(new CellRangeAddress(0, 0, column, column + group.getAttributes().size() - 1));
for (AttributeDTO attrib : group.getAttributes()) {
attributes.add(attrib.getId());
createHeaderCell(headerRow2, column, attrib.getName(), attribHeaderStyle);
sheet.setColumnWidth(column, characters(ATTRIBUTE_COLUMN_WIDTH));
column++;
}
}
}
levels = new ArrayList<Integer>();
for (AdminLevelDTO level : activity.getAdminLevels()) {
createHeaderCell(headerRow2, column++, "Code " + level.getName());
createHeaderCell(headerRow2, column++, level.getName());
levels.add(level.getId());
}
int latColumn = column++;
int lngColumn = column++;
createHeaderCell(headerRow2, latColumn, I18N.CONSTANTS.longitude(), CellStyle.ALIGN_RIGHT);
createHeaderCell(headerRow2, lngColumn, I18N.CONSTANTS.latitude(), CellStyle.ALIGN_RIGHT);
sheet.setColumnWidth(lngColumn, characters(COORD_COLUMN_WIDTH));
sheet.setColumnWidth(latColumn, characters(COORD_COLUMN_WIDTH));
createHeaderCell(headerRow2, column++, I18N.CONSTANTS.comments());
}
use of org.activityinfo.shared.dto.IndicatorGroup in project activityinfo by bedatadriven.
the class IndicatorTreePanel method loadSingleDatabase.
public void loadSingleDatabase(UserDatabaseDTO database) {
store.removeAll();
for (ActivityDTO activity : database.getActivities()) {
store.add(activity, true);
List<ModelData> models = createActivityChildren(activity);
for (ModelData model : models) {
if (model instanceof IndicatorGroup) {
store.add(activity, model, true);
store.add(model, createIndicatorList((IndicatorGroup) model), true);
} else {
store.add(activity, model, true);
}
}
}
tree.expandAll();
}
Aggregations