Merge branch 'RED-9782' into 'release/4.348.x'
RED-9782: Automated Analysis should be disabled when uploading a document that... See merge request redactmanager/redaction-service!471
This commit is contained in:
commit
43620f7b52
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
description = "redaction-service-api-v1"
|
description = "redaction-service-api-v1"
|
||||||
val persistenceServiceVersion = "2.465.38"
|
val persistenceServiceVersion = "2.465.41"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.springframework:spring-web:6.0.12")
|
implementation("org.springframework:spring-web:6.0.12")
|
||||||
|
|||||||
@ -16,7 +16,7 @@ val layoutParserVersion = "0.142.6"
|
|||||||
val jacksonVersion = "2.15.2"
|
val jacksonVersion = "2.15.2"
|
||||||
val droolsVersion = "9.44.0.Final"
|
val droolsVersion = "9.44.0.Final"
|
||||||
val pdfBoxVersion = "3.0.0"
|
val pdfBoxVersion = "3.0.0"
|
||||||
val persistenceServiceVersion = "2.465.38"
|
val persistenceServiceVersion = "2.465.41"
|
||||||
val springBootStarterVersion = "3.1.5"
|
val springBootStarterVersion = "3.1.5"
|
||||||
val springCloudVersion = "4.0.4"
|
val springCloudVersion = "4.0.4"
|
||||||
val testContainersVersion = "1.19.7"
|
val testContainersVersion = "1.19.7"
|
||||||
|
|||||||
@ -120,7 +120,8 @@ public class PrecursorEntity implements IEntity {
|
|||||||
EntityType entityType = getEntityType(entryType);
|
EntityType entityType = getEntityType(entryType);
|
||||||
String value = Optional.ofNullable(importedRedaction.getValue())
|
String value = Optional.ofNullable(importedRedaction.getValue())
|
||||||
.orElse("");
|
.orElse("");
|
||||||
return PrecursorEntity.builder()
|
|
||||||
|
PrecursorEntityBuilder precursorEntityBuilder = PrecursorEntity.builder()
|
||||||
.id(importedRedaction.getId())
|
.id(importedRedaction.getId())
|
||||||
.value(value)
|
.value(value)
|
||||||
.entityPosition(rectangleWithPages)
|
.entityPosition(rectangleWithPages)
|
||||||
@ -130,14 +131,21 @@ public class PrecursorEntity implements IEntity {
|
|||||||
.orElse(""))
|
.orElse(""))
|
||||||
.type(Optional.ofNullable(importedRedaction.getType())
|
.type(Optional.ofNullable(importedRedaction.getType())
|
||||||
.orElse(IMPORTED_REDACTION_TYPE))
|
.orElse(IMPORTED_REDACTION_TYPE))
|
||||||
.section(importedRedaction.getManualOverwriteSection())
|
.section(Optional.ofNullable(importedRedaction.getSection())
|
||||||
|
.orElse(""))
|
||||||
.entityType(entityType)
|
.entityType(entityType)
|
||||||
.isDictionaryEntry(false)
|
.isDictionaryEntry(false)
|
||||||
.isDossierDictionaryEntry(false)
|
.isDossierDictionaryEntry(false)
|
||||||
|
.manualOverwrite(new ManualChangeOverwrite(entityType))
|
||||||
.rectangle(value.isBlank() || entryType.equals(EntryType.IMAGE) || entryType.equals(EntryType.IMAGE_HINT) || entryType.equals(EntryType.AREA))
|
.rectangle(value.isBlank() || entryType.equals(EntryType.IMAGE) || entryType.equals(EntryType.IMAGE_HINT) || entryType.equals(EntryType.AREA))
|
||||||
.manualOverwrite(new ManualChangeOverwrite(entityType, importedRedaction.getManualOverwriteSection()))
|
.engines(Set.of(Engine.IMPORTED));
|
||||||
.engines(Set.of(Engine.IMPORTED))
|
|
||||||
.build();
|
if (importedRedaction.getManualOverwriteSection() != null && !importedRedaction.getManualOverwriteSection().isEmpty()) {
|
||||||
|
precursorEntityBuilder.section(importedRedaction.getManualOverwriteSection())
|
||||||
|
.manualOverwrite(new ManualChangeOverwrite(entityType, importedRedaction.getManualOverwriteSection()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return precursorEntityBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,10 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.RuleFileTyp
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogChanges;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogChanges;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedLegalBases;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.mapper.ImportedLegalBasisMapper;
|
||||||
import com.iqser.red.service.redaction.v1.server.RedactionServiceSettings;
|
import com.iqser.red.service.redaction.v1.server.RedactionServiceSettings;
|
||||||
import com.iqser.red.service.redaction.v1.server.client.model.NerEntitiesModel;
|
import com.iqser.red.service.redaction.v1.server.client.model.NerEntitiesModel;
|
||||||
import com.iqser.red.service.redaction.v1.server.model.KieWrapper;
|
import com.iqser.red.service.redaction.v1.server.model.KieWrapper;
|
||||||
@ -76,6 +78,7 @@ public class AnalyzeService {
|
|||||||
ImportedRedactionEntryService importedRedactionEntryService;
|
ImportedRedactionEntryService importedRedactionEntryService;
|
||||||
ObservedStorageService observedStorageService;
|
ObservedStorageService observedStorageService;
|
||||||
FunctionTimerValues redactmanagerAnalyzePagewiseValues;
|
FunctionTimerValues redactmanagerAnalyzePagewiseValues;
|
||||||
|
ImportedLegalBasisMapper importedLegalBasisMapper = ImportedLegalBasisMapper.INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
@Timed("redactmanager_reanalyze")
|
@Timed("redactmanager_reanalyze")
|
||||||
@ -245,10 +248,9 @@ public class AnalyzeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Timed("redactmanager_analyzeImportedRedactionsOnly")
|
@Timed("redactmanager_analyzeImportedRedactionsOnly")
|
||||||
@Observed(name = "AnalyzeService", contextualName = "analyzeImportedRedactionsOnly")
|
@Observed(name = "AnalyzeService", contextualName = "analyzeImportedRedactionsOnly")
|
||||||
public AnalyzeResult analyzeImportedRedactionsOnly(AnalyzeRequest analyzeRequest){
|
public AnalyzeResult analyzeImportedRedactionsOnly(AnalyzeRequest analyzeRequest) {
|
||||||
|
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@ -260,30 +262,25 @@ public class AnalyzeService {
|
|||||||
ImportedRedactions importedRedactions = redactionStorageService.getImportedRedactions(analyzeRequest.getDossierId(), analyzeRequest.getFileId());
|
ImportedRedactions importedRedactions = redactionStorageService.getImportedRedactions(analyzeRequest.getDossierId(), analyzeRequest.getFileId());
|
||||||
log.info("Loaded Imported Redactions for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
|
log.info("Loaded Imported Redactions for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
|
||||||
|
|
||||||
|
ImportedLegalBases importedLegalBases = redactionStorageService.getImportedLegalBases(analyzeRequest.getDossierId(), analyzeRequest.getFileId());
|
||||||
|
log.info("Loaded Imported Legal Bases for file {} in dossier {}", analyzeRequest.getFileId(), analyzeRequest.getDossierId());
|
||||||
|
|
||||||
var notFoundImportedEntries = importedRedactionEntryService.addImportedEntriesAndReturnNotFoundEntries(analyzeRequest, importedRedactions, document);
|
var notFoundImportedEntries = importedRedactionEntryService.addImportedEntriesAndReturnNotFoundEntries(analyzeRequest, importedRedactions, document);
|
||||||
|
|
||||||
|
EntityLogChanges entityLogChanges = entityLogCreatorService.createInitialEntityLog(analyzeRequest, document, notFoundImportedEntries, new DictionaryVersion(0, 0), 0);
|
||||||
|
|
||||||
EntityLogChanges entityLogChanges = entityLogCreatorService.createInitialEntityLog(analyzeRequest,
|
entityLogChanges.getEntityLog()
|
||||||
document,
|
.setLegalBasis(importedLegalBases.getImportedLegalBases()
|
||||||
notFoundImportedEntries,
|
.stream()
|
||||||
new DictionaryVersion(0,0),
|
.map(importedLegalBasisMapper::toEntityLogLegalBasis)
|
||||||
0);
|
.toList());
|
||||||
|
|
||||||
notFoundImportedEntitiesService.processEntityLog(entityLogChanges.getEntityLog(), analyzeRequest, notFoundImportedEntries);
|
notFoundImportedEntitiesService.processEntityLog(entityLogChanges.getEntityLog(), analyzeRequest, notFoundImportedEntries);
|
||||||
|
|
||||||
return finalizeAnalysis(analyzeRequest,
|
return finalizeAnalysis(analyzeRequest, startTime, KieWrapper.empty(), entityLogChanges, document, document.getNumberOfPages(), false, new HashSet<>());
|
||||||
startTime,
|
|
||||||
KieWrapper.empty(),
|
|
||||||
entityLogChanges,
|
|
||||||
document,
|
|
||||||
document.getNumberOfPages(),
|
|
||||||
false,
|
|
||||||
new HashSet<>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private AnalyzeResult finalizeAnalysis(AnalyzeRequest analyzeRequest,
|
private AnalyzeResult finalizeAnalysis(AnalyzeRequest analyzeRequest,
|
||||||
long startTime,
|
long startTime,
|
||||||
KieWrapper kieWrapperComponentRules,
|
KieWrapper kieWrapperComponentRules,
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.BaseAnnotation;
|
||||||
@ -127,11 +128,13 @@ public class EntityFromPrecursorCreationService {
|
|||||||
precursorEntity.getEntityType(),
|
precursorEntity.getEntityType(),
|
||||||
closestEntity.getDeepestFullyContainingNode());
|
closestEntity.getDeepestFullyContainingNode());
|
||||||
} else {
|
} else {
|
||||||
correctEntity = TextEntity.initialEntityNode(closestEntity.getTextRange(),
|
String section = precursorEntity.getManualOverwrite().getSection()
|
||||||
precursorEntity.type(),
|
.orElse(null);
|
||||||
precursorEntity.getEntityType(),
|
if (section != null && precursorEntity.getEngines().contains(Engine.IMPORTED) && section.isBlank() && !precursorEntity.getSection().isBlank()) {
|
||||||
precursorEntity.getId(),
|
section = precursorEntity.getSection();
|
||||||
precursorEntity.getManualOverwrite().getSection().orElse(null));
|
}
|
||||||
|
|
||||||
|
correctEntity = TextEntity.initialEntityNode(closestEntity.getTextRange(), precursorEntity.type(), precursorEntity.getEntityType(), precursorEntity.getId(), section);
|
||||||
}
|
}
|
||||||
correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode());
|
correctEntity.setDeepestFullyContainingNode(closestEntity.getDeepestFullyContainingNode());
|
||||||
correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes()));
|
correctEntity.setIntersectingNodes(new ArrayList<>(closestEntity.getIntersectingNodes()));
|
||||||
|
|||||||
@ -9,10 +9,12 @@ import java.util.Set;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.componentlog.ComponentLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.EntityLogEntry;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedLegalBases;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactions;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactionsPerPage;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.imported.ImportedRedactionsPerPage;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
|
||||||
@ -147,6 +149,21 @@ public class RedactionStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Timed("redactmanager_getImportedLegalBases")
|
||||||
|
public ImportedLegalBases getImportedLegalBases(String dossierId, String fileId) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return storageService.readJSONObject(TenantContext.getTenantId(),
|
||||||
|
StorageIdUtils.getStorageId(dossierId, fileId, FileType.IMPORTED_LEGAL_BASES),
|
||||||
|
ImportedLegalBases.class);
|
||||||
|
} catch (StorageObjectDoesNotExist e) {
|
||||||
|
log.debug("Imported legal bases not available.");
|
||||||
|
return new ImportedLegalBases();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
@Timed("redactmanager_getRedactionLog")
|
@Timed("redactmanager_getRedactionLog")
|
||||||
public RedactionLog getRedactionLog(String dossierId, String fileId) {
|
public RedactionLog getRedactionLog(String dossierId, String fileId) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user