diff --git a/redaction-service-v1/redaction-service-server-v1/pom.xml b/redaction-service-v1/redaction-service-server-v1/pom.xml index 08ad41a0..f7d688f0 100644 --- a/redaction-service-v1/redaction-service-server-v1/pom.xml +++ b/redaction-service-v1/redaction-service-server-v1/pom.xml @@ -39,7 +39,7 @@ com.iqser.red.service configuration-service-api-v1 - 1.0.2 + 1.0.6 org.drools diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/service/DictionaryService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/service/DictionaryService.java index 4b6d5bf8..4a02ad89 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/service/DictionaryService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/redaction/service/DictionaryService.java @@ -1,6 +1,8 @@ package com.iqser.red.service.redaction.v1.server.redaction.service; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; @@ -32,6 +34,13 @@ public class DictionaryService { @Getter private Map entryColors = new HashMap<>(); + @Getter + private List hintTypes = new ArrayList<>(); + + @Getter + private List caseInsensitiveTypes = new ArrayList<>(); + + public void updateDictionary() { long version = dictionaryClient.getVersion(); @@ -41,16 +50,36 @@ public class DictionaryService { } } + private void updateDictionaryEntry() { + try { TypeResponse typeResponse = dictionaryClient.getAllTypes(); if (typeResponse != null && !CollectionUtils.isEmpty(typeResponse.getTypes())) { - entryColors = typeResponse.getTypes().stream().collect(Collectors.toMap(TypeResult::getType, TypeResult::getColor)); - dictionary = entryColors.keySet().stream().collect(Collectors.toMap(type -> type, s -> dictionaryClient.getDictionaryForType(s).getEntries().stream().collect(Collectors.toSet()))); + entryColors = typeResponse.getTypes() + .stream() + .collect(Collectors.toMap(TypeResult::getType, TypeResult::getColor)); + dictionary = entryColors.keySet() + .stream() + .collect(Collectors.toMap(type -> type, s -> dictionaryClient.getDictionaryForType(s) + .getEntries() + .stream() + .collect(Collectors.toSet()))); + hintTypes = typeResponse.getTypes() + .stream() + .filter(TypeResult::isHint) + .map(TypeResult::getType) + .collect(Collectors.toList()); + caseInsensitiveTypes = typeResponse.getTypes() + .stream() + .filter(TypeResult::isCaseInsensitive) + .map(TypeResult::getType) + .collect(Collectors.toList()); } } catch (FeignException e) { log.warn("Got some unknown feignException", e); throw e; } } + } \ No newline at end of file diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/visualization/service/AnnotationHighlightService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/visualization/service/AnnotationHighlightService.java index 4b63523e..fa4b49aa 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/visualization/service/AnnotationHighlightService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/visualization/service/AnnotationHighlightService.java @@ -4,6 +4,7 @@ import java.awt.Color; import java.io.IOException; import java.util.List; +import org.apache.commons.collections4.CollectionUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; @@ -208,17 +209,14 @@ public class AnnotationHighlightService { return dictionaryService.getEntryColors().get(entity.getType()); } - private boolean isHint(Entity entity) { - // TODO in RED-161. - if (entity.getType().equalsIgnoreCase("vertebrate") || entity.getType() - .equalsIgnoreCase("no_redaction_indicator")) { + List hintTypes = dictionaryService.getHintTypes(); + if (CollectionUtils.isNotEmpty(hintTypes) && hintTypes.contains(entity.getType())) { return true; } return false; } - private void visualizeTextBlock(TextBlock textBlock, PDPageContentStream contentStream) throws IOException { contentStream.setStrokingColor(Color.LIGHT_GRAY);