RED-7034 - Check for dossierDictionaryOnly flag when add to template dict is requested
- update after review
This commit is contained in:
parent
8860e9d040
commit
9b2ea9dfc4
@ -88,7 +88,7 @@ public class ManualRedactionService {
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final RedactionLogService redactionLogService;
|
||||
private final DictionaryManagementService dictionaryService;
|
||||
private final DictionaryManagementService dictionaryManagementService;
|
||||
private final HashFunction hashFunction = Hashing.murmur3_128();
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ public class ManualRedactionService {
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var actionPerformed = false;
|
||||
// validate add to dossier template dictionaries
|
||||
addRedactionRequests.forEach(request -> dictionaryService.validateAddRemoveToDossierTemplateDictionary(request.getDossierTemplateTypeId(), request.isAddToDictionary(), request.isAddToAllDossiers()));
|
||||
addRedactionRequests.forEach(request -> dictionaryManagementService.validateAddRemoveToDossierTemplateDictionary(request.getDossierTemplateTypeId(), request.isAddToDictionary(), request.isAddToAllDossiers()));
|
||||
|
||||
for (var addRedactionRequest : addRedactionRequests) {
|
||||
if (addRedactionRequest.isAddToDictionary()) {
|
||||
@ -209,7 +209,7 @@ public class ManualRedactionService {
|
||||
});
|
||||
} else {
|
||||
if (addToAllDossiers) {
|
||||
var dictionaryEntriesToUnDelete = dictionaryService.getAllEntriesInDossierTemplate(dossierTemplateTypeId, value);
|
||||
var dictionaryEntriesToUnDelete = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplateTypeId, value);
|
||||
dictionaryEntriesToUnDelete.forEach(entry -> {
|
||||
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
||||
addToDictionary(entry.getTypeId(), value, dossierId, fileId, dictionaryEntryType);
|
||||
@ -260,7 +260,7 @@ public class ManualRedactionService {
|
||||
|
||||
try {
|
||||
log.debug("Deleting entries to {} for {} / {}", typeId, dossierId, fileId);
|
||||
dictionaryService.deleteEntries(typeId, List.of(value), dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
||||
dictionaryManagementService.deleteEntries(typeId, List.of(value), dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
||||
} catch (FeignException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
@ -271,7 +271,7 @@ public class ManualRedactionService {
|
||||
|
||||
try {
|
||||
log.debug("Adding entry: {} to {} for {} / {}", value, typeId, dossierId, fileId);
|
||||
dictionaryService.addEntries(typeId, List.of(value), false, false, dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
||||
dictionaryManagementService.addEntries(typeId, List.of(value), false, false, dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
@ -294,7 +294,7 @@ public class ManualRedactionService {
|
||||
if (request.isRemoveFromDictionary()) {
|
||||
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, request.getAnnotationId());
|
||||
var dossierTemplateTypeId = toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId());
|
||||
dictionaryService.validateAddRemoveToDossierTemplateDictionary(dossierTemplateTypeId, request.isRemoveFromDictionary(), request.isRemoveFromAllDossiers());
|
||||
dictionaryManagementService.validateAddRemoveToDossierTemplateDictionary(dossierTemplateTypeId, request.isRemoveFromDictionary(), request.isRemoveFromAllDossiers());
|
||||
}
|
||||
});
|
||||
|
||||
@ -318,7 +318,14 @@ public class ManualRedactionService {
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(removeRedactionRequest.getAnnotationId()))
|
||||
.findFirst();
|
||||
var requiresAnalysis = redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
|
||||
RedactionLogEntry redactionLogEntry = null;
|
||||
boolean requiresAnalysis = false;
|
||||
try {
|
||||
redactionLogEntry = getRedactionLogEntry(redactionLog, removeRedactionRequest.getAnnotationId());
|
||||
requiresAnalysis = redactionLogEntry.isHint();
|
||||
} catch (NotFoundException e) {
|
||||
|
||||
}
|
||||
actionPerformed = actionPerformed || requiresAnalysis;
|
||||
if (!requiresAnalysis && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
@ -384,7 +391,7 @@ public class ManualRedactionService {
|
||||
});
|
||||
} else {
|
||||
if (removeFromAllDossiers) {
|
||||
var dictionaryEntriesToRemove = dictionaryService.getAllEntriesInDossierTemplate(toTypeId(redactionLogEntry.getType(),dossier.getDossierTemplateId()),
|
||||
var dictionaryEntriesToRemove = dictionaryManagementService.getAllEntriesInDossierTemplate(toTypeId(redactionLogEntry.getType(),dossier.getDossierTemplateId()),
|
||||
redactionLogEntry.getValue());
|
||||
dictionaryEntriesToRemove.forEach(entry -> {
|
||||
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
||||
@ -715,17 +722,13 @@ public class ManualRedactionService {
|
||||
|
||||
private void updateDictionaryForResizeRedactions(String dossierId, String fileId, ManualResizeRedactionEntity resizeRedaction, RedactionLog redactionLog) {
|
||||
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(r -> r.getId().equals(resizeRedaction.getId().getAnnotationId()))
|
||||
.findFirst();
|
||||
|
||||
if (redactionLogEntryOptional.isEmpty()) {
|
||||
RedactionLogEntry redactionLogEntry = null;
|
||||
try {
|
||||
redactionLogEntry = getRedactionLogEntry(redactionLog, resizeRedaction.getId().getAnnotationId());
|
||||
} catch (NotFoundException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (resizeRedaction.getUpdateDictionary() != null && resizeRedaction.getUpdateDictionary() && resizeRedaction.getStatus()
|
||||
.equals(AnnotationStatus.APPROVED) && (redactionLogEntry.isDictionaryEntry() || redactionLogEntry.isDossierDictionaryEntry())) {
|
||||
var dossier = dossierPersistenceService.findByDossierId(dossierId);
|
||||
@ -768,19 +771,10 @@ public class ManualRedactionService {
|
||||
for (var annotationId : annotationIds) {
|
||||
var idRemoval = MagicConverter.convert(removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId), IdRemoval.class);
|
||||
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getAnnotationId()))
|
||||
.findFirst();
|
||||
|
||||
if (redactionLogEntryOptional.isEmpty()) {
|
||||
throw new NotFoundException("Annotation does not exist in redaction log.");
|
||||
}
|
||||
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, idRemoval.getAnnotationId());
|
||||
|
||||
if (idRemoval.isRemoveFromDictionary()) {
|
||||
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY);
|
||||
approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue());
|
||||
@ -794,7 +788,7 @@ public class ManualRedactionService {
|
||||
|
||||
}
|
||||
}
|
||||
} else if (redactionLogEntryOptional.get().isHint()) {
|
||||
} else if (redactionLogEntry.isHint()) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user