RED-5062: Sonar issues
This commit is contained in:
parent
616315d9e4
commit
ef0528aa8c
@ -43,8 +43,8 @@ public class PlanSpec {
|
||||
/**
|
||||
* Run main to publish plan on Bamboo
|
||||
*/
|
||||
public static void main(final String[] args) throws Exception {
|
||||
//By default credentials are read from the '.credentials' file.
|
||||
public static void main(final String[] args) {
|
||||
//By default, credentials are read from the '.credentials' file.
|
||||
BambooServer bambooServer = new BambooServer("http://localhost:8085");
|
||||
|
||||
Plan plan = new PlanSpec().createPlan();
|
||||
|
||||
@ -3,8 +3,6 @@ package com.iqser.red.service.redaction.report.v1.server.model;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ReportRedactionEntry {
|
||||
|
||||
@ -1,28 +1,72 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.*;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE;
|
||||
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.EXCERPT_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FILE_ATTRIBUTE_PLACEHOLDER_BASE;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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.JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_PARAGRAPH_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_REASON_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_TEXT_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PAGE_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_VALUE_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 javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.*;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellStyle;
|
||||
import org.apache.poi.ss.usermodel.ClientAnchor;
|
||||
import org.apache.poi.ss.usermodel.CreationHelper;
|
||||
import org.apache.poi.ss.usermodel.Drawing;
|
||||
import org.apache.poi.ss.usermodel.Picture;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.CellIdentifier;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ExcelModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ImagePlaceholder;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderInput;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
import com.iqser.red.service.redaction.report.v1.server.utils.PixelUtil;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -167,21 +211,7 @@ public class ExcelReportGenerationService {
|
||||
|
||||
private boolean containsRedactionPlaceholder(String text) {
|
||||
|
||||
return text.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE) ||
|
||||
text.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE) ||
|
||||
text.contains(FILE_NAME_PLACEHOLDER) ||
|
||||
text.contains(PAGE_PLACEHOLDER) ||
|
||||
text.contains(PARAGRAPH_PLACEHOLDER) ||
|
||||
text.contains(JUSTIFICATION_PLACEHOLDER) ||
|
||||
text.contains(EXCERPT_PLACEHOLDER) ||
|
||||
text.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) ||
|
||||
text.contains(JUSTIFICATION_REASON_PLACEHOLDER) ||
|
||||
text.contains(REDACTION_VALUE_PLACEHOLDER) ||
|
||||
text.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) ||
|
||||
text.contains(JUSTIFICATION_TEXT_PLACEHOLDER) ||
|
||||
text.contains(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) ||
|
||||
text.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER) ||
|
||||
text.contains(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
return text.startsWith(DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE) || text.startsWith(FILE_ATTRIBUTE_PLACEHOLDER_BASE) || text.contains(FILE_NAME_PLACEHOLDER) || text.contains(PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || text.contains(JUSTIFICATION_REASON_PLACEHOLDER) || text.contains(REDACTION_VALUE_PLACEHOLDER) || text.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || text.contains(JUSTIFICATION_TEXT_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER) || text.contains(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER) || text.contains(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
}
|
||||
|
||||
|
||||
@ -285,8 +315,8 @@ public class ExcelReportGenerationService {
|
||||
double imageWidth = img.getWidth();
|
||||
double imageHeight = img.getHeight();
|
||||
|
||||
double widthFactor = (double) cellWidth / imageWidth;
|
||||
double heightFactor = (double) cellHeight / imageHeight;
|
||||
double widthFactor = cellWidth / imageWidth;
|
||||
double heightFactor = cellHeight / imageHeight;
|
||||
|
||||
if (imageWidth < cellWidth && imageHeight < cellHeight) {
|
||||
return 1;
|
||||
|
||||
@ -20,7 +20,7 @@ public class IuclidFunctionService {
|
||||
public String computeIuclidFunction(List<ReportRedactionEntry> reportRedactionEntries, String filename) {
|
||||
|
||||
Map<String, List<ReportRedactionEntry>> entriesPerJustification = new HashMap<>();
|
||||
reportRedactionEntries.forEach(reportRedactionEntry -> entriesPerJustification.computeIfAbsent(reportRedactionEntry.getJustification(), (x) -> new ArrayList<>())
|
||||
reportRedactionEntries.forEach(reportRedactionEntry -> entriesPerJustification.computeIfAbsent(reportRedactionEntry.getJustification(), x -> new ArrayList<>())
|
||||
.add(reportRedactionEntry));
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
|
||||
@ -1,32 +1,76 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
|
||||
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.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.*;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.util.Dimension2DDouble;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.DOSSIER_ATTRIBUTE_PLACEHOLDER_BASE;
|
||||
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.EXCERPT_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.FILE_ATTRIBUTE_PLACEHOLDER_BASE;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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.JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_PARAGRAPH_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_REASON_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.JUSTIFICATION_TEXT_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PAGE_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.PARAGRAPH_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER;
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.REDACTION_VALUE_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 javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.function.Function;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.service.PlaceholderService.*;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||
import org.apache.poi.util.Dimension2DDouble;
|
||||
import org.apache.poi.util.Units;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFRun;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTable;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableCell;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ColoredText;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ImagePlaceholder;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceHolderFunctions;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderInput;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.PlaceholderModel;
|
||||
import com.iqser.red.service.redaction.report.v1.server.model.ReportRedactionEntry;
|
||||
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -278,7 +322,7 @@ public class WordReportGenerationService {
|
||||
if (containsRedactionPlaceholder(cell.getText())) {
|
||||
placeholderCellPos.put(i, getFunctionForPlaceHolder(cell.getText(), foundPlaceHolder, placeholderModel));
|
||||
} else if (cell.getText().isEmpty()) {
|
||||
placeholderCellPos.put(i, (input) -> "");
|
||||
placeholderCellPos.put(i, input -> "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,65 +368,65 @@ public class WordReportGenerationService {
|
||||
}
|
||||
if (placeholder.equals(PAGE_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(PAGE_PLACEHOLDER);
|
||||
return (input) -> String.valueOf(input.getEntry().getPage());
|
||||
return input -> String.valueOf(input.getEntry().getPage());
|
||||
}
|
||||
if (placeholder.equals(PARAGRAPH_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(PARAGRAPH_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getSection();
|
||||
return input -> input.getEntry().getSection();
|
||||
}
|
||||
if (placeholder.equals(JUSTIFICATION_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(JUSTIFICATION_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getJustification();
|
||||
return input -> input.getEntry().getJustification();
|
||||
}
|
||||
if (placeholder.equals(JUSTIFICATION_PARAGRAPH_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(JUSTIFICATION_PARAGRAPH_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getJustificationParagraph();
|
||||
return input -> input.getEntry().getJustificationParagraph();
|
||||
}
|
||||
if (placeholder.equals(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(JUSTIFICATION_REASON_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getJustificationReason();
|
||||
return input -> input.getEntry().getJustificationReason();
|
||||
}
|
||||
if (placeholder.equals(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getJustificationParagraph();
|
||||
return input -> input.getEntry().getJustificationParagraph();
|
||||
}
|
||||
if (placeholder.equals(JUSTIFICATION_TEXT_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(JUSTIFICATION_TEXT_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getJustificationReason();
|
||||
return input -> input.getEntry().getJustificationReason();
|
||||
}
|
||||
if (placeholder.equals(EXCERPT_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(EXCERPT_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getExcerpt();
|
||||
return input -> input.getEntry().getExcerpt();
|
||||
}
|
||||
if (placeholder.equals(REDACTION_VALUE_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(REDACTION_VALUE_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getValue() != null ? input.getEntry().getValue().replaceAll("\n", " ").replaceAll(" ", " ") : "";
|
||||
return input -> input.getEntry().getValue() != null ? input.getEntry().getValue().replaceAll("\n", " ").replaceAll(" ", " ") : "";
|
||||
}
|
||||
if (placeholder.equals(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(REDACTION_ENTITY_DISPLAY_NAME_PLACEHOLDER);
|
||||
return (input) -> input.getEntry().getEntityDisplayName();
|
||||
return input -> input.getEntry().getEntityDisplayName();
|
||||
}
|
||||
|
||||
if (placeholder.equals(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER)) {
|
||||
foundPlaceholders.add(SEEDS_FUNCTION_REDACTION_GROUPED_BY_JUSTIFICATION_PAGES_PLACEHOLDER);
|
||||
return (input) -> computePageRanges(input.getRedactionsPerJustificationEntry().getValue().stream().map(ReportRedactionEntry::getPage).collect(Collectors.toSet()));
|
||||
return input -> computePageRanges(input.getRedactionsPerJustificationEntry().getValue().stream().map(ReportRedactionEntry::getPage).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
if (placeholder.equals(SEEDS_FUNCTION_JUSTIFICATION_PLACEHOLDER)) {
|
||||
return (input) -> input.getRedactionsPerJustificationEntry().getKey();
|
||||
return input -> input.getRedactionsPerJustificationEntry().getKey();
|
||||
}
|
||||
|
||||
if (placeholderModel.getFileAttributeValueByPlaceholder().containsKey(placeholder)) {
|
||||
foundPlaceholders.add(placeholder);
|
||||
return (input) -> input.getPlaceholderModel().getFileAttributeValueByPlaceholder().get(placeholder);
|
||||
return input -> input.getPlaceholderModel().getFileAttributeValueByPlaceholder().get(placeholder);
|
||||
}
|
||||
|
||||
if (placeholderModel.getDossierAttributesValueByPlaceholder().containsKey(placeholder)) {
|
||||
foundPlaceholders.add(placeholder);
|
||||
return (input) -> input.getPlaceholderModel().getDossierAttributesValueByPlaceholder().get(placeholder);
|
||||
return input -> input.getPlaceholderModel().getDossierAttributesValueByPlaceholder().get(placeholder);
|
||||
}
|
||||
|
||||
return (input) -> "";
|
||||
return input -> "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.storage;
|
||||
|
||||
public class StorageIdUtils {
|
||||
public final class StorageIdUtils {
|
||||
|
||||
public static String getStorageId(String downloadId, String tmpFilename) {
|
||||
|
||||
return downloadId.substring(0, downloadId.length() - 3) + "/" + tmpFilename;
|
||||
}
|
||||
|
||||
|
||||
private StorageIdUtils() {
|
||||
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,29 +1,42 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server.service;
|
||||
package com.iqser.red.service.redaction.report.v1.server.utils;
|
||||
|
||||
public class PixelUtil {
|
||||
public final class PixelUtil {
|
||||
|
||||
public static final short EXCEL_COLUMN_WIDTH_FACTOR = 256;
|
||||
public static final short EXCEL_ROW_HEIGHT_FACTOR = 20;
|
||||
public static final int UNIT_OFFSET_LENGTH = 7;
|
||||
public static final int[] UNIT_OFFSET_MAP = new int[] { 0, 36, 73, 109, 146, 182, 219 };
|
||||
public static final int[] UNIT_OFFSET_MAP = new int[]{0, 36, 73, 109, 146, 182, 219};
|
||||
|
||||
|
||||
public static short pixel2WidthUnits(int pxs) {
|
||||
|
||||
short widthUnits = (short) (EXCEL_COLUMN_WIDTH_FACTOR * (pxs / UNIT_OFFSET_LENGTH));
|
||||
widthUnits += UNIT_OFFSET_MAP[pxs % UNIT_OFFSET_LENGTH];
|
||||
return widthUnits;
|
||||
}
|
||||
|
||||
|
||||
public static int widthUnits2Pixel(short widthUnits) {
|
||||
|
||||
int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR) * UNIT_OFFSET_LENGTH;
|
||||
int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR;
|
||||
pixels += Math.floor((float) offsetWidthUnits / ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));
|
||||
pixels += Math.floor(offsetWidthUnits / ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH));
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
public static int heightUnits2Pixel(short heightUnits) {
|
||||
|
||||
int pixels = heightUnits / EXCEL_ROW_HEIGHT_FACTOR;
|
||||
int offsetWidthUnits = heightUnits % EXCEL_ROW_HEIGHT_FACTOR;
|
||||
pixels += Math.floor((float) offsetWidthUnits / ((float) EXCEL_ROW_HEIGHT_FACTOR / UNIT_OFFSET_LENGTH));
|
||||
pixels += Math.floor(offsetWidthUnits / ((float) EXCEL_ROW_HEIGHT_FACTOR / UNIT_OFFSET_LENGTH));
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
private PixelUtil() {
|
||||
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,7 +21,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogLegalBasis;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
@ -40,7 +39,6 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.file.FileModel;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.legalbasis.LegalBasis;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.Type;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
|
||||
@ -57,6 +55,7 @@ import com.iqser.red.service.redaction.report.v1.server.service.RedactionLogConv
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.WordReportGenerationService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.ReportStorageService;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogLegalBasis;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
@ -1,5 +1,31 @@
|
||||
package com.iqser.red.service.redaction.report.v1.server;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.utils.OsUtils.getTemporaryDirectory;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@ -13,36 +39,22 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.do
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileModel;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.StoredFileInformation;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.*;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DictionaryClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.DossierClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileAttributesConfigClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.FileStatusClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.RedactionLogClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.client.ReportTemplateClient;
|
||||
import com.iqser.red.service.redaction.report.v1.server.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.redaction.report.v1.server.service.ReportGenerationService;
|
||||
import com.iqser.red.service.redaction.report.v1.server.storage.StorageIdUtils;
|
||||
import com.iqser.red.service.redaction.report.v1.server.utils.FileSystemBackedStorageService;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.storage.commons.StorageAutoConfiguration;
|
||||
import com.iqser.red.storage.commons.service.StorageService;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.iqser.red.service.redaction.report.v1.server.utils.OsUtils.getTemporaryDirectory;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@Import(RedactionReportV2IntegrationTest.TestConfiguration.class)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user