debugging

This commit is contained in:
Timo Bejan 2021-11-03 17:53:24 +02:00
parent 4900e526fb
commit 07d59c6353
6 changed files with 932 additions and 97 deletions

View File

@ -233,8 +233,8 @@ public class RedactionLogMergeService {
redactionLogEntry.setComments(comments.get(manualRedactionEntry.getId()));
sectionTextService.handleSectionText(sectionGrid, redactionLogEntry);
redactionLogEntries.add(redactionLogEntry);
redactionLogEntries.add(redactionLogEntry);
}
}

View File

@ -2,14 +2,19 @@ package com.iqser.red.service.redaction.v1.server.redaction.service;
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
import com.iqser.red.service.redaction.v1.model.SectionGrid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SectionTextService {
public void handleSectionText(SectionGrid sectionGrid, RedactionLogEntry redactionLogEntry) {
log.info("Handling manual redaction match for sections: {} and entry section: {}, positions: {}",
sectionGrid != null ? sectionGrid.getSections().size() : "null", redactionLogEntry.getSection(), redactionLogEntry.getPositions());
if (redactionLogEntry.getSection() != null) {
// set by UI
return;

View File

@ -2,7 +2,9 @@ package com.iqser.red.service.redaction.v1.server.redaction.utils;
import com.amazonaws.services.s3.AmazonS3;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.redaction.v1.model.*;
import com.iqser.red.service.redaction.v1.model.ManualRedactions;
import com.iqser.red.service.redaction.v1.model.RedactionLog;
import com.iqser.red.service.redaction.v1.model.SectionGrid;
import com.iqser.red.service.redaction.v1.server.Application;
import com.iqser.red.service.redaction.v1.server.redaction.service.DictionaryService;
import com.iqser.red.service.redaction.v1.server.redaction.service.RedactionLogMergeService;
@ -56,43 +58,23 @@ public class SectionTextServiceTest {
@Test
@SneakyThrows
public void testMerge(){
public void testMerge() {
when(dictionaryService.getColor(Mockito.anyString(), Mockito.anyString())).thenReturn(new float[]{0,0,0});
when(dictionaryService.getColor(Mockito.anyString(), Mockito.anyString())).thenReturn(new float[]{0, 0, 0});
RedactionLogEntry entry = objectMapper.readValue(new ClassPathResource("contains/entry.json").getInputStream(), RedactionLogEntry.class);
ManualRedactions manualRedactions = objectMapper.readValue(new ClassPathResource("contains/manual-redactions.json").getInputStream(), ManualRedactions.class);
RedactionLog redactionLog = new RedactionLog(1, Lists.newArrayList(),Lists.newArrayList(),1,1,1,1);
RedactionLog redactionLog = new RedactionLog(1, Lists.newArrayList(), Lists.newArrayList(), 1, 1, 1, 1);
SectionGrid sectionGrid = objectMapper.readValue(new ClassPathResource("contains/sections.json").getInputStream(), SectionGrid.class);
ManualRedactionEntry addRequest = new ManualRedactionEntry();
addRequest.setAddToDictionary(false);
addRequest.setAddToDossierDictionary(false);
addRequest.setStatus(Status.APPROVED);
addRequest.setReason("reason");
addRequest.setType("manual");
addRequest.setId("123");
addRequest.setUser("123");
addRequest.setPositions(entry.getPositions());
RedactionLog merged = redactionLogMergeService.mergeRedactionLogData(redactionLog, sectionGrid, "1", ManualRedactions.builder().entriesToAdd(Sets.newLinkedHashSet(addRequest)).build(), Sets.newHashSet());
RedactionLog merged = redactionLogMergeService.mergeRedactionLogData(redactionLog, sectionGrid, "1", manualRedactions, Sets.newHashSet());
assertThat(merged.getRedactionLogEntry().isEmpty()).isFalse();
assertThat(merged.getRedactionLogEntry().iterator().next().getSection()).isEqualTo("Headline 1");
assertThat(merged.getRedactionLogEntry().iterator().next().getSectionNumber()).isEqualTo(1);
assertThat(merged.getRedactionLogEntry().iterator().next().getSection()).isEqualTo("NOTIFICATION OF AN ACTIVE\n" +
"SUBSTANCE UNDER COMMISSION\n" +
"REGULATION (EU) 844/2012");
assertThat(merged.getRedactionLogEntry().iterator().next().getSectionNumber()).isEqualTo(7);
}
@Test
@SneakyThrows
public void testSectionMatch() {
SectionGrid sectionGrid = objectMapper.readValue(new ClassPathResource("contains/sections.json").getInputStream(), SectionGrid.class);
RedactionLogEntry entry = objectMapper.readValue(new ClassPathResource("contains/entry.json").getInputStream(), RedactionLogEntry.class);
service.handleSectionText(sectionGrid, entry);
assertThat(entry.getSection()).isEqualTo("Headline 1");
assertThat(entry.getSectionNumber()).isEqualTo(1);
}
}

View File

@ -1,60 +0,0 @@
{
"id": "4092d4f880675587b33c8c1d4a7420fa",
"type": "manual",
"value": "NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"reason": "names and addresses of persons involved in testing on vertebrate animals",
"matchedRule": 0,
"legalBasis": "[Reg (EC) No 1107/2009 Art. 63 (2g)]",
"redacted": true,
"color": [
0.6745098,
0.9882353,
0
],
"positions": [
{
"topLeft": {
"x": 189.224,
"y": 478.632
},
"width": 231.03699,
"height": 22.912,
"page": 1
},
{
"topLeft": {
"x": 169.65797,
"y": 460.234
},
"width": 270.143,
"height": 22.912,
"page": 1
},
{
"topLeft": {
"x": 197.63498,
"y": 441.836
},
"width": 214.25,
"height": 22.912,
"page": 1
}
],
"manual": true,
"status": "APPROVED",
"manualRedactionType": "ADD",
"manualRedactionUserId": "7adf30b4-a0d8-4abb-adbb-760b1211098f",
"textBefore": null,
"textAfter": null,
"startOffset": 0,
"endOffset": 0,
"imageHasTransparency": false,
"excluded": false,
"recategorizationType": null,
"legalBasisChangeValue": null,
"hint": false,
"recommendation": false,
"image": false,
"dictionaryEntry": false,
"dossierDictionaryEntry": false
}

View File

@ -0,0 +1,54 @@
{
"idsToRemove": [],
"entriesToAdd": [
{
"id": "d5fd9fd9690557703a22d8ab22832c7f",
"user": "7adf30b4-a0d8-4abb-adbb-760b1211098f",
"type": "manual",
"value": "DOCUMENT M-CA, Section 10\nSupplement",
"reason": "names and addresses of persons involved in testing on vertebrate animals",
"legalBasis": "[Reg (EC) No 1107/2009 Art. 63 (2g)]",
"section": null,
"positions": [
{
"topLeft": {
"x": 190.92,
"y": 376.7999
},
"width": 227.49368,
"height": 14.974969,
"page": 1
},
{
"topLeft": {
"x": 258.96,
"y": 358.31992
},
"width": 91.47408,
"height": 14.974969,
"page": 1
}
],
"status": "APPROVED",
"addToDictionary": false,
"addToDossierDictionary": false,
"requestDate": "2021-11-03T15:01:45Z",
"processedDate": "2021-11-03T15:01:45Z",
"softDeletedTime": null
}
],
"forceRedactions": [],
"imageRecategorization": [],
"legalBasisChanges": [],
"comments": {
"d5fd9fd9690557703a22d8ab22832c7f": [
{
"id": "56c1a675-0d64-4190-b76c-6af9d0b361a9",
"date": "2021-11-03T15:01:45Z",
"text": "test",
"user": "7adf30b4-a0d8-4abb-adbb-760b1211098f",
"softDeletedTime": null
}
]
}
}

View File

@ -1,21 +1,875 @@
{
"rectanglesPerPage": {
"1": [
{
"topLeft": {
"x": 251.4,
"y": 550.32
},
"width": 107.763336,
"height": 12.02002,
"part": 1,
"numberOfParts": 1,
"tableCells": null
},
{
"topLeft": {
"x": 159.24,
"y": 280.92004
},
"width": 291.92004,
"height": 212.29996,
"part": 1,
"numberOfParts": 3,
"tableCells": null
}
],
"2": [
{
"topLeft": {
"x": 70.92,
"y": 735.36
},
"width": 105.64288,
"height": 9.02002,
"part": 2,
"numberOfParts": 3,
"tableCells": null
},
{
"topLeft": {
"x": 65.56436,
"y": 719.9557
},
"width": 478.4686,
"height": -110.91278,
"part": 3,
"numberOfParts": 3,
"tableCells": [
{
"topLeft": {
"x": 65.56436,
"y": 684.47955
},
"width": 83.35573,
"height": 35.476135
},
{
"topLeft": {
"x": 148.92009,
"y": 684.47955
},
"width": 255.12016,
"height": 35.476135
},
{
"topLeft": {
"x": 404.04025,
"y": 684.47955
},
"width": 139.9927,
"height": 35.476135
},
{
"topLeft": {
"x": 65.56436,
"y": 659.27954
},
"width": 83.35573,
"height": 25.200012
},
{
"topLeft": {
"x": 148.92009,
"y": 659.27954
},
"width": 255.12016,
"height": 25.200012
},
{
"topLeft": {
"x": 404.04025,
"y": 659.27954
},
"width": 139.9927,
"height": 25.200012
},
{
"topLeft": {
"x": 65.56436,
"y": 634.20074
},
"width": 83.35573,
"height": 25.078796
},
{
"topLeft": {
"x": 148.92009,
"y": 634.20074
},
"width": 255.12016,
"height": 25.078796
},
{
"topLeft": {
"x": 404.04025,
"y": 634.20074
},
"width": 139.9927,
"height": 25.078796
},
{
"topLeft": {
"x": 65.56436,
"y": 609.0429
},
"width": 83.35573,
"height": 25.157837
},
{
"topLeft": {
"x": 148.92009,
"y": 609.0429
},
"width": 255.12016,
"height": 25.157837
},
{
"topLeft": {
"x": 404.04025,
"y": 609.0429
},
"width": 139.9927,
"height": 25.157837
}
]
}
],
"3": [
{
"topLeft": {
"x": 70.92,
"y": 691.2
},
"width": 468.76624,
"height": 53.179993,
"part": 1,
"numberOfParts": 3,
"tableCells": null
}
],
"4": [
{
"topLeft": {
"x": 71.04,
"y": 555.48
},
"width": 461.24002,
"height": 188.78003,
"part": 2,
"numberOfParts": 3,
"tableCells": null
},
{
"topLeft": {
"x": 65.68587,
"y": 540.55756
},
"width": 478.58698,
"height": -365.55508,
"part": 3,
"numberOfParts": 3,
"tableCells": [
{
"topLeft": {
"x": 65.68587,
"y": 515.4003
},
"width": 125.808716,
"height": 25.157227
},
{
"topLeft": {
"x": 191.49458,
"y": 515.4003
},
"width": 352.77826,
"height": 25.157227
},
{
"topLeft": {
"x": 65.68587,
"y": 404.75992
},
"width": 125.808716,
"height": 110.64041
},
{
"topLeft": {
"x": 191.49458,
"y": 404.75992
},
"width": 352.77826,
"height": 110.64041
},
{
"topLeft": {
"x": 65.68587,
"y": 379.68002
},
"width": 125.808716,
"height": 25.079895
},
{
"topLeft": {
"x": 191.49458,
"y": 379.68002
},
"width": 352.77826,
"height": 25.079895
},
{
"topLeft": {
"x": 65.68587,
"y": 335.8798
},
"width": 125.808716,
"height": 43.800232
},
{
"topLeft": {
"x": 191.49458,
"y": 335.8798
},
"width": 352.77826,
"height": 43.800232
},
{
"topLeft": {
"x": 65.68587,
"y": 310.68
},
"width": 125.808716,
"height": 25.199799
},
{
"topLeft": {
"x": 191.49458,
"y": 310.68
},
"width": 352.77826,
"height": 25.199799
},
{
"topLeft": {
"x": 65.68587,
"y": 281.2798
},
"width": 125.808716,
"height": 29.400208
},
{
"topLeft": {
"x": 191.49458,
"y": 281.2798
},
"width": 352.77826,
"height": 29.400208
},
{
"topLeft": {
"x": 65.68587,
"y": 218.76001
},
"width": 125.808716,
"height": 62.519775
},
{
"topLeft": {
"x": 191.49458,
"y": 218.76001
},
"width": 352.77826,
"height": 62.519775
},
{
"topLeft": {
"x": 65.68587,
"y": 175.00247
},
"width": 125.808716,
"height": 43.757538
},
{
"topLeft": {
"x": 191.49458,
"y": 175.00247
},
"width": 352.77826,
"height": 43.757538
}
]
}
]
},
"sections": [
{
"sectionNumber": 1,
"headline": "Headline 1",
"headline": "",
"pages": [
1
],
"sectionAreas": [
{
"topLeft": {
"x": 169.65797,
"y": 282.43396
"x": 251.4,
"y": 550.32
},
"width": 271.14307,
"height": 285.75897,
"width": 107.763336,
"height": 12.02002,
"page": 1,
"header": "Unknown"
"header": null
}
]
},
{
"sectionNumber": 2,
"headline": "Table in: NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"pages": [
2
],
"sectionAreas": [
{
"topLeft": {
"x": 65.56436,
"y": 684.47955
},
"width": 83.35573,
"height": 35.476135,
"page": 2,
"header": null
},
{
"topLeft": {
"x": 148.92009,
"y": 684.47955
},
"width": 255.12016,
"height": 35.476135,
"page": 2,
"header": null
},
{
"topLeft": {
"x": 404.04025,
"y": 684.47955
},
"width": 139.9927,
"height": 35.476135,
"page": 2,
"header": null
}
]
},
{
"sectionNumber": 3,
"headline": "Table in: NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"pages": [],
"sectionAreas": []
},
{
"sectionNumber": 4,
"headline": "Table in: NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"pages": [],
"sectionAreas": []
},
{
"sectionNumber": 5,
"headline": "Table in: NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"pages": [
2
],
"sectionAreas": [
{
"topLeft": {
"x": 65.56436,
"y": 609.0429
},
"width": 83.35573,
"height": 25.157837,
"page": 2,
"header": "Date"
}
]
},
{
"sectionNumber": 7,
"headline": "NOTIFICATION OF AN ACTIVE\nSUBSTANCE UNDER COMMISSION\nREGULATION (EU) 844/2012",
"pages": [
1,
2
],
"sectionAreas": [
{
"topLeft": {
"x": 159.24,
"y": 280.92004
},
"width": 291.92004,
"height": 212.29996,
"page": 1,
"header": null
},
{
"topLeft": {
"x": 70.92,
"y": 735.36
},
"width": 105.64288,
"height": 9.02002,
"page": 2,
"header": null
}
]
},
{
"sectionNumber": 8,
"headline": "Table in: Table of Contents",
"pages": [
4
],
"sectionAreas": [
{
"topLeft": {
"x": 65.68587,
"y": 515.4003
},
"width": 125.808716,
"height": 25.157227,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 515.4003
},
"width": 352.77826,
"height": 25.157227,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 404.75992
},
"width": 125.808716,
"height": 110.64041,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 379.68002
},
"width": 125.808716,
"height": 25.079895,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 379.68002
},
"width": 352.77826,
"height": 25.079895,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 335.8798
},
"width": 125.808716,
"height": 43.800232,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 335.8798
},
"width": 352.77826,
"height": 43.800232,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 310.68
},
"width": 125.808716,
"height": 25.199799,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 310.68
},
"width": 352.77826,
"height": 25.199799,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 281.2798
},
"width": 125.808716,
"height": 29.400208,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 281.2798
},
"width": 352.77826,
"height": 29.400208,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 218.76001
},
"width": 125.808716,
"height": 62.519775,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 218.76001
},
"width": 352.77826,
"height": 62.519775,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 65.68587,
"y": 175.00247
},
"width": 125.808716,
"height": 43.757538,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 191.49458,
"y": 175.00247
},
"width": 352.77826,
"height": 43.757538,
"page": 4,
"header": null
}
]
},
{
"sectionNumber": 9,
"headline": "Table of Contents",
"pages": [
3,
4
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 691.2
},
"width": 468.76624,
"height": 53.179993,
"page": 3,
"header": null
},
{
"topLeft": {
"x": 71.04,
"y": 555.48
},
"width": 461.24002,
"height": 188.78003,
"page": 4,
"header": null
}
]
},
{
"sectionNumber": 10,
"headline": "Header",
"pages": [
1
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 799.08
},
"width": 469.31543,
"height": 6.799988,
"page": 1,
"header": null
},
{
"topLeft": {
"x": 534.72,
"y": 783.84
},
"width": 5.470215,
"height": 6.0200195,
"page": 1,
"header": null
}
]
},
{
"sectionNumber": 11,
"headline": "Header",
"pages": [
2
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 799.08
},
"width": 469.31543,
"height": 6.799988,
"page": 2,
"header": null
},
{
"topLeft": {
"x": 534.72,
"y": 783.84
},
"width": 5.470215,
"height": 6.0200195,
"page": 2,
"header": null
}
]
},
{
"sectionNumber": 12,
"headline": "Header",
"pages": [
3
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 799.08
},
"width": 469.31543,
"height": 6.799988,
"page": 3,
"header": null
},
{
"topLeft": {
"x": 534.72,
"y": 783.84
},
"width": 5.470215,
"height": 6.0200195,
"page": 3,
"header": null
}
]
},
{
"sectionNumber": 13,
"headline": "Header",
"pages": [
4
],
"sectionAreas": [
{
"topLeft": {
"x": 71.04,
"y": 798.96
},
"width": 469.70926,
"height": 6.799988,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 534.84,
"y": 783.72
},
"width": 5.488098,
"height": 6.036072,
"page": 4,
"header": null
}
]
},
{
"sectionNumber": 14,
"headline": "Footer",
"pages": [
1
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 37.080017
},
"width": 93.19173,
"height": 6.0200005,
"page": 1,
"header": null
},
{
"topLeft": {
"x": 468.0,
"y": 37.080017
},
"width": 71.701416,
"height": 6.0200005,
"page": 1,
"header": null
}
]
},
{
"sectionNumber": 15,
"headline": "Footer",
"pages": [
2
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 37.440002
},
"width": 93.19173,
"height": 6.0200005,
"page": 2,
"header": null
},
{
"topLeft": {
"x": 468.0,
"y": 37.440002
},
"width": 71.701416,
"height": 6.0200005,
"page": 2,
"header": null
}
]
},
{
"sectionNumber": 16,
"headline": "Footer",
"pages": [
3
],
"sectionAreas": [
{
"topLeft": {
"x": 70.92,
"y": 37.440002
},
"width": 468.78143,
"height": 6.0200005,
"page": 3,
"header": null
}
]
},
{
"sectionNumber": 17,
"headline": "Footer",
"pages": [
4
],
"sectionAreas": [
{
"topLeft": {
"x": 71.04,
"y": 37.320007
},
"width": 93.3805,
"height": 6.0360794,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 468.12,
"y": 37.320007
},
"width": 71.984375,
"height": 6.0360794,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 71.04,
"y": 140.16003
},
"width": 254.69507,
"height": 7.5200043,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 71.04,
"y": 115.56
},
"width": 65.564415,
"height": 7.5199966,
"page": 4,
"header": null
},
{
"topLeft": {
"x": 71.04,
"y": 90.599976
},
"width": 424.84805,
"height": 7.5199966,
"page": 4,
"header": null
}
]
}