Merge branch 'RED-10146-bp' into 'release/4.348.x'

RED-10146: Include defined components in component log

See merge request redactmanager/redaction-service!530
This commit is contained in:
Maverick Studer 2024-10-07 12:26:00 +02:00
commit 333481e1c9
4 changed files with 32 additions and 7 deletions

View File

@ -4,7 +4,7 @@ plugins {
}
description = "redaction-service-api-v1"
val persistenceServiceVersion = "2.465.60"
val persistenceServiceVersion = "2.465.79"
dependencies {
implementation("org.springframework:spring-web:6.0.12")

View File

@ -16,7 +16,7 @@ val layoutParserVersion = "0.142.6"
val jacksonVersion = "2.15.2"
val droolsVersion = "9.44.0.Final"
val pdfBoxVersion = "3.0.0"
val persistenceServiceVersion = "2.465.60"
val persistenceServiceVersion = "2.465.79"
val springBootStarterVersion = "3.1.5"
val springCloudVersion = "4.0.4"
val testContainersVersion = "1.19.7"

View File

@ -358,7 +358,10 @@ public class AnalyzeService {
log.info("Finished component rule execution for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
ComponentLog componentLog = componentLogCreatorService.buildComponentLog(analyzeRequest.getAnalysisNumber(), components, kieWrapperComponentRules.rulesVersion());
ComponentLog componentLog = componentLogCreatorService.buildComponentLog(analyzeRequest.getAnalysisNumber(),
components,
kieWrapperComponentRules.rulesVersion(),
analyzeRequest.getComponentDefinitions());
redactionStorageService.storeObject(analyzeRequest.getDossierId(), analyzeRequest.getFileId(), FileType.COMPONENT_LOG, componentLog);

View File

@ -1,9 +1,15 @@
package com.iqser.red.service.redaction.v1.server.service.components;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
@ -12,6 +18,7 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLogEntry;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLogEntryValue;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Position;
import com.iqser.red.service.persistence.service.v1.api.shared.model.component.ComponentDefinition;
import com.iqser.red.service.redaction.v1.server.model.component.Component;
import com.iqser.red.service.redaction.v1.server.model.component.Entity;
import com.iqser.red.service.redaction.v1.server.service.document.ComponentComparator;
@ -20,7 +27,10 @@ import com.iqser.red.service.redaction.v1.server.service.document.EntityComparat
@Service
public class ComponentLogCreatorService {
public ComponentLog buildComponentLog(int analysisNumber, List<Component> components, long componentRulesVersion) {
public ComponentLog buildComponentLog(int analysisNumber,
List<Component> components,
long componentRulesVersion,
List<ComponentDefinition> componentDefinitions) {
Map<String, List<ComponentLogEntryValue>> map = new HashMap<>();
components.stream()
@ -29,11 +39,23 @@ public class ComponentLogCreatorService {
ComponentLogEntryValue componentLogEntryValue = buildComponentLogEntry(component);
map.computeIfAbsent(component.getName(), k -> new ArrayList<>()).add(componentLogEntryValue);
});
List<ComponentLogEntry> componentLogComponents = map.entrySet()
List<ComponentLogEntry> componentLogEntries = map.entrySet()
.stream()
.map(entry -> new ComponentLogEntry(entry.getKey(), entry.getValue(), false))
.toList();
return new ComponentLog(analysisNumber, componentRulesVersion, componentLogComponents);
.collect(Collectors.toList());
Set<String> existingComponentNames = map.keySet()
.stream()
.map(s -> s.toLowerCase(Locale.ROOT))
.collect(Collectors.toSet());
for (ComponentDefinition componentDefinition : componentDefinitions) {
String technicalName = componentDefinition.getTechnicalName().toLowerCase(Locale.ROOT);
if (!existingComponentNames.contains(technicalName)) {
componentLogEntries.add(new ComponentLogEntry(componentDefinition.getDisplayName(), null, false));
}
}
return new ComponentLog(analysisNumber, componentRulesVersion, componentLogEntries);
}