RED-7317: Endpoint to change entity types of dict-based annotations

* fixed tests
This commit is contained in:
Kilian Schuettler 2023-08-30 14:51:50 +02:00
parent ea5f79d67c
commit d25b8c3934
2 changed files with 31 additions and 18 deletions

View File

@ -57,23 +57,37 @@ public class ManualRedactionDictionaryUpdateHandler {
} }
Set<String> typeIdsOfModifiedDictionaries = new HashSet<>(); Set<String> typeIdsOfModifiedDictionaries = new HashSet<>();
if (manualRequestWithAddToDictionary.isAddToAllDossiers()) { if (manualRequestWithAddToDictionary.isAddToAllDossiers()) {
List<DictionaryEntry> dictionaryEntriesToUnDelete = dictionaryManagementService.getAllEntriesInDossierTemplate(manualRequestWithAddToDictionary.getDossierTemplateTypeId(), return addToDossierTemplateDictionary(fileId, value, manualRequestWithAddToDictionary, typeIdsOfModifiedDictionaries);
value);
dictionaryEntriesToUnDelete.forEach(entry -> {
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
addToDictionary(entry.getTypeId(),
value,
manualRequestWithAddToDictionary.getDossierId(),
fileId,
manualRequestWithAddToDictionary.getDictionaryEntryType());
});
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId(),
value,
manualRequestWithAddToDictionary.getDossierId(),
fileId,
manualRequestWithAddToDictionary.getDictionaryEntryType());
typeIdsOfModifiedDictionaries.add(manualRequestWithAddToDictionary.getDossierTemplateTypeId());
} }
return addToDossierDictionary(fileId, value, manualRequestWithAddToDictionary, typeIdsOfModifiedDictionaries);
}
private Set<String> addToDossierTemplateDictionary(String fileId, String value, ManualRequestWithAddToDictionary manualRequestWithAddToDictionary, Set<String> typeIdsOfModifiedDictionaries) {
List<DictionaryEntry> dictionaryEntriesToUnDelete = dictionaryManagementService.getAllEntriesInDossierTemplate(manualRequestWithAddToDictionary.getDossierTemplateTypeId(),
value);
dictionaryEntriesToUnDelete.forEach(entry -> {
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
addToDictionary(entry.getTypeId(), value,
manualRequestWithAddToDictionary.getDossierId(), fileId,
manualRequestWithAddToDictionary.getDictionaryEntryType());
});
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId(), value,
manualRequestWithAddToDictionary.getDossierId(), fileId,
manualRequestWithAddToDictionary.getDictionaryEntryType());
typeIdsOfModifiedDictionaries.add(manualRequestWithAddToDictionary.getDossierTemplateTypeId());
return typeIdsOfModifiedDictionaries;
}
private Set<String> addToDossierDictionary(String fileId,
String value,
ManualRequestWithAddToDictionary manualRequestWithAddToDictionary,
Set<String> typeIdsOfModifiedDictionaries) {
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId() + ":" + manualRequestWithAddToDictionary.getDossierId(), addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId() + ":" + manualRequestWithAddToDictionary.getDossierId(),
value, value,
manualRequestWithAddToDictionary.getDossierId(), manualRequestWithAddToDictionary.getDossierId(),
@ -83,7 +97,6 @@ public class ManualRedactionDictionaryUpdateHandler {
return typeIdsOfModifiedDictionaries; return typeIdsOfModifiedDictionaries;
} }
public Set<String> handleRemoveFromDictionaryAndReturnModifiedTypeIds(RedactionLogEntry redactionLogEntry, public Set<String> handleRemoveFromDictionaryAndReturnModifiedTypeIds(RedactionLogEntry redactionLogEntry,
String fileId, String fileId,
String dossierId, String dossierId,

View File

@ -1005,7 +1005,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
dossierTemplateDictionary2 = dictionaryClient.getDictionaryForType(type2.getType(), type.getDossierTemplateId(), null); dossierTemplateDictionary2 = dictionaryClient.getDictionaryForType(type2.getType(), type.getDossierTemplateId(), null);
assertThat(dossierTemplateDictionary2.getEntries()).containsExactlyInAnyOrder(lukeSkywalker); assertThat(dossierTemplateDictionary2.getEntries()).containsExactlyInAnyOrder(lukeSkywalker);
dossierDictionary2 = dictionaryClient.getDictionaryForType(type2.getType(), type.getDossierTemplateId(), dossier.getDossierId()); dossierDictionary2 = dictionaryClient.getDictionaryForType(type2.getType(), type.getDossierTemplateId(), dossier.getDossierId());
assertThat(dossierDictionary2.getEntries()).containsExactlyInAnyOrder(lukeSkywalker); assertThat(dossierDictionary2.getEntries()).isEmpty();
manualRedactionClient.undo(dossier.getDossierId(), file.getFileId(), Set.of(annotationId)); manualRedactionClient.undo(dossier.getDossierId(), file.getFileId(), Set.of(annotationId));