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