DM-285: adjust reports to new component log

This commit is contained in:
Kilian Schuettler 2023-10-04 16:47:45 +02:00
parent c1868f5eb7
commit b78de6857e
4 changed files with 20 additions and 30 deletions

View File

@ -24,7 +24,7 @@
<properties>
<persistence-service.version>2.197.0</persistence-service.version>
<persistence-service.version>2.198.0</persistence-service.version>
<apache-poi.version>5.2.3</apache-poi.version>
</properties>

View File

@ -86,7 +86,7 @@
<dependency>
<groupId>com.iqser.red.service</groupId>
<artifactId>persistence-service-external-api-v2</artifactId>
<artifactId>persistence-service-internal-api-v1</artifactId>
<version>${persistence-service.version}</version>
</dependency>
<dependency>

View File

@ -2,9 +2,9 @@ package com.iqser.red.service.redaction.report.v1.server.client;
import org.springframework.cloud.openfeign.FeignClient;
import com.iqser.red.service.persistence.service.v2.api.external.resource.ComponentResource;
import com.iqser.red.service.persistence.service.v1.api.internal.resources.InternalComponentResource;
@FeignClient(name = "ComponentResource", url = "${persistence-service.url}")
public interface ComponentClient extends ComponentResource {
@FeignClient(name = "InternalComponentResource", url = "${persistence-service.url}")
public interface ComponentClient extends InternalComponentResource {
}

View File

@ -3,12 +3,13 @@ package com.iqser.red.service.redaction.report.v1.server.service;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileAttributeConfig;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileModel;
import com.iqser.red.service.persistence.service.v2.api.external.model.FileComponents;
import com.iqser.red.service.redaction.report.v1.server.client.ComponentClient;
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
import com.iqser.red.service.redaction.report.v1.server.model.ExcelModel;
@ -25,44 +26,33 @@ public class ComponentRowsReportService {
ComponentClient componentResource;
FileAttributesConfigClient fileAttributesClient;
static int FILENAME_COL = 0;
static int COMPONENT_NAME_COL = 1;
static int COMPONENT_VALUE_COL = 2;
static int COMPONENT_NAME_COL = 0;
static int COMPONENT_VALUE_STARTING_COL = 1;
public void addComponentRows(Sheet sheet, FileModel fileModel, ExcelModel excelModel) {
FileComponents fileComponents = componentResource.getComponents(fileModel.getDossierTemplateId(), fileModel.getDossierId(), fileModel.getId(), false);
ComponentLog componentLog = componentResource.getComponentLog(fileModel.getDossierId(), fileModel.getId(), true);
AtomicInteger rowIndex = new AtomicInteger(excelModel.getRedactionPlaceholderRow());
String oecd = getOecdNumber(fileModel);
int fileNameRow = rowIndex.getAndIncrement();
sheet.createRow(fileNameRow);
excelModel.getWrittenRows().add(fileNameRow);
Cell fileNameCell = sheet.getRow(fileNameRow).createCell(FILENAME_COL);
fileNameCell.setCellValue(fileComponents.getFilename() + "-" + oecd);
fileComponents.getComponents().forEach((componentName, values) -> {
componentLog.getComponentLogEntries().forEach(componentLogEntry -> {
if (values.isEmpty()) {
if (componentLogEntry.getComponentValues().isEmpty()) {
return;
}
int componentNameRow = rowIndex.getAndIncrement();
sheet.createRow(componentNameRow);
excelModel.getWrittenRows().add(componentNameRow);
int componentRowIdx = rowIndex.getAndIncrement();
Row componentRow = sheet.createRow(componentRowIdx);
excelModel.getWrittenRows().add(componentRowIdx);
Cell componentNameCell = sheet.getRow(componentNameRow).createCell(COMPONENT_NAME_COL);
componentNameCell.setCellValue(componentName.replaceAll("_", " "));
Cell componentNameCell = componentRow.createCell(COMPONENT_NAME_COL);
componentNameCell.setCellValue(oecd + "-" + componentLogEntry.getName().replaceAll("_", " "));
Cell valueCell = sheet.getRow(componentNameRow).createCell(COMPONENT_VALUE_COL);
valueCell.setCellValue(values.get(0));
for (String value : values.subList(1, values.size())) {
int additionalValueRow = rowIndex.getAndIncrement();
Cell additionalValueCell = sheet.createRow(additionalValueRow).createCell(COMPONENT_VALUE_COL);
excelModel.getWrittenRows().add(additionalValueRow);
additionalValueCell.setCellValue(value);
for (int valueIdx = 0; valueIdx < componentLogEntry.getComponentValues().size(); valueIdx++) {
String value = componentLogEntry.getComponentValues().get(valueIdx).getValue();
componentRow.createCell(COMPONENT_VALUE_STARTING_COL + valueIdx).setCellValue(value);
}
});