RED-2523: Rename justification placeholders
This commit is contained in:
parent
cff8f1a2a5
commit
fdeef449bd
@ -11,9 +11,11 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold
|
|||||||
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_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;
|
||||||
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.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_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_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_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.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.PARAGRAPH_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.REDACTION_VALUE_PLACEHOLDER;
|
||||||
@ -213,7 +215,7 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
|
|
||||||
private boolean containsRedactionPlaceholder(String text) {
|
private boolean containsRedactionPlaceholder(String text) {
|
||||||
|
|
||||||
return 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);
|
return 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -237,6 +239,12 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
if (placeholder.equals(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
if (placeholder.equals(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
||||||
return entry.getJustificationReason();
|
return entry.getJustificationReason();
|
||||||
}
|
}
|
||||||
|
if (placeholder.equals(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER)) {
|
||||||
|
return entry.getJustificationParagraph();
|
||||||
|
}
|
||||||
|
if (placeholder.equals(JUSTIFICATION_TEXT_PLACEHOLDER)) {
|
||||||
|
return entry.getJustificationReason();
|
||||||
|
}
|
||||||
if (placeholder.equals(EXCERPT_PLACEHOLDER)) {
|
if (placeholder.equals(EXCERPT_PLACEHOLDER)) {
|
||||||
return entry.getExcerpt();
|
return entry.getExcerpt();
|
||||||
}
|
}
|
||||||
@ -273,7 +281,8 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
// ByteArrayInputStream scaledImage = getScaledImage(is, PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())), PixelUtil.heightUnits2Pixel(cell.getRow().getHeight()));
|
// ByteArrayInputStream scaledImage = getScaledImage(is, PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())), PixelUtil.heightUnits2Pixel(cell.getRow().getHeight()));
|
||||||
// is.reset();
|
// is.reset();
|
||||||
|
|
||||||
double factor = calculateScale(is, PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())), PixelUtil.heightUnits2Pixel(cell.getRow().getHeight()));
|
double factor = calculateScale(is, PixelUtil.widthUnits2Pixel((short) sheet.getColumnWidth(cell.getColumnIndex())), PixelUtil.heightUnits2Pixel(cell.getRow()
|
||||||
|
.getHeight()));
|
||||||
is.reset();
|
is.reset();
|
||||||
|
|
||||||
int pictureIdx = workbook.addPicture(is, XSSFWorkbook.PICTURE_TYPE_JPEG);
|
int pictureIdx = workbook.addPicture(is, XSSFWorkbook.PICTURE_TYPE_JPEG);
|
||||||
@ -302,16 +311,18 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private double calculateScale(ByteArrayInputStream imageByteArrayInputStream, float cellWidth, float cellHeight) throws IOException {
|
private double calculateScale(ByteArrayInputStream imageByteArrayInputStream, float cellWidth,
|
||||||
|
float cellHeight) throws IOException {
|
||||||
|
|
||||||
BufferedImage img = ImageIO.read(imageByteArrayInputStream);
|
BufferedImage img = ImageIO.read(imageByteArrayInputStream);
|
||||||
|
|
||||||
double imageWidth = img.getWidth();
|
double imageWidth = img.getWidth();
|
||||||
double imageHeight = img.getHeight();
|
double imageHeight = img.getHeight();
|
||||||
|
|
||||||
double widthFactor = (double) cellWidth/ imageWidth;
|
double widthFactor = (double) cellWidth / imageWidth;
|
||||||
double heightFactor = (double) cellHeight/ imageHeight;
|
double heightFactor = (double) cellHeight / imageHeight;
|
||||||
|
|
||||||
if (imageWidth < cellWidth && imageHeight < cellHeight) {
|
if (imageWidth < cellWidth && imageHeight < cellHeight) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (cellWidth > cellHeight) {
|
} else if (cellWidth > cellHeight) {
|
||||||
return heightFactor;
|
return heightFactor;
|
||||||
@ -347,7 +358,6 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
if (fileAttributePlaceholders.containsKey(placeholder)) {
|
if (fileAttributePlaceholders.containsKey(placeholder)) {
|
||||||
String id = fileAttributePlaceholders.get(placeholder);
|
String id = fileAttributePlaceholders.get(placeholder);
|
||||||
|
|
||||||
|
|
||||||
if (fileStatus.getFileAttributes().containsKey(id)) {
|
if (fileStatus.getFileAttributes().containsKey(id)) {
|
||||||
return fileStatus.getFileAttributes().get(id);
|
return fileStatus.getFileAttributes().get(id);
|
||||||
} else {
|
} else {
|
||||||
@ -360,6 +370,7 @@ public class ExcelTemplateReportGenerationService {
|
|||||||
throw new RuntimeException("unknown placeholder");
|
throw new RuntimeException("unknown placeholder");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public byte[] toByteArray(XSSFWorkbook workbook) {
|
public byte[] toByteArray(XSSFWorkbook workbook) {
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,9 @@ public class PlaceholderService {
|
|||||||
public static final String PARAGRAPH_PLACEHOLDER = "{{redaction.paragraph}}";
|
public static final String PARAGRAPH_PLACEHOLDER = "{{redaction.paragraph}}";
|
||||||
public static final String JUSTIFICATION_PLACEHOLDER = "{{redaction.justification}}";
|
public static final String JUSTIFICATION_PLACEHOLDER = "{{redaction.justification}}";
|
||||||
public static final String JUSTIFICATION_PARAGRAPH_PLACEHOLDER = "{{redaction.justificationParagraph}}";
|
public static final String JUSTIFICATION_PARAGRAPH_PLACEHOLDER = "{{redaction.justificationParagraph}}";
|
||||||
|
public static final String JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER = "{{redaction.justificationLegalBasis}}";
|
||||||
public static final String JUSTIFICATION_REASON_PLACEHOLDER = "{{redaction.justificationReason}}";
|
public static final String JUSTIFICATION_REASON_PLACEHOLDER = "{{redaction.justificationReason}}";
|
||||||
|
public static final String JUSTIFICATION_TEXT_PLACEHOLDER = "{{redaction.justificationText}}";
|
||||||
public static final String EXCERPT_PLACEHOLDER = "{{redaction.excerpt}}";
|
public static final String EXCERPT_PLACEHOLDER = "{{redaction.excerpt}}";
|
||||||
public static final String REDACTION_VALUE_PLACEHOLDER = "{{redaction.value}}";
|
public static final String REDACTION_VALUE_PLACEHOLDER = "{{redaction.value}}";
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ public class PlaceholderService {
|
|||||||
|
|
||||||
public List<String> getGeneralPlaceholders() {
|
public List<String> getGeneralPlaceholders() {
|
||||||
|
|
||||||
return List.of(FILE_NAME_PLACEHOLDER, PAGE_PLACEHOLDER, PARAGRAPH_PLACEHOLDER, JUSTIFICATION_PLACEHOLDER, JUSTIFICATION_PARAGRAPH_PLACEHOLDER, JUSTIFICATION_REASON_PLACEHOLDER, EXCERPT_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, REDACTION_VALUE_PLACEHOLDER);
|
return List.of(FILE_NAME_PLACEHOLDER, PAGE_PLACEHOLDER, PARAGRAPH_PLACEHOLDER, JUSTIFICATION_PLACEHOLDER, EXCERPT_PLACEHOLDER, FORMAT_DATE_ISO_PLACEHOLDER, FORMAT_DATE_GER_PLACEHOLDER, FORMAT_DATE_ENG_PLACEHOLDER, FORMAT_TIME_ISO_PLACEHOLDER, DOSSIER_NAME_PLACEHOLDER, IUCLID_FUNCTION_PLACEHOLDER, REDACTION_VALUE_PLACEHOLDER, JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER, JUSTIFICATION_TEXT_PLACEHOLDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,9 +12,11 @@ import static com.iqser.red.service.redaction.report.v1.server.service.Placehold
|
|||||||
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;
|
||||||
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.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.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_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_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_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.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.PARAGRAPH_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.REDACTION_VALUE_PLACEHOLDER;
|
||||||
@ -111,7 +113,7 @@ public class WordReportGenerationService {
|
|||||||
if (dossierAttribute.getValue() == null) {
|
if (dossierAttribute.getValue() == null) {
|
||||||
dossierAttributesPlaceholder.put(attributeConfig.getPlaceholder(), "");
|
dossierAttributesPlaceholder.put(attributeConfig.getPlaceholder(), "");
|
||||||
} else {
|
} else {
|
||||||
if(attributeConfig.getType().equals(DossierAttributeType.DATE)) {
|
if (attributeConfig.getType().equals(DossierAttributeType.DATE)) {
|
||||||
OffsetDateTime dt = OffsetDateTime.parse(dossierAttribute.getValue());
|
OffsetDateTime dt = OffsetDateTime.parse(dossierAttribute.getValue());
|
||||||
String date = FORMAT_DATE_ISO.format(dt);
|
String date = FORMAT_DATE_ISO.format(dt);
|
||||||
dossierAttributesPlaceholder.put(attributeConfig.getPlaceholder(), date);
|
dossierAttributesPlaceholder.put(attributeConfig.getPlaceholder(), date);
|
||||||
@ -243,8 +245,7 @@ public class WordReportGenerationService {
|
|||||||
run.setText("", 0);
|
run.setText("", 0);
|
||||||
run.addBreak();
|
run.addBreak();
|
||||||
Dimension2DDouble dim = getImageDimension(is2);
|
Dimension2DDouble dim = getImageDimension(is2);
|
||||||
run.addPicture(is2, XWPFDocument.PICTURE_TYPE_JPEG, "image.jpg", Units.toEMU(dim.getWidth()), Units.toEMU(dim
|
run.addPicture(is2, XWPFDocument.PICTURE_TYPE_JPEG, "image.jpg", Units.toEMU(dim.getWidth()), Units.toEMU(dim.getHeight()));
|
||||||
.getHeight()));
|
|
||||||
int size = p.getRuns().size();
|
int size = p.getRuns().size();
|
||||||
for (int i = 1; i < size; i++) {
|
for (int i = 1; i < size; i++) {
|
||||||
p.removeRun(1);
|
p.removeRun(1);
|
||||||
@ -315,8 +316,7 @@ public class WordReportGenerationService {
|
|||||||
|
|
||||||
for (XWPFTable tbl : doc.getTables()) {
|
for (XWPFTable tbl : doc.getTables()) {
|
||||||
String tblText = tbl.getText();
|
String tblText = tbl.getText();
|
||||||
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText
|
if (tblText.contains(PAGE_PLACEHOLDER) || tblText.contains(PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PLACEHOLDER) || tblText.contains(EXCERPT_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_REASON_PLACEHOLDER) || tblText.contains(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER) || tblText.contains(JUSTIFICATION_TEXT_PLACEHOLDER)) {
|
||||||
.contains(EXCERPT_PLACEHOLDER) || tblText.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || tblText.contains(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
|
||||||
return tbl;
|
return tbl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -326,9 +326,7 @@ public class WordReportGenerationService {
|
|||||||
|
|
||||||
private boolean containsRedactionPlaceholder(String text) {
|
private boolean containsRedactionPlaceholder(String text) {
|
||||||
|
|
||||||
return text.contains(FILE_NAME_PLACEHOLDER) || text.contains(PAGE_PLACEHOLDER) || text.contains(PARAGRAPH_PLACEHOLDER) || text
|
return 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);
|
||||||
.contains(JUSTIFICATION_PLACEHOLDER) || text.contains(EXCERPT_PLACEHOLDER) || text.contains(JUSTIFICATION_PARAGRAPH_PLACEHOLDER) || text
|
|
||||||
.contains(JUSTIFICATION_REASON_PLACEHOLDER) || text.contains(REDACTION_VALUE_PLACEHOLDER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -388,6 +386,12 @@ public class WordReportGenerationService {
|
|||||||
if (placeholder.equals(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
if (placeholder.equals(JUSTIFICATION_REASON_PLACEHOLDER)) {
|
||||||
return entry.getJustificationReason();
|
return entry.getJustificationReason();
|
||||||
}
|
}
|
||||||
|
if (placeholder.equals(JUSTIFICATION_LEGAL_BASIS_PLACEHOLDER)) {
|
||||||
|
return entry.getJustificationParagraph();
|
||||||
|
}
|
||||||
|
if (placeholder.equals(JUSTIFICATION_TEXT_PLACEHOLDER)) {
|
||||||
|
return entry.getJustificationReason();
|
||||||
|
}
|
||||||
if (placeholder.equals(EXCERPT_PLACEHOLDER)) {
|
if (placeholder.equals(EXCERPT_PLACEHOLDER)) {
|
||||||
return entry.getExcerpt();
|
return entry.getExcerpt();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user