Pull request #6: Only add manual redactions, if they are approved

Merge in RED/redaction-report-service from manual to master

* commit '78bd529bc7ccd36ccf73e35f7953862120fd0b4d':
  Only add manual redactions, if they are approved
This commit is contained in:
Dominique Eiflaender 2020-10-19 13:42:16 +02:00
commit ab72de54a4
4 changed files with 423 additions and 3 deletions

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>com.iqser.red.service</groupId>
<artifactId>redaction-service-api-v1</artifactId>
<version>1.1.3</version>
<version>1.3.0</version>
</dependency>
<dependency>
<!-- This dependency contains annotations that are used in specifying REST endpoints. -->

View File

@ -16,6 +16,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.Status;
@Service
public class ReportGenerationService {
@ -49,6 +50,9 @@ public class ReportGenerationService {
multiFileRedactionLog.getRedactionLogs().forEach(fileRedactionLog -> {
fileRedactionLog.getRedactionLogEntry().forEach(redactionLogEntry -> {
if(redactionLogEntry.isRedacted()) {
if(redactionLogEntry.isManual() && !redactionLogEntry.getStatus().equals(Status.APPROVED)){
return;
}
Set<Integer> pages = new HashSet<>();
redactionLogEntry.getPositions().forEach(position -> {
pages.add(position.getPage());

View File

@ -34,7 +34,7 @@ public class RedactionReportIntegrationTest {
@Test
public void testReportGeneration() throws IOException {
ClassPathResource redactionLogResource = new ClassPathResource("files/RedactionLog.txt");
ClassPathResource redactionLogResource = new ClassPathResource("files/RedactionLogManual.txt");
RedactionLog redactionLog = objectMapper.readValue(redactionLogResource.getInputStream(), RedactionLog.class);
@ -43,7 +43,7 @@ public class RedactionReportIntegrationTest {
ReportResult reportResult = redactionReportController.generateReport(multiFileRedactionLog);
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/document.docx")) {
try (FileOutputStream fileOutputStream = new FileOutputStream("/tmp/document2.docx")) {
fileOutputStream.write(reportResult.getDocument());
}

View File

@ -0,0 +1,416 @@
{
"redactionLogEntry": [
{
"id": "e5be0f1d941bbb92a068e198648d06c4",
"type": "name",
"value": "Robinson N.",
"reason": "Not redacted because row is not a vertebrate study",
"redacted": false,
"section": "Table in: ",
"color": [
0.8,
0.8,
0.8
],
"positions": [
{
"topLeft": {
"x": 142.04396,
"y": 241.282
},
"width": 7.648056,
"height": 42.43087,
"page": 1
}
],
"sectionNumber": 3,
"manual": false,
"status": null,
"hint": false
},
{
"id": "0295bbdff66926ebb57b03641bba7ba8",
"type": "address",
"value": "Syngenta Crop Protection AG, Basel, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
"redacted": false,
"section": "Table in: ",
"color": [
0.8,
0.8,
0.8
],
"positions": [
{
"topLeft": {
"x": 289.44595,
"y": 327.567
},
"width": 7.648041,
"height": 82.51475,
"page": 1
},
{
"topLeft": {
"x": 298.67056,
"y": 327.567
},
"width": 7.648041,
"height": 75.32377,
"page": 1
}
],
"sectionNumber": 4,
"manual": false,
"status": null,
"hint": false
},
{
"id": "1bd556e9b3dd82987f9775b19bb26fa4",
"type": "address",
"value": "RCC Ltd., Itingen, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
"redacted": false,
"section": "Table in: ",
"color": [
0.8,
0.8,
0.8
],
"positions": [
{
"topLeft": {
"x": 307.89517,
"y": 327.567
},
"width": 7.648041,
"height": 61.670967,
"page": 1
},
{
"topLeft": {
"x": 316.99985,
"y": 327.567
},
"width": 7.648041,
"height": 38.104286,
"page": 1
}
],
"sectionNumber": 4,
"manual": false,
"status": null,
"hint": false
},
{
"id": "e4eb6f849b60753c59897d1da21f3d83",
"type": "hint_only",
"value": "N",
"reason": null,
"redacted": false,
"section": "Table in: ",
"color": [
0,
0.9882353,
0.69411767
],
"positions": [
{
"topLeft": {
"x": 145.03896,
"y": 448.34
},
"width": 7.648056,
"height": 4.000008,
"page": 1
}
],
"sectionNumber": 3,
"manual": false,
"status": null,
"hint": true
},
{
"id": "76dcc148fca080479fb3856d6e404813",
"type": "address",
"value": "Syngenta Crop Protection AG, Basel, Switzerland",
"reason": "Not redacted because row is not a vertebrate study",
"redacted": false,
"section": "Table in: ",
"color": [
0.8,
0.8,
0.8
],
"positions": [
{
"topLeft": {
"x": 169.62755,
"y": 327.567
},
"width": 7.648056,
"height": 82.51475,
"page": 1
},
{
"topLeft": {
"x": 178.73225,
"y": 327.567
},
"width": 7.648056,
"height": 75.32377,
"page": 1
}
],
"sectionNumber": 3,
"manual": false,
"status": null,
"hint": false
},
{
"id": "109c034945053697a8c3ff5449d4dbd5",
"type": "name",
"value": "Wolf S.",
"reason": "Not redacted because row is not a vertebrate study",
"redacted": false,
"section": "Table in: ",
"color": [
0.8,
0.8,
0.8
],
"positions": [
{
"topLeft": {
"x": 261.87195,
"y": 241.282
},
"width": 7.648041,
"height": 26.739037,
"page": 1
}
],
"sectionNumber": 4,
"manual": false,
"status": null,
"hint": false
},
{
"id": "8d4060e4761dfccfdaa6310d6e9c3407",
"type": "hint_only",
"value": "N",
"reason": null,
"redacted": false,
"section": "Table in: ",
"color": [
0,
0.9882353,
0.69411767
],
"positions": [
{
"topLeft": {
"x": 264.88797,
"y": 448.34
},
"width": 7.648041,
"height": 4.000008,
"page": 1
}
],
"sectionNumber": 4,
"manual": false,
"status": null,
"hint": true
},
{
"id": "6b1338e3a108d3993c6da186f57ea019",
"type": "vertebrate",
"value": "rats",
"reason": null,
"redacted": false,
"section": "Table in: ",
"color": [
0,
1,
0
],
"positions": [
{
"topLeft": {
"x": 381.84018,
"y": 377.10638
},
"width": 7.648041,
"height": 12.379707,
"page": 1
}
],
"sectionNumber": 5,
"manual": false,
"status": null,
"hint": true
},
{
"id": "258d1236aa4ff9de4260a9d4284efdc5",
"type": "name",
"value": "Casey, H.W.",
"reason": "Redacted because Section contains Vertebrate",
"redacted": true,
"section": "Table in: ",
"color": [
1,
1,
0
],
"positions": [
{
"topLeft": {
"x": 421.61328,
"y": 241.282
},
"width": 7.648041,
"height": 42.66442,
"page": 1
}
],
"sectionNumber": 5,
"manual": false,
"status": null,
"hint": false
},
{
"id": "0836727c3508a0b2ea271da69c04cc2f",
"type": "address",
"value": "Toxigenics, Inc., Decatur, IL 62526, USA",
"reason": "Redacted because Section contains Vertebrate",
"redacted": true,
"section": "Table in: ",
"color": [
0,
1,
1
],
"positions": [
{
"topLeft": {
"x": 400.16907,
"y": 327.567
},
"width": 7.648041,
"height": 91.46436,
"page": 1
},
{
"topLeft": {
"x": 409.39368,
"y": 327.567
},
"width": 7.648041,
"height": 38.232735,
"page": 1
}
],
"sectionNumber": 5,
"manual": false,
"status": null,
"hint": false
},
{
"id": "0372ec83feed162bdd478b201027bc25",
"type": "name",
"value": "Salamon, C.M.",
"reason": "Redacted because Section contains Vertebrate",
"redacted": true,
"section": "Table in: ",
"color": [
1,
1,
0
],
"positions": [
{
"topLeft": {
"x": 394.0594,
"y": 241.282
},
"width": 7.648041,
"height": 32.012077,
"page": 1
},
{
"topLeft": {
"x": 403.16406,
"y": 241.282
},
"width": 7.648041,
"height": 18.487892,
"page": 1
}
],
"sectionNumber": 5,
"manual": false,
"status": null,
"hint": false
},
{
"id": "8734c14e72b7750de7637627ed5d572c",
"type": "name",
"value": "Smith, S.H.",
"reason": "Redacted because Section contains Vertebrate",
"redacted": true,
"section": "Table in: ",
"color": [
1,
1,
0
],
"positions": [
{
"topLeft": {
"x": 412.38867,
"y": 241.282
},
"width": 7.648041,
"height": 39.300346,
"page": 1
}
],
"sectionNumber": 5,
"manual": false,
"status": null,
"hint": false
},
{
"id": "2f4459be7301d8689a0f405399e55d69",
"type": "name",
"value": null,
"reason": "Manual Redaction",
"redacted": true,
"section": null,
"color": [
1,
1,
0
],
"positions": [
{
"topLeft": {
"x": 375.61096,
"y": 241.282
},
"width": 7.648041,
"height": 43.72262,
"page": 1
}
],
"sectionNumber": 0,
"manual": true,
"status": "APPROVED",
"hint": false
}
],
"dictionaryVersion": 9,
"rulesVersion": 2,
"filename": "Single Table.pdf"
}