RED-413: Added user to manual redactions, approved flag to Status.APPROVED
This commit is contained in:
parent
8f12695f16
commit
638c4f9c65
@ -15,7 +15,8 @@ import lombok.NoArgsConstructor;
|
|||||||
public class IdRemoval {
|
public class IdRemoval {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private boolean approved;
|
private String user;
|
||||||
|
private Status status;
|
||||||
private boolean removeFromDictionary;
|
private boolean removeFromDictionary;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
|||||||
@ -15,11 +15,12 @@ import lombok.NoArgsConstructor;
|
|||||||
public class ManualRedactionEntry {
|
public class ManualRedactionEntry {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
private String user;
|
||||||
private String type;
|
private String type;
|
||||||
private String value;
|
private String value;
|
||||||
private String reason;
|
private String reason;
|
||||||
private List<Rectangle> positions = new ArrayList<>();
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
private boolean approved;
|
private Status status;
|
||||||
private boolean addToDictionary;
|
private boolean addToDictionary;
|
||||||
|
|
||||||
@Builder.Default
|
@Builder.Default
|
||||||
|
|||||||
@ -27,6 +27,6 @@ public class RedactionLogEntry {
|
|||||||
private List<Rectangle> positions = new ArrayList<>();
|
private List<Rectangle> positions = new ArrayList<>();
|
||||||
private int sectionNumber;
|
private int sectionNumber;
|
||||||
private boolean manual;
|
private boolean manual;
|
||||||
private boolean approved;
|
private Status status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
package com.iqser.red.service.redaction.v1.model;
|
||||||
|
|
||||||
|
public enum Status {
|
||||||
|
REQUESTED, APPROVED, DECLINED
|
||||||
|
}
|
||||||
@ -29,6 +29,7 @@ import com.iqser.red.service.redaction.v1.model.ManualRedactionEntry;
|
|||||||
import com.iqser.red.service.redaction.v1.model.ManualRedactions;
|
import com.iqser.red.service.redaction.v1.model.ManualRedactions;
|
||||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.Status;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Document;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.Paragraph;
|
import com.iqser.red.service.redaction.v1.server.classification.model.Paragraph;
|
||||||
import com.iqser.red.service.redaction.v1.server.classification.model.TextBlock;
|
import com.iqser.red.service.redaction.v1.server.classification.model.TextBlock;
|
||||||
@ -109,13 +110,13 @@ public class AnnotationHighlightService {
|
|||||||
for (IdRemoval manualRemoval : manualRedactions.getIdsToRemove()) {
|
for (IdRemoval manualRemoval : manualRedactions.getIdsToRemove()) {
|
||||||
if (manualRemoval.getId().equals(entityPositionSequence.getId())) {
|
if (manualRemoval.getId().equals(entityPositionSequence.getId())) {
|
||||||
comments = manualRemoval.getComments();
|
comments = manualRemoval.getComments();
|
||||||
String manualOverrideReason;
|
String manualOverrideReason = null;
|
||||||
if (manualRemoval.isApproved()) {
|
if (manualRemoval.getStatus().equals(Status.APPROVED)) {
|
||||||
entity.setRedaction(false);
|
entity.setRedaction(false);
|
||||||
redactionLogEntry.setRedacted(false);
|
redactionLogEntry.setRedacted(false);
|
||||||
redactionLogEntry.setApproved(true);
|
redactionLogEntry.setStatus(Status.APPROVED);
|
||||||
manualOverrideReason = entity.getRedactionReason() + ", removed by manual override";
|
manualOverrideReason = entity.getRedactionReason() + ", removed by manual override";
|
||||||
} else {
|
} else if (manualRemoval.getStatus().equals(Status.REQUESTED)) {
|
||||||
requestedToRemove = true;
|
requestedToRemove = true;
|
||||||
manualOverrideReason = entity.getRedactionReason() + ", requested to remove";
|
manualOverrideReason = entity.getRedactionReason() + ", requested to remove";
|
||||||
if (manualRemoval.isRemoveFromDictionary()) {
|
if (manualRemoval.isRemoveFromDictionary()) {
|
||||||
@ -123,7 +124,7 @@ public class AnnotationHighlightService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setRedactionReason(manualOverrideReason);
|
entity.setRedactionReason(manualOverrideReason != null ? manualOverrideReason : entity.getRedactionReason());
|
||||||
redactionLogEntry.setReason(manualOverrideReason);
|
redactionLogEntry.setReason(manualOverrideReason);
|
||||||
redactionLogEntry.setManual(true);
|
redactionLogEntry.setManual(true);
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ public class AnnotationHighlightService {
|
|||||||
|
|
||||||
if (!rectanglesOnPage.isEmpty()) {
|
if (!rectanglesOnPage.isEmpty()) {
|
||||||
annotations.addAll(createAnnotation(rectanglesOnPage, prefixId(manualRedactionEntry, id), createAnnotationContent(manualRedactionEntry), getColorForManualAdd(manualRedactionEntry
|
annotations.addAll(createAnnotation(rectanglesOnPage, prefixId(manualRedactionEntry, id), createAnnotationContent(manualRedactionEntry), getColorForManualAdd(manualRedactionEntry
|
||||||
.getType(), manualRedactionEntry.isApproved()), manualRedactionEntry.getComments(), true));
|
.getType(), manualRedactionEntry.getStatus()), manualRedactionEntry.getComments(), true));
|
||||||
classifiedDoc.getRedactionLogEntities().add(redactionLogEntry);
|
classifiedDoc.getRedactionLogEntities().add(redactionLogEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,13 +230,18 @@ public class AnnotationHighlightService {
|
|||||||
|
|
||||||
private String prefixId(ManualRedactionEntry manualRedactionEntry, String id) {
|
private String prefixId(ManualRedactionEntry manualRedactionEntry, String id) {
|
||||||
|
|
||||||
if (manualRedactionEntry.isApproved()) {
|
if (manualRedactionEntry.getStatus().equals(Status.APPROVED)) {
|
||||||
return "redaction:" + manualRedactionEntry.getType() + ":" + id;
|
return "redaction:" + manualRedactionEntry.getType() + ":" + id;
|
||||||
}
|
}
|
||||||
if (manualRedactionEntry.isAddToDictionary()) {
|
|
||||||
return "request:add:" + manualRedactionEntry.getType() + ":" + id;
|
if(manualRedactionEntry.getStatus().equals(Status.REQUESTED)) {
|
||||||
|
if (manualRedactionEntry.isAddToDictionary()) {
|
||||||
|
return "request:add:" + manualRedactionEntry.getType() + ":" + id;
|
||||||
|
}
|
||||||
|
return "request:add:only_here" + ":" + id;
|
||||||
}
|
}
|
||||||
return "request:add:only_here" + ":" + id;
|
|
||||||
|
return "ignore:" + manualRedactionEntry.getType() + ":" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -252,7 +258,7 @@ public class AnnotationHighlightService {
|
|||||||
.section(manualRedactionEntry.getSection())
|
.section(manualRedactionEntry.getSection())
|
||||||
.sectionNumber(manualRedactionEntry.getSectionNumber())
|
.sectionNumber(manualRedactionEntry.getSectionNumber())
|
||||||
.manual(true)
|
.manual(true)
|
||||||
.approved(manualRedactionEntry.isApproved())
|
.status(manualRedactionEntry.getStatus())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,10 +409,12 @@ public class AnnotationHighlightService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private float[] getColorForManualAdd(String type, boolean approved) {
|
private float[] getColorForManualAdd(String type, Status status) {
|
||||||
|
|
||||||
if (!approved) {
|
if (status.equals(Status.REQUESTED)) {
|
||||||
return dictionaryService.getRequestAddColor();
|
return dictionaryService.getRequestAddColor();
|
||||||
|
} else if (status.equals(Status.DECLINED)){
|
||||||
|
return dictionaryService.getNotRedactedColor();
|
||||||
}
|
}
|
||||||
return getColor(type);
|
return getColor(type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,7 @@ import com.iqser.red.service.redaction.v1.model.Point;
|
|||||||
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
import com.iqser.red.service.redaction.v1.model.Rectangle;
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
||||||
import com.iqser.red.service.redaction.v1.model.RedactionResult;
|
import com.iqser.red.service.redaction.v1.model.RedactionResult;
|
||||||
|
import com.iqser.red.service.redaction.v1.model.Status;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
import com.iqser.red.service.redaction.v1.server.client.DictionaryClient;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
import com.iqser.red.service.redaction.v1.server.client.RulesClient;
|
||||||
import com.iqser.red.service.redaction.v1.server.controller.RedactionController;
|
import com.iqser.red.service.redaction.v1.server.controller.RedactionController;
|
||||||
@ -347,10 +348,12 @@ public class RedactionIntegrationTest {
|
|||||||
.build();
|
.build();
|
||||||
manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder()
|
manualRedactions.setIdsToRemove(Set.of(IdRemoval.builder()
|
||||||
.id("0836727c3508a0b2ea271da69c04cc2f")
|
.id("0836727c3508a0b2ea271da69c04cc2f")
|
||||||
.approved(false)
|
.status(Status.REQUESTED)
|
||||||
|
.comments(List.of(comment))
|
||||||
.build()));
|
.build()));
|
||||||
|
|
||||||
ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
|
ManualRedactionEntry manualRedactionEntry = new ManualRedactionEntry();
|
||||||
|
manualRedactionEntry.setStatus(Status.REQUESTED);
|
||||||
manualRedactionEntry.setComments(List.of(comment));
|
manualRedactionEntry.setComments(List.of(comment));
|
||||||
manualRedactionEntry.setType("name");
|
manualRedactionEntry.setType("name");
|
||||||
manualRedactionEntry.setValue("O'Loughlin C.K.");
|
manualRedactionEntry.setValue("O'Loughlin C.K.");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user