use of eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemState in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportXlsxRenderer method renderRecord.
/**
* Methods renders single record
*/
private void renderRecord(int lineIdx, Sheet sheet, RptChangesOnSystemRecordDto record, Map<String, Integer> attributeOrder) {
if (record == null) {
LOG.warn("Trying to render null record!");
return;
}
Row row = sheet.createRow(lineIdx);
row.setHeight((short) -1);
int cellIdx;
// render status
XSSFRichTextString content = new XSSFRichTextString();
RptChangesOnSystemState state = record.getState();
cellIdx = attributeOrder.get(STATUS_COLUMN_NAME);
Cell cell = row.createCell(cellIdx);
content.append(state.toString());
cell.setCellValue(content);
cell.setCellStyle(getStatusCellStyle(sheet, state));
// render record key/identifier
XSSFFont boldFont = ((XSSFWorkbook) sheet.getWorkbook()).createFont();
boldFont.setBold(true);
String key = record.getIdentifier();
content = new XSSFRichTextString();
cellIdx = attributeOrder.get(KEY_COLUMN_NAME);
cell = row.createCell(cellIdx);
content.append(Objects.toString(key, ""), boldFont);
cell.setCellValue(content);
if (state == RptChangesOnSystemState.FAILED) {
cellIdx++;
cell = row.createCell(cellIdx);
content = new XSSFRichTextString();
XSSFFont font = getTextFont(cell, SysValueChangeType.REMOVED);
content.append(Objects.toString(record.getError(), ""), font);
cell.setCellValue(content);
return;
}
List<SysAttributeDifferenceDto> differences = record.getAttributeDifferences();
if (CollectionUtils.isEmpty(differences)) {
return;
}
for (SysAttributeDifferenceDto diff : differences) {
Integer colIdx = attributeOrder.get(diff.getName());
if (colIdx == null) {
continue;
}
cell = row.createCell(colIdx);
if (diff.isMultivalue()) {
renderMultiValueCell(cell, diff);
} else {
renderSingleValueCell(cell, diff, state);
}
}
}
Aggregations