use of org.activityinfo.legacy.shared.reports.content.FilterDescription in project activityinfo by bedatadriven.
the class ExcelChartRenderer method render.
@Override
public void render(Workbook book, PivotChartReportElement element) {
/* Generate the actual pivot table data */
element.getContent().getData();
/* Generate the excel sheet */
new BaseExcelRenderer<PivotChartReportElement>(book, element) {
@Override
public List<FilterDescription> generateFilterDescriptions() {
return element.getContent().getFilterDescriptions();
}
@Override
public void generate() {
PivotTableData data = this.element.getContent().getData();
List<PivotTableData.Axis> rows = data.getRootRow().getLeaves();
List<PivotTableData.Axis> cols = data.getRootColumn().getLeaves();
Row headerRow = sheet.createRow(rowIndex++);
for (int i = 0; i != cols.size(); ++i) {
Cell colHeaderCell = headerRow.createCell(i + 1);
colHeaderCell.setCellValue(factory.createRichTextString(cols.get(i).flattenLabel()));
}
for (int i = 0; i != rows.size(); ++i) {
Row row = sheet.createRow(rowIndex++);
// header
Cell rowHeaderCell = row.createCell(0);
rowHeaderCell.setCellValue(factory.createRichTextString(rows.get(i).flattenLabel()));
// values
for (int j = 0; j != cols.size(); ++j) {
Cell valueCell = row.createCell(j + 1);
valueCell.setCellValue(rows.get(i).getCell(cols.get(j)).getValue());
}
}
}
};
}
use of org.activityinfo.legacy.shared.reports.content.FilterDescription in project activityinfo by bedatadriven.
the class BaseGenerator method generateFilterDescriptions.
protected List<FilterDescription> generateFilterDescriptions(Filter filter, Set<DimensionType> excludeDims, User user) {
List<FilterDescription> list = new ArrayList<FilterDescription>();
Set<DimensionType> filterDims = filter.getRestrictedDimensions();
filterDims.removeAll(excludeDims);
for (DimensionType type : filterDims) {
DimensionLabels labels = dispatcher.execute(new GetDimensionLabels(type, filter.getRestrictions(type)));
list.add(new FilterDescription(type, labels.getLabels()));
}
return list;
}
use of org.activityinfo.legacy.shared.reports.content.FilterDescription in project activityinfo by bedatadriven.
the class StaticElementRenderTest method setup.
@Before
public void setup() throws JAXBException {
report = Reports.parseXml(getClass(), "static.xml");
report.setContent(new ReportContent());
report.getContent().setFilterDescriptions(new ArrayList<FilterDescription>());
}
use of org.activityinfo.legacy.shared.reports.content.FilterDescription in project activityinfo by bedatadriven.
the class ExcelTableRenderer method render.
@Override
public void render(Workbook book, TableElement element) {
final TableData tableData = element.getContent().getData();
new BaseExcelTableRenderer<TableElement, TableColumn>(book, element) {
@Override
public List<FilterDescription> generateFilterDescriptions() {
return element.getContent().getFilterDescriptions();
}
@Override
public void generate() {
/* Generate the column headers for the table */
initColHeaderStyles(element.getRootColumn());
generateColumnHeaders(0, element.getRootColumn());
int headerHeight = rowIndex;
sheet.createFreezePane(element.getFrozenColumns(), headerHeight);
/* Prepare the generators and indexes */
List<TableColumn> leaves = element.getRootColumn().getLeaves();
String[] colIndexes = new String[leaves.size()];
for (int i = 0; i != leaves.size(); ++i) {
colIndexes[i] = leaves.get(i).getSitePropertyName();
}
for (SiteDTO rowData : tableData.getRows()) {
Row row = sheet.createRow(rowIndex++);
for (int i = 0; i != colIndexes.length; ++i) {
Object value = null;
if (colIndexes[i] != null) {
value = rowData.get(colIndexes[i]);
}
Cell cell = row.createCell(i);
if (value instanceof Number) {
cell.setCellValue(((Number) value).doubleValue());
} else if (value instanceof Date) {
cell.setCellValue((Date) value);
} else if (value instanceof Boolean) {
cell.setCellValue((Boolean) value);
} else if (value != null) {
cell.setCellValue(factory.createRichTextString(value.toString()));
}
}
}
}
};
}
use of org.activityinfo.legacy.shared.reports.content.FilterDescription in project activityinfo by bedatadriven.
the class ExcelPivotTableRenderer method render.
@Override
public void render(Workbook book, PivotTableReportElement element) {
/* Generate the actual pivot table data */
final PivotTableData table = element.getContent().getData();
/* Generate the excel sheet */
new BaseExcelTableRenderer<PivotTableReportElement, PivotTableData.Axis>(book, element) {
@Override
public List<FilterDescription> generateFilterDescriptions() {
return element.getContent().getFilterDescriptions();
}
private CellStyle[] rowHeaderStyles;
@Override
public void generate() {
/* Initialize Cell Styles */
initColHeaderStyles(table.getRootColumn());
initRowHeaderStyles();
/* Generate the column headers */
generateColumnHeaders(1, table.getRootColumn());
int headerHeight = rowIndex;
/* Create the rows */
// row headers are in column 1
sheet.setColumnWidth(0, 40 * 256);
generateRows(table.getRootRow().getChildList(), 0);
/* Finalize the sheet */
sheet.setRowSumsBelow(false);
sheet.createFreezePane(1, headerHeight);
}
protected void initRowHeaderStyles() {
int depth = table.getRootRow().getDepth();
rowHeaderStyles = new CellStyle[depth];
for (int i = 0; i != depth; ++i) {
CellStyle style = book.createCellStyle();
style.setIndention((short) i);
style.setWrapText(true);
Font font = createBaseFont();
if (i + 1 != depth) {
/* Has sub headers */
font.setBoldweight(Font.BOLDWEIGHT_BOLD);
} else {
font.setBoldweight(Font.BOLDWEIGHT_NORMAL);
}
style.setFont(font);
rowHeaderStyles[i] = style;
}
}
protected void generateRows(List<PivotTableData.Axis> rows, int indent) {
for (PivotTableData.Axis pivotRow : rows) {
Row row = sheet.createRow(rowIndex++);
Cell headerCell = row.createCell(0);
headerCell.setCellValue(factory.createRichTextString(pivotRow.getLabel()));
headerCell.setCellStyle(rowHeaderStyles[indent]);
if (pivotRow.isLeaf()) {
for (Entry<PivotTableData.Axis, Integer> entry : colIndexMap.entrySet()) {
PivotTableData.Cell pivotCell = pivotRow.getCell(entry.getKey());
if (pivotCell != null) {
Cell cell = row.createCell(entry.getValue());
cell.setCellValue(pivotCell.getValue());
}
}
} else {
int groupStart = rowIndex;
generateRows(pivotRow.getChildList(), indent + 1);
int groupEnd = rowIndex;
sheet.groupRow(groupStart, groupEnd);
}
}
}
};
}
Aggregations