Merge branch 'RED-9123' into 'master'

RED-9123: Improve performance of re-analysis (Spike)

Closes RED-9123

See merge request redactmanager/persistence-service!571
This commit is contained in:
Maverick Studer 2024-07-02 10:56:44 +02:00
commit a8a9232c4c
2 changed files with 27 additions and 5 deletions

View File

@ -32,17 +32,39 @@ public class DictionaryInternalController implements DictionaryResource {
@Override
public List<Type> getAllTypesForDossierTemplate(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
@RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion,
@RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted) {
return convert(dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId, includeDeleted), Type.class);
var targets = convert(dictionaryPersistenceService.getAllTypesForDossierTemplate(dossierTemplateId, includeDeleted), Type.class);
setEntriesForTypes(fromVersion, targets);
return targets;
}
@Override
public List<Type> getAllTypesForDossier(@PathVariable(DOSSIER_ID_PARAMETER_NAME) String dossierId,
@RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion,
@RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted) {
return convert(dictionaryPersistenceService.getAllTypesForDossier(dossierId, includeDeleted), Type.class);
var targets = convert(dictionaryPersistenceService.getAllTypesForDossier(dossierId, includeDeleted), Type.class);
setEntriesForTypes(fromVersion, targets);
return targets;
}
private void setEntriesForTypes(Long fromVersion, List<Type> targets) {
targets.forEach(target -> {
setEntriesForType(target.getTypeId(), target, fromVersion != null ? fromVersion : -1);
});
}
private void setEntriesForType(String typeId, Type target, Long fromVersion) {
target.setEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, fromVersion), DictionaryEntry.class));
target.setFalsePositiveEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, fromVersion), DictionaryEntry.class));
target.setFalseRecommendationEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, fromVersion), DictionaryEntry.class));
}
@ -51,9 +73,7 @@ public class DictionaryInternalController implements DictionaryResource {
var entity = dictionaryPersistenceService.getType(typeId, true);
var target = convert(entity, Type.class);
target.setEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, fromVersion), DictionaryEntry.class));
target.setFalsePositiveEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, fromVersion), DictionaryEntry.class));
target.setFalseRecommendationEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, fromVersion), DictionaryEntry.class));
setEntriesForType(typeId, target, fromVersion);
return target;
}

View File

@ -38,11 +38,13 @@ public interface DictionaryResource {
@GetMapping(value = InternalApi.BASE_PATH + TYPE_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
List<Type> getAllTypesForDossierTemplate(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
@RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion,
@RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted);
@GetMapping(value = InternalApi.BASE_PATH + TYPE_PATH + DOSSIER_PATH + DOSSIER_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
List<Type> getAllTypesForDossier(@PathVariable(DOSSIER_ID_PARAMETER_NAME) String dossierId,
@RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion,
@RequestParam(value = INCLUDE_DELETED_PARAMETER_NAME, required = false, defaultValue = "false") boolean includeDeleted);