RSS-145: Fixed Immutable list exception when merging existing and added fileattributes
This commit is contained in:
parent
503df78f88
commit
e2234dc52a
@ -44,7 +44,15 @@ public class EntityRedactionService {
|
|||||||
FindEntitiesResult findEntitiesResult = findEntities(sectionTexts, dictionary, kieContainer, analyzeRequest, false, null, imagesPerPage, nerEntities);
|
FindEntitiesResult findEntitiesResult = findEntities(sectionTexts, dictionary, kieContainer, analyzeRequest, false, null, imagesPerPage, nerEntities);
|
||||||
|
|
||||||
if (dictionary.hasLocalEntries() || !findEntitiesResult.getAddedFileAttributes().isEmpty()) {
|
if (dictionary.hasLocalEntries() || !findEntitiesResult.getAddedFileAttributes().isEmpty()) {
|
||||||
analyzeRequest.getFileAttributes().addAll(findEntitiesResult.getAddedFileAttributes());
|
|
||||||
|
if(!findEntitiesResult.getAddedFileAttributes().isEmpty()) {
|
||||||
|
//AnalyzeRequest provides immutable list.
|
||||||
|
List<FileAttribute> mergedFileAttributes = new ArrayList<>();
|
||||||
|
mergedFileAttributes.addAll(analyzeRequest.getFileAttributes());
|
||||||
|
mergedFileAttributes.addAll(findEntitiesResult.getAddedFileAttributes());
|
||||||
|
analyzeRequest.setFileAttributes(mergedFileAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
Map<Integer, Set<Entity>> hintsPerSectionNumber = getHintsPerSection(findEntitiesResult.getEntities(), dictionary);
|
Map<Integer, Set<Entity>> hintsPerSectionNumber = getHintsPerSection(findEntitiesResult.getEntities(), dictionary);
|
||||||
FindEntitiesResult foundByLocalEntitiesResult = findEntities(sectionTexts, dictionary, kieContainer, analyzeRequest, true, hintsPerSectionNumber, imagesPerPage, nerEntities);
|
FindEntitiesResult foundByLocalEntitiesResult = findEntities(sectionTexts, dictionary, kieContainer, analyzeRequest, true, hintsPerSectionNumber, imagesPerPage, nerEntities);
|
||||||
EntitySearchUtils.addEntitiesWithHigherRank(findEntitiesResult.getEntities(), foundByLocalEntitiesResult.getEntities(), dictionary);
|
EntitySearchUtils.addEntitiesWithHigherRank(findEntitiesResult.getEntities(), foundByLocalEntitiesResult.getEntities(), dictionary);
|
||||||
@ -154,7 +162,13 @@ public class EntityRedactionService {
|
|||||||
Set<Entity> entities = new HashSet<>();
|
Set<Entity> entities = new HashSet<>();
|
||||||
sectionSearchableTextPairs.forEach(sectionSearchableTextPair -> {
|
sectionSearchableTextPairs.forEach(sectionSearchableTextPair -> {
|
||||||
|
|
||||||
sectionSearchableTextPair.getSection().getFileAttributes().addAll(addedFileAttributes);
|
if(!addedFileAttributes.isEmpty()) {
|
||||||
|
//Section.Builder provides immutable list.
|
||||||
|
List<FileAttribute> mergedFileAttributes = new ArrayList<>();
|
||||||
|
mergedFileAttributes.addAll(sectionSearchableTextPair.getSection().getAddedFileAttributes());
|
||||||
|
mergedFileAttributes.addAll(addedFileAttributes);
|
||||||
|
sectionSearchableTextPair.getSection().setFileAttributes(mergedFileAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
Section analysedSection = droolsExecutionService.executeRules(kieContainer, sectionSearchableTextPair.getSection());
|
Section analysedSection = droolsExecutionService.executeRules(kieContainer, sectionSearchableTextPair.getSection());
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user