diff --git a/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml b/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml
index 2fa3bd3..5c5075d 100644
--- a/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml
+++ b/redaction-report-service-v1/redaction-report-service-api-v1/pom.xml
@@ -17,7 +17,7 @@
com.iqser.red.service
redaction-service-api-v1
- 1.3.0
+ 1.3.3
diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java
index afb91ef..2daba72 100644
--- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java
+++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ReportGenerationService.java
@@ -2,10 +2,9 @@ package com.iqser.red.service.redaction.report.v1.server.service;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.List;
+import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
@@ -16,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.iqser.red.service.redaction.report.v1.api.model.MultiFileRedactionLog;
import com.iqser.red.service.redaction.report.v1.server.utils.ResourceLoader;
+import com.iqser.red.service.redaction.v1.model.Rectangle;
import com.iqser.red.service.redaction.v1.model.Status;
@Service
@@ -35,7 +35,7 @@ public class ReportGenerationService {
try (ByteArrayInputStream is = new ByteArrayInputStream(template)) {
XWPFDocument doc = new XWPFDocument(is);
- doc = addTableRows(doc, multiFileRedactionLog);
+ addTableRows(doc, multiFileRedactionLog);
return toByteArray(doc);
} catch (IOException e) {
throw new RuntimeException(e);
@@ -43,36 +43,37 @@ public class ReportGenerationService {
}
- private XWPFDocument addTableRows(XWPFDocument doc, MultiFileRedactionLog multiFileRedactionLog) {
+ private void addTableRows(XWPFDocument doc, MultiFileRedactionLog multiFileRedactionLog) {
XWPFTable table = doc.getTables().get(1);
multiFileRedactionLog.getRedactionLogs().forEach(fileRedactionLog -> {
fileRedactionLog.getRedactionLogEntry().forEach(redactionLogEntry -> {
- if(redactionLogEntry.isRedacted()) {
- if(redactionLogEntry.isManual() && !redactionLogEntry.getStatus().equals(Status.APPROVED)){
+ if (redactionLogEntry.isRedacted()) {
+ if (redactionLogEntry.isManual() && !redactionLogEntry.getStatus().equals(Status.APPROVED)) {
return;
}
- Set pages = new HashSet<>();
- redactionLogEntry.getPositions().forEach(position -> {
- pages.add(position.getPage());
- });
+ List pages = redactionLogEntry.getPositions()
+ .stream()
+ .map(Rectangle::getPage)
+ .distinct()
+ .sorted()
+ .collect(Collectors.toList());
pages.forEach(page -> {
XWPFTableRow row = table.createRow();
row.getCell(0).setText(fileRedactionLog.getFilename());
row.getCell(1).setText(String.valueOf(page));
row.getCell(2).setText(redactionLogEntry.getSection());
- row.getCell(3).setText(redactionLogEntry.getReason());
+ row.getCell(3).setText(redactionLogEntry.getReason() + "; " + redactionLogEntry.getLegalBasis());
});
}
});
});
- return doc;
}
- private byte[] toByteArray(XWPFDocument doc) throws FileNotFoundException, IOException {
+ private byte[] toByteArray(XWPFDocument doc) throws IOException {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
doc.write(byteArrayOutputStream);
diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java
index 236b693..d80da64 100644
--- a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java
+++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/java/com/iqser/red/service/redaction/report/v1/server/RedactionReportIntegrationTest.java
@@ -1,6 +1,5 @@
package com.iqser.red.service.redaction.report.v1.server;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
import java.io.FileOutputStream;
@@ -47,7 +46,6 @@ public class RedactionReportIntegrationTest {
fileOutputStream.write(reportResult.getDocument());
}
- assertThat(true).isTrue();
}
}
\ No newline at end of file
diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/files/RedactionLogManual.txt b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/files/RedactionLogManual.txt
index c9a3654..f39b958 100644
--- a/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/files/RedactionLogManual.txt
+++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/test/resources/files/RedactionLogManual.txt
@@ -5,6 +5,7 @@
"type": "name",
"value": "Robinson N.",
"reason": "Not redacted because row is not a vertebrate study",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -33,6 +34,7 @@
"type": "address",
"value": "Syngenta Crop Protection AG, Basel, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -70,6 +72,7 @@
"type": "address",
"value": "RCC Ltd., Itingen, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -107,6 +110,7 @@
"type": "hint_only",
"value": "N",
"reason": null,
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -135,6 +139,7 @@
"type": "address",
"value": "Syngenta Crop Protection AG, Basel, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -172,6 +177,7 @@
"type": "name",
"value": "Wolf S.",
"reason": "Not redacted because row is not a vertebrate study",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -200,6 +206,7 @@
"type": "hint_only",
"value": "N",
"reason": null,
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -228,6 +235,7 @@
"type": "vertebrate",
"value": "rats",
"reason": null,
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": false,
"section": "Table in: ",
"color": [
@@ -256,6 +264,7 @@
"type": "name",
"value": "Casey, H.W.",
"reason": "Redacted because Section contains Vertebrate",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": true,
"section": "Table in: ",
"color": [
@@ -284,6 +293,7 @@
"type": "address",
"value": "Toxigenics, Inc., Decatur, IL 62526, USA",
"reason": "Redacted because Section contains Vertebrate",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": true,
"section": "Table in: ",
"color": [
@@ -321,6 +331,7 @@
"type": "name",
"value": "Salamon, C.M.",
"reason": "Redacted because Section contains Vertebrate",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": true,
"section": "Table in: ",
"color": [
@@ -358,6 +369,7 @@
"type": "name",
"value": "Smith, S.H.",
"reason": "Redacted because Section contains Vertebrate",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": true,
"section": "Table in: ",
"color": [
@@ -386,6 +398,7 @@
"type": "name",
"value": null,
"reason": "Manual Redaction",
+ "legalBasis": "Reg (EC) No 1107/2009 Art. 63 (2g)",
"redacted": true,
"section": null,
"color": [