From 1cff5666b5cf8aca2b1f54a214e23657901fc260 Mon Sep 17 00:00:00 2001 From: Maverick Studer Date: Mon, 7 Oct 2024 12:26:00 +0200 Subject: [PATCH] RED-10146: Include defined components in component log --- .../redaction-service-api-v1/build.gradle.kts | 2 +- .../build.gradle.kts | 2 +- .../v1/server/service/AnalyzeService.java | 5 +++- .../ComponentLogCreatorService.java | 30 ++++++++++++++++--- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/redaction-service-v1/redaction-service-api-v1/build.gradle.kts b/redaction-service-v1/redaction-service-api-v1/build.gradle.kts index 1ee7e03c..7c8082ac 100644 --- a/redaction-service-v1/redaction-service-api-v1/build.gradle.kts +++ b/redaction-service-v1/redaction-service-api-v1/build.gradle.kts @@ -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") diff --git a/redaction-service-v1/redaction-service-server-v1/build.gradle.kts b/redaction-service-v1/redaction-service-server-v1/build.gradle.kts index a79200a6..112f8424 100644 --- a/redaction-service-v1/redaction-service-server-v1/build.gradle.kts +++ b/redaction-service-v1/redaction-service-server-v1/build.gradle.kts @@ -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" diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/AnalyzeService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/AnalyzeService.java index 39cfb1c4..d4c54445 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/AnalyzeService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/AnalyzeService.java @@ -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); diff --git a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/components/ComponentLogCreatorService.java b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/components/ComponentLogCreatorService.java index 1f28ff91..34d4f70d 100644 --- a/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/components/ComponentLogCreatorService.java +++ b/redaction-service-v1/redaction-service-server-v1/src/main/java/com/iqser/red/service/redaction/v1/server/service/components/ComponentLogCreatorService.java @@ -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 components, long componentRulesVersion) { + public ComponentLog buildComponentLog(int analysisNumber, + List components, + long componentRulesVersion, + List componentDefinitions) { Map> 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 componentLogComponents = map.entrySet() + List componentLogEntries = map.entrySet() .stream() .map(entry -> new ComponentLogEntry(entry.getKey(), entry.getValue(), false)) - .toList(); - return new ComponentLog(analysisNumber, componentRulesVersion, componentLogComponents); + .collect(Collectors.toList()); + + Set 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); }