Search in sources :

Example 1 with SysValueChangeType

use of eu.bcvsolutions.idm.acc.domain.SysValueChangeType in project CzechIdMng by bcvsolutions.

the class ChangesOnSystemReportXlsxRenderer method renderMultiValueCell.

/**
 * Multi value cell renderer.
 */
private Cell renderMultiValueCell(Cell cell, SysAttributeDifferenceDto attribute) {
    XSSFRichTextString content = new XSSFRichTextString();
    // also defines the order of change types
    SysValueChangeType[] changeTypes = { SysValueChangeType.ADDED, SysValueChangeType.REMOVED, null };
    List<List<SysAttributeDifferenceValueDto>> valueList = Arrays.stream(changeTypes).map(type -> {
        return attribute.getValues().stream().filter(val -> type == val.getChange()).collect(Collectors.toList());
    }).collect(Collectors.toList());
    for (int i = 0; i < changeTypes.length; i++) {
        SysValueChangeType changeType = changeTypes[i];
        List<SysAttributeDifferenceValueDto> values = valueList.get(i);
        for (int j = 0; j < values.size(); ++j) {
            SysAttributeDifferenceValueDto value = values.get(j);
            content.append(Objects.toString(value.getValue()), getTextFont(cell, changeType));
            if (j >= values.size() - 1 && i >= changeTypes.length - 1) {
                continue;
            }
            content.append(NEW_LINE);
        }
    }
    cell.setCellValue(content);
    return cell;
}
Also used : Arrays(java.util.Arrays) FillPatternType(org.apache.poi.ss.usermodel.FillPatternType) SysAttributeDifferenceValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceValueDto) RptChangesOnSystemRecordDto(eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemRecordDto) HashMap(java.util.HashMap) SysAttributeDifferenceDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto) StringUtils(org.apache.commons.lang3.StringUtils) HSSFColor(org.apache.poi.hssf.util.HSSFColor) ArrayList(java.util.ArrayList) XSSFFont(org.apache.poi.xssf.usermodel.XSSFFont) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) CollectionUtils(org.apache.commons.collections.CollectionUtils) IndexedColors(org.apache.poi.ss.usermodel.IndexedColors) Map(java.util.Map) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) Cell(org.apache.poi.ss.usermodel.Cell) JsonToken(com.fasterxml.jackson.core.JsonToken) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Description(org.springframework.context.annotation.Description) Sheet(org.apache.poi.ss.usermodel.Sheet) JsonParser(com.fasterxml.jackson.core.JsonParser) ReportRenderException(eu.bcvsolutions.idm.rpt.api.exception.ReportRenderException) XSSFCellStyle(org.apache.poi.xssf.usermodel.XSSFCellStyle) Collectors(java.util.stream.Collectors) RptChangesOnSystemState(eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemState) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto) Objects(java.util.Objects) List(java.util.List) Component(org.springframework.stereotype.Component) AbstractXlsxRenderer(eu.bcvsolutions.idm.rpt.api.renderer.AbstractXlsxRenderer) XSSFSheet(org.apache.poi.xssf.usermodel.XSSFSheet) Row(org.apache.poi.ss.usermodel.Row) SysValueChangeType(eu.bcvsolutions.idm.acc.domain.SysValueChangeType) RendererRegistrar(eu.bcvsolutions.idm.rpt.api.renderer.RendererRegistrar) InputStream(java.io.InputStream) XSSFRichTextString(org.apache.poi.xssf.usermodel.XSSFRichTextString) SysValueChangeType(eu.bcvsolutions.idm.acc.domain.SysValueChangeType) ArrayList(java.util.ArrayList) List(java.util.List) SysAttributeDifferenceValueDto(eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceValueDto)

Aggregations

JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonToken (com.fasterxml.jackson.core.JsonToken)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 SysValueChangeType (eu.bcvsolutions.idm.acc.domain.SysValueChangeType)1 SysAttributeDifferenceDto (eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceDto)1 SysAttributeDifferenceValueDto (eu.bcvsolutions.idm.acc.dto.SysAttributeDifferenceValueDto)1 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)1 ReportRenderException (eu.bcvsolutions.idm.rpt.api.exception.ReportRenderException)1 AbstractXlsxRenderer (eu.bcvsolutions.idm.rpt.api.renderer.AbstractXlsxRenderer)1 RendererRegistrar (eu.bcvsolutions.idm.rpt.api.renderer.RendererRegistrar)1 RptChangesOnSystemRecordDto (eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemRecordDto)1 RptChangesOnSystemState (eu.bcvsolutions.idm.rpt.dto.RptChangesOnSystemState)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1