Log entries and manual redaction require one position per line
This commit is contained in:
parent
74e63ca292
commit
f5790bccab
@ -1,5 +1,8 @@
|
|||||||
package com.iqser.red.service.redaction.v1.model;
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
@ -12,7 +15,7 @@ public class ManualRedactionEntry {
|
|||||||
private String type;
|
private String type;
|
||||||
private String value;
|
private String value;
|
||||||
private String reason;
|
private String reason;
|
||||||
private Rectangle position;
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
|
|
||||||
private String section;
|
private String section;
|
||||||
private int sectionNumber;
|
private int sectionNumber;
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
package com.iqser.red.service.redaction.v1.model;
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -20,7 +23,8 @@ public class RedactionLogEntry {
|
|||||||
private String section;
|
private String section;
|
||||||
private float[] color;
|
private float[] color;
|
||||||
|
|
||||||
private Rectangle position;
|
@Builder.Default
|
||||||
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
private int sectionNumber;
|
private int sectionNumber;
|
||||||
private boolean manual;
|
private boolean manual;
|
||||||
|
|
||||||
|
|||||||
@ -213,10 +213,11 @@ public class EntityRedactionService {
|
|||||||
|
|
||||||
for (TextBlock textBlock : textBlocks) {
|
for (TextBlock textBlock : textBlocks) {
|
||||||
for (ManualRedactionEntry manualRedactionEntry : manualRedactions.getEntriesToAdd()) {
|
for (ManualRedactionEntry manualRedactionEntry : manualRedactions.getEntriesToAdd()) {
|
||||||
Rectangle rectangle = manualRedactionEntry.getPosition();
|
for (Rectangle rectangle : manualRedactionEntry.getPositions()) {
|
||||||
if (textBlock.contains(rectangle)) {
|
if (textBlock.contains(rectangle)) {
|
||||||
manualRedactionEntry.setSection(section);
|
manualRedactionEntry.setSection(section);
|
||||||
manualRedactionEntry.setSectionNumber(sectionNumber);
|
manualRedactionEntry.setSectionNumber(sectionNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,11 @@ public class AnnotationHighlightService {
|
|||||||
return manualRedactionPages;
|
return manualRedactionPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
manualRedactions.getEntriesToAdd().forEach(entry -> manualRedactionPages.add(entry.getPosition().getPage()));
|
manualRedactions.getEntriesToAdd().forEach(entry -> {
|
||||||
|
entry.getPositions().forEach(pos -> {
|
||||||
|
manualRedactionPages.add(pos.getPage());
|
||||||
|
});
|
||||||
|
});
|
||||||
return manualRedactionPages;
|
return manualRedactionPages;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,7 +115,7 @@ public class AnnotationHighlightService {
|
|||||||
.stream()
|
.stream()
|
||||||
.flatMap(seq -> seq.getTextPositions().stream())
|
.flatMap(seq -> seq.getTextPositions().stream())
|
||||||
.collect(Collectors.toList()), page)) {
|
.collect(Collectors.toList()), page)) {
|
||||||
redactionLogEntry.setPosition(rectangle);
|
redactionLogEntry.getPositions().add(rectangle);
|
||||||
annotations.add(createAnnotation(rectangle, entityPositionSequence.getId(),
|
annotations.add(createAnnotation(rectangle, entityPositionSequence.getId(),
|
||||||
createAnnotationContent(entity), getColor(entity), !flatRedaction && !isHint(entity)));
|
createAnnotationContent(entity), getColor(entity), !flatRedaction && !isHint(entity)));
|
||||||
}
|
}
|
||||||
@ -159,19 +163,24 @@ public class AnnotationHighlightService {
|
|||||||
|
|
||||||
RedactionLogEntry redactionLogEntry = createRedactionLogEntry(manualRedactionEntry, id);
|
RedactionLogEntry redactionLogEntry = createRedactionLogEntry(manualRedactionEntry, id);
|
||||||
|
|
||||||
Rectangle rectangle = manualRedactionEntry.getPosition();
|
boolean foundOnPage = false;
|
||||||
|
for (Rectangle rectangle : manualRedactionEntry.getPositions()) {
|
||||||
|
|
||||||
if (page != rectangle.getPage()) {
|
if (page != rectangle.getPage()) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foundOnPage = true;
|
||||||
|
|
||||||
|
PDAnnotationTextMarkup highlight = createAnnotation(rectangle, id,
|
||||||
|
createAnnotationContent(manualRedactionEntry), getColor(manualRedactionEntry.getType()), true);
|
||||||
|
annotations.add(highlight);
|
||||||
|
|
||||||
|
redactionLogEntry.getPositions().add(rectangle);
|
||||||
|
}
|
||||||
|
if (foundOnPage) {
|
||||||
|
classifiedDoc.getRedactionLogEntities().add(redactionLogEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
PDAnnotationTextMarkup highlight = createAnnotation(rectangle, id,
|
|
||||||
createAnnotationContent(manualRedactionEntry), getColor(manualRedactionEntry
|
|
||||||
.getType()), true);
|
|
||||||
annotations.add(highlight);
|
|
||||||
|
|
||||||
redactionLogEntry.setPosition(rectangle);
|
|
||||||
classifiedDoc.getRedactionLogEntities().add(redactionLogEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -325,12 +325,7 @@ public class RedactionIntegrationTest {
|
|||||||
manualRedactionEntry.setType("name");
|
manualRedactionEntry.setType("name");
|
||||||
manualRedactionEntry.setValue("O'Loughlin C.K.");
|
manualRedactionEntry.setValue("O'Loughlin C.K.");
|
||||||
manualRedactionEntry.setReason("Manual Redaction");
|
manualRedactionEntry.setReason("Manual Redaction");
|
||||||
Rectangle position = new Rectangle();
|
manualRedactionEntry.setPositions(List.of(new Rectangle(new Point(375.61096f, 241.282f), 7.648041f, 43.72262f, 1), new Rectangle(new Point(384.83517f, 241.282f), 7.648041f, 17.043358f, 1)));
|
||||||
position.setTopLeft(new Point(375.61096f, 241.282f));
|
|
||||||
position.setHeight(43.72262f);
|
|
||||||
position.setWidth(15.296082f);
|
|
||||||
position.setPage(1);
|
|
||||||
manualRedactionEntry.setPosition(position);
|
|
||||||
|
|
||||||
manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
|
manualRedactions.getEntriesToAdd().add(manualRedactionEntry);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user