RED-4036: Wait for executor timeout
This commit is contained in:
parent
81febade14
commit
f46ee71e34
@ -319,7 +319,7 @@ public class ExcelTemplateReportGenerationService {
|
||||
if (dossierAttributesPlaceholders.containsKey(placeholder)) {
|
||||
return dossierAttributesPlaceholders.get(placeholder);
|
||||
}
|
||||
throw new RuntimeException("unknown placeholder");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,24 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.DOSSIER_NAME_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FILE_NAME_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_DATE_ENG_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_DATE_GER_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_DATE_ISO_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FORMAT_TIME_ISO_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.IUCLID_FUNCTION_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.DossierAttributeConfig;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierAttribute;
|
||||
@ -9,13 +28,8 @@ import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributes
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ImagePlaceholder;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderModel;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.*;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.DOSSIER_NAME_PLACEHOLDER;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@ -21,6 +21,7 @@ import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
import com.iqser.red.storage.commons.exception.StorageObjectDoesNotExist;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
@ -35,6 +36,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -54,6 +56,7 @@ public class ReportGenerationService {
|
||||
@Value("${redaction-report-service.numberOfReportGenerationThreads:4}")
|
||||
private int numberOfReportGenerationThreads;
|
||||
|
||||
@SneakyThrows
|
||||
public List<StoredFileInformation> generateReport(ReportRequestMessage reportMessage) {
|
||||
|
||||
List<StoredFileInformation> storedFileInformation = Collections.synchronizedList(new ArrayList<>());
|
||||
@ -131,6 +134,7 @@ public class ReportGenerationService {
|
||||
}
|
||||
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(1, TimeUnit.DAYS);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
log.info("Successfully processed {}/{} fileIds for downloadId {}, took {}", i, reportMessage.getFileIds()
|
||||
|
||||
@ -30,6 +30,7 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@SuppressWarnings("PMD")
|
||||
public class WordReportGenerationService {
|
||||
|
||||
|
||||
@ -58,7 +59,7 @@ public class WordReportGenerationService {
|
||||
log.warn("Table time: {}", (t2 - t1));
|
||||
|
||||
t1 = System.currentTimeMillis();
|
||||
replaceTextPlaceholders(doc, placeholderModel, dossier, fileStatus, table);
|
||||
replaceTextPlaceholders(doc, placeholderModel, dossier, fileStatus, table, reportEntries);
|
||||
|
||||
if (isLastFile) {
|
||||
removePlaceholdersRow(table);
|
||||
@ -83,6 +84,9 @@ public class WordReportGenerationService {
|
||||
}
|
||||
|
||||
private void removePlaceholdersRow(XWPFTable table) {
|
||||
if (table == null){
|
||||
return;
|
||||
}
|
||||
for (int j = 0; j < table.getRows().size(); j++) {
|
||||
for (int i = 0; i < table.getRows().get(j).getTableCells().size(); i++) {
|
||||
XWPFTableCell cell = table.getRows().get(j).getTableCells().get(i);
|
||||
@ -171,11 +175,11 @@ public class WordReportGenerationService {
|
||||
}
|
||||
|
||||
|
||||
public void replaceTextPlaceholders(XWPFDocument doc, PlaceholderModel placeholderModel, Dossier dossier, FileModel fileModel, XWPFTable tableToSkip) {
|
||||
public void replaceTextPlaceholders(XWPFDocument doc, PlaceholderModel placeholderModel, Dossier dossier, FileModel fileModel, XWPFTable tableToSkip, List<ReportRedactionEntry> reportRedactionEntries) {
|
||||
|
||||
Map<String, String> placeHolderValueMap = new HashMap<>();
|
||||
for (String placeholder : placeholderModel.getPlaceholders()) {
|
||||
String placeholderValue = getPlaceholderValue(placeholder, dossier, fileModel, placeholderModel.getFileAttributePlaceHolders(), placeholderModel.getDossierAttributesPlaceholder(), new ArrayList<>());
|
||||
String placeholderValue = getPlaceholderValue(placeholder, dossier, fileModel, placeholderModel.getFileAttributePlaceHolders(), placeholderModel.getDossierAttributesPlaceholder(), reportRedactionEntries);
|
||||
placeHolderValueMap.put(placeholder, placeholderValue);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user