RED-8424: Case-Sensitive Redaction Not Functioning Properly for Case-Sensitive Entities
This commit is contained in:
parent
b44e49b4d9
commit
a0d2430319
@ -160,13 +160,19 @@ public class DictionaryService {
|
|||||||
|
|
||||||
List<DictionaryModel> dictionary = typeResponse.stream().map(t -> {
|
List<DictionaryModel> dictionary = typeResponse.stream().map(t -> {
|
||||||
|
|
||||||
Optional<DictionaryModel> oldModel;
|
Optional<DictionaryModel> optionalOldModel;
|
||||||
if (dossierId == null) {
|
if (dossierId == null) {
|
||||||
var representation = getDossierTemplateDictionary(dossierTemplateId);
|
var representation = getDossierTemplateDictionary(dossierTemplateId);
|
||||||
oldModel = representation != null ? representation.getDictionary().stream().filter(f -> f.getType().equals(t.getType())).findAny() : Optional.empty();
|
optionalOldModel = representation != null ? representation.getDictionary()
|
||||||
|
.stream()
|
||||||
|
.filter(f -> f.getType().equals(t.getType()))
|
||||||
|
.findAny() : Optional.empty();
|
||||||
} else {
|
} else {
|
||||||
var representation = getDossierDictionary(dossierId);
|
var representation = getDossierDictionary(dossierId);
|
||||||
oldModel = representation != null ? representation.getDictionary().stream().filter(f -> f.getType().equals(t.getType())).findAny() : Optional.empty();
|
optionalOldModel = representation != null ? representation.getDictionary()
|
||||||
|
.stream()
|
||||||
|
.filter(f -> f.getType().equals(t.getType()))
|
||||||
|
.findAny() : Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<DictionaryEntryModel> entries = new HashSet<>();
|
Set<DictionaryEntryModel> entries = new HashSet<>();
|
||||||
@ -179,19 +185,38 @@ public class DictionaryService {
|
|||||||
var newFalsePositivesValues = newEntries.getFalsePositives().stream().map(DictionaryEntry::getValue).collect(Collectors.toSet());
|
var newFalsePositivesValues = newEntries.getFalsePositives().stream().map(DictionaryEntry::getValue).collect(Collectors.toSet());
|
||||||
var newFalseRecommendationsValues = newEntries.getFalseRecommendations().stream().map(DictionaryEntry::getValue).collect(Collectors.toSet());
|
var newFalseRecommendationsValues = newEntries.getFalseRecommendations().stream().map(DictionaryEntry::getValue).collect(Collectors.toSet());
|
||||||
|
|
||||||
oldModel.ifPresent(oldDictionaryModel -> {
|
optionalOldModel.ifPresent(oldDictionaryModel -> {
|
||||||
|
|
||||||
});
|
});
|
||||||
// add old entries from existing DictionaryModel
|
if (optionalOldModel.isPresent()) {
|
||||||
oldModel.ifPresent(dictionaryModel -> entries.addAll(dictionaryModel.getEntries().stream().filter(f -> !newValues.contains(f.getValue())).toList()));
|
var oldModel = optionalOldModel.get();
|
||||||
oldModel.ifPresent(dictionaryModel -> falsePositives.addAll(dictionaryModel.getFalsePositives()
|
if (oldModel.isCaseInsensitive() && !t.isCaseInsensitive()) {
|
||||||
.stream()
|
// add old entries from existing DictionaryModel but exclude lower case representation
|
||||||
.filter(f -> !newFalsePositivesValues.contains(f.getValue()))
|
entries.addAll(oldModel.getEntries().stream().filter(f -> !newValues.stream().map(s -> s.toLowerCase(Locale.ROOT)).toList().contains(f.getValue())).toList());
|
||||||
.toList()));
|
falsePositives.addAll(oldModel.getFalsePositives()
|
||||||
oldModel.ifPresent(dictionaryModel -> falseRecommendations.addAll(dictionaryModel.getFalseRecommendations()
|
.stream()
|
||||||
.stream()
|
.filter(f -> !newFalsePositivesValues.stream().map(s -> s.toLowerCase(Locale.ROOT)).toList().contains(f.getValue()))
|
||||||
.filter(f -> !newFalseRecommendationsValues.contains(f.getValue()))
|
.toList());
|
||||||
.toList()));
|
falseRecommendations.addAll(oldModel.getFalseRecommendations()
|
||||||
|
.stream()
|
||||||
|
.filter(f -> !newFalseRecommendationsValues.stream().map(s -> s.toLowerCase(Locale.ROOT)).toList().contains(f.getValue()))
|
||||||
|
.toList());
|
||||||
|
} else if (!oldModel.isCaseInsensitive() && t.isCaseInsensitive()) {
|
||||||
|
// add old entries from existing DictionaryModel but exclude upper case representation
|
||||||
|
entries.addAll(oldModel.getEntries().stream().filter(f -> !newValues.contains(f.getValue().toLowerCase(Locale.ROOT))).toList());
|
||||||
|
falsePositives.addAll(oldModel.getFalsePositives().stream().filter(f -> !newFalsePositivesValues.contains(f.getValue().toLowerCase(Locale.ROOT))).toList());
|
||||||
|
falseRecommendations.addAll(oldModel.getFalseRecommendations()
|
||||||
|
.stream()
|
||||||
|
.filter(f -> !newFalseRecommendationsValues.contains(f.getValue().toLowerCase(Locale.ROOT)))
|
||||||
|
.toList());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// add old entries from existing DictionaryModel
|
||||||
|
entries.addAll(oldModel.getEntries().stream().filter(f -> !newValues.contains(f.getValue())).toList());
|
||||||
|
falsePositives.addAll(oldModel.getFalsePositives().stream().filter(f -> !newFalsePositivesValues.contains(f.getValue())).toList());
|
||||||
|
falseRecommendations.addAll(oldModel.getFalseRecommendations().stream().filter(f -> !newFalseRecommendationsValues.contains(f.getValue())).toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add Increments
|
// Add Increments
|
||||||
entries.addAll(newEntries.getEntries());
|
entries.addAll(newEntries.getEntries());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user