Added isDossierDictionaryEntry to manualRedactions and redactionLog

This commit is contained in:
Dominique Eifländer 2021-04-29 12:29:50 +02:00
parent 01eceaaef4
commit b7ae6cf390
13 changed files with 27 additions and 13 deletions

View File

@ -27,4 +27,6 @@ public class ManualRedactionEntry {
private String section; private String section;
private int sectionNumber; private int sectionNumber;
private boolean addToDossierDictionary;
} }

View File

@ -42,4 +42,6 @@ public class RedactionChangeLogEntry {
private ChangeType changeType; private ChangeType changeType;
private boolean isDossierDictionaryEntry;
} }

View File

@ -45,4 +45,6 @@ public class RedactionLogEntry {
private boolean isImage; private boolean isImage;
private boolean isDossierDictionaryEntry;
} }

View File

@ -21,6 +21,7 @@ public class DictionaryModel implements Serializable {
private boolean recommendation; private boolean recommendation;
private Set<DictionaryEntry> entries; private Set<DictionaryEntry> entries;
private Set<String> localEntries; private Set<String> localEntries;
private boolean isDossierDictionary;
public Set<String> getValues(boolean local) { public Set<String> getValues(boolean local) {
return local ? localEntries : entries.stream().filter(e -> !e.isDeleted()).map(e -> e.getValue()).collect(Collectors return local ? localEntries : entries.stream().filter(e -> !e.isDeleted()).map(e -> e.getValue()).collect(Collectors

View File

@ -37,8 +37,10 @@ public class Entity {
private String textBefore; private String textBefore;
private String textAfter; private String textAfter;
private boolean isDossierDictionaryEntry;
public Entity(String word, String type, boolean redaction, String redactionReason, List<EntityPositionSequence> positionSequences, String headline, int matchedRule, int sectionNumber, String legalBasis, boolean isDictionaryEntry, String textBefore, String textAfter, Integer start, Integer end) {
public Entity(String word, String type, boolean redaction, String redactionReason, List<EntityPositionSequence> positionSequences, String headline, int matchedRule, int sectionNumber, String legalBasis, boolean isDictionaryEntry, String textBefore, String textAfter, Integer start, Integer end, boolean isDossierDictionaryEntry) {
this.word = word; this.word = word;
this.type = type; this.type = type;
@ -54,10 +56,11 @@ public class Entity {
this.textAfter = textAfter; this.textAfter = textAfter;
this.start = start; this.start = start;
this.end = end; this.end = end;
this.isDossierDictionaryEntry = isDossierDictionaryEntry;
} }
public Entity(String word, String type, Integer start, Integer end, String headline, int sectionNumber, boolean isDictionaryEntry) { public Entity(String word, String type, Integer start, Integer end, String headline, int sectionNumber, boolean isDictionaryEntry, boolean isDossierDictionaryEntry) {
this.word = word; this.word = word;
this.type = type; this.type = type;
@ -66,6 +69,7 @@ public class Entity {
this.headline = headline; this.headline = headline;
this.sectionNumber = sectionNumber; this.sectionNumber = sectionNumber;
this.isDictionaryEntry = isDictionaryEntry; this.isDictionaryEntry = isDictionaryEntry;
this.isDossierDictionaryEntry = isDossierDictionaryEntry;
} }
} }

View File

@ -411,7 +411,7 @@ public class Section {
String text = caseInsensitive ? searchText.toLowerCase() : searchText; String text = caseInsensitive ? searchText.toLowerCase() : searchText;
String searchValue = caseInsensitive ? value.toLowerCase() : value; String searchValue = caseInsensitive ? value.toLowerCase() : value;
Set<Entity> found = EntitySearchUtils.find(text, Set.of(searchValue), asType, headline, sectionNumber, true); Set<Entity> found = EntitySearchUtils.find(text, Set.of(searchValue), asType, headline, sectionNumber, true, false);
found.forEach(entity -> { found.forEach(entity -> {
if (redacted) { if (redacted) {
@ -437,7 +437,7 @@ public class Section {
} else { } else {
String word = value.toString(); String word = value.toString();
Entity entity = new Entity(word, type, value.getRowSpanStart(), value.getRowSpanStart() + word.length(), headline, sectionNumber, false); Entity entity = new Entity(word, type, value.getRowSpanStart(), value.getRowSpanStart() + word.length(), headline, sectionNumber, false, false);
entity.setRedaction(redact); entity.setRedaction(redact);
entity.setMatchedRule(ruleNumber); entity.setMatchedRule(ruleNumber);
entity.setRedactionReason(reason); entity.setRedactionReason(reason);

View File

@ -94,7 +94,7 @@ public class DictionaryService {
List<DictionaryModel> dictionary = typeResponse.getTypes() List<DictionaryModel> dictionary = typeResponse.getTypes()
.stream() .stream()
.map(t -> new DictionaryModel(t.getType(), t.getRank(), convertColor(t.getHexColor()), t.isCaseInsensitive(), t .map(t -> new DictionaryModel(t.getType(), t.getRank(), convertColor(t.getHexColor()), t.isCaseInsensitive(), t
.isHint(), t.isRecommendation(), convertEntries(t, dossierId), new HashSet<>())) .isHint(), t.isRecommendation(), convertEntries(t, dossierId), new HashSet<>(),dossierId.equals(GLOBAL_DOSSIER) ? false : true))
.sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed()) .sorted(Comparator.comparingInt(DictionaryModel::getRank).reversed())
.collect(Collectors.toList()); .collect(Collectors.toList());

View File

@ -71,7 +71,7 @@ public class EntityRedactionService {
.add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry .add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry
.getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity .getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity
.getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity .getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity
.getStart(), entity.getEnd())); .getStart(), entity.getEnd(), entity.isDossierDictionaryEntry()));
} }
} }
@ -371,9 +371,9 @@ public class EntityRedactionService {
String lowercaseInputString = searchableString.toLowerCase(); String lowercaseInputString = searchableString.toLowerCase();
for (DictionaryModel model : dictionary.getDictionaryModels()) { for (DictionaryModel model : dictionary.getDictionaryModels()) {
if (model.isCaseInsensitive()) { if (model.isCaseInsensitive()) {
found.addAll(EntitySearchUtils.find(lowercaseInputString, model.getValues(local), model.getType(), headline, sectionNumber, local)); found.addAll(EntitySearchUtils.find(lowercaseInputString, model.getValues(local), model.getType(), headline, sectionNumber, local, model.isDossierDictionary()));
} else { } else {
found.addAll(EntitySearchUtils.find(searchableString, model.getValues(local), model.getType(), headline, sectionNumber, local)); found.addAll(EntitySearchUtils.find(searchableString, model.getValues(local), model.getType(), headline, sectionNumber, local, model.isDossierDictionary()));
} }
} }

View File

@ -216,7 +216,7 @@ public class ReanalyzeService {
.add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry .add(new Entity(entity.getWord(), entity.getType(), entity.isRedaction(), entity.getRedactionReason(), entry
.getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity .getValue(), entity.getHeadline(), entity.getMatchedRule(), entity.getSectionNumber(), entity
.getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity .getLegalBasis(), entity.isDictionaryEntry(), entity.getTextBefore(), entity.getTextAfter(), entity
.getStart(), entity.getEnd())); .getStart(), entity.getEnd(), entity.isDossierDictionaryEntry()));
} }
} }

View File

@ -86,6 +86,7 @@ public class RedactionChangeLogService {
.textAfter(entry.getTextAfter()) .textAfter(entry.getTextAfter())
.comments(entry.getComments()) .comments(entry.getComments())
.changeType(changeType) .changeType(changeType)
.isDossierDictionaryEntry(entry.isDossierDictionaryEntry())
.build(); .build();
} }

View File

@ -355,6 +355,7 @@ public class RedactionLogCreatorService {
.status(manualRedactionEntry.getStatus()) .status(manualRedactionEntry.getStatus())
.manualRedactionType(ManualRedactionType.ADD) .manualRedactionType(ManualRedactionType.ADD)
.isDictionaryEntry(false) .isDictionaryEntry(false)
.isDossierDictionaryEntry(manualRedactionEntry.isAddToDossierDictionary())
.build(); .build();
} }
@ -378,6 +379,7 @@ public class RedactionLogCreatorService {
.textBefore(entity.getTextBefore()) .textBefore(entity.getTextBefore())
.startOffset(entity.getStart()) .startOffset(entity.getStart())
.endOffset(entity.getEnd()) .endOffset(entity.getEnd())
.isDossierDictionaryEntry(entity.isDossierDictionaryEntry())
.build(); .build();
} }

View File

@ -49,7 +49,7 @@ public class EntitySearchUtils {
public Set<Entity> find(String inputString, Set<String> values, String type, String headline, int sectionNumber, public Set<Entity> find(String inputString, Set<String> values, String type, String headline, int sectionNumber,
boolean local) { boolean local, boolean isDossierDictionary) {
Set<Entity> found = new HashSet<>(); Set<Entity> found = new HashSet<>();
@ -69,7 +69,7 @@ public class EntitySearchUtils {
if (startIndex > -1 && (startIndex == 0 || Character.isWhitespace(inputString.charAt(startIndex - 1)) || isSeparator(inputString if (startIndex > -1 && (startIndex == 0 || Character.isWhitespace(inputString.charAt(startIndex - 1)) || isSeparator(inputString
.charAt(startIndex - 1))) && (stopIndex == inputString.length() || isSeparator(inputString.charAt(stopIndex)))) { .charAt(startIndex - 1))) && (stopIndex == inputString.length() || isSeparator(inputString.charAt(stopIndex)))) {
found.add(new Entity(inputString.substring(startIndex, stopIndex), type, startIndex, stopIndex, headline, sectionNumber, !local)); found.add(new Entity(inputString.substring(startIndex, stopIndex), type, startIndex, stopIndex, headline, sectionNumber, !local, isDossierDictionary));
} }
} while (startIndex > -1); } while (startIndex > -1);
} }

View File

@ -114,8 +114,8 @@ public class EntityRedactionServiceTest {
public void testNestedEntitiesRemoval() { public void testNestedEntitiesRemoval() {
Set<Entity> entities = new HashSet<>(); Set<Entity> entities = new HashSet<>();
Entity nested = new Entity("nested", "fake type", 10, 16, "fake headline", 0, false); Entity nested = new Entity("nested", "fake type", 10, 16, "fake headline", 0, false, false);
Entity nesting = new Entity("nesting nested", "fake type", 2, 16, "fake headline", 0, false); Entity nesting = new Entity("nesting nested", "fake type", 2, 16, "fake headline", 0, false, false);
entities.add(nested); entities.add(nested);
entities.add(nesting); entities.add(nesting);
EntitySearchUtils.removeEntitiesContainedInLarger(entities); EntitySearchUtils.removeEntitiesContainedInLarger(entities);