Search in sources :

Example 1 with RptChangesOnSystemState

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);
        }
    }
}
Also used : XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) RptChangesOnSystemState(eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemState) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Row(org.apache.poi.ss.usermodel.Row) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) Cell(org.apache.poi.ss.usermodel.Cell)

Aggregations

SysAttributeDifferenceDto (eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto)1 RptChangesOnSystemState (eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemState)1 Cell (org.apache.poi.ss.usermodel.Cell)1 Row (org.apache.poi.ss.usermodel.Row)1 XSSFFont (org.apache.poi.xssf.usermodel.XSSFFont)1 XSSFRichTextString (org.apache.poi.xssf.usermodel.XSSFRichTextString)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1