RED-7317: Endpoint to change entity types of dict-based annotations #102
@ -5,13 +5,10 @@ import static com.iqser.red.service.persistence.management.v1.processor.roles.Ac
|
|||||||
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DELETE_MANUAL_REDACTION;
|
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DELETE_MANUAL_REDACTION;
|
||||||
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DO_MANUAL_REDACTION;
|
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.DO_MANUAL_REDACTION;
|
||||||
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.READ_MANUAL_REDACTIONS;
|
import static com.iqser.red.service.persistence.management.v1.processor.roles.ActionRoles.READ_MANUAL_REDACTIONS;
|
||||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@ -19,8 +16,9 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.AccessControlService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.DossierManagementService;
|
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.CommentService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.CommentService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.DossierManagementService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.manualredactions.ManualRedactionMapper;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.manualredactions.ManualRedactionService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.manualredactions.ManualRedactionService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.manualredactions.ManualRedactionUndoService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.manualredactions.ManualRedactionUndoService;
|
||||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.AuditPersistenceService;
|
||||||
@ -28,14 +26,16 @@ import com.iqser.red.service.persistence.service.v1.api.external.resource.Manual
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.AuditCategory;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.AuditCategory;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.CommentResponse;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.CommentResponse;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.CommentRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.CommentRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.Comments;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.Comments;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualAddResponse;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualAddResponse;
|
||||||
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.RecategorizationRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RecategorizationRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.audit.AuditRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.audit.AuditRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddCommentRequestModel;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddCommentRequestModel;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequestModel;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequestModel;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequestModel;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequestModel;
|
||||||
@ -64,6 +64,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
DossierManagementService dossierManagementService;
|
DossierManagementService dossierManagementService;
|
||||||
AuditPersistenceService auditPersistenceService;
|
AuditPersistenceService auditPersistenceService;
|
||||||
AccessControlService accessControlService;
|
AccessControlService accessControlService;
|
||||||
|
ManualRedactionMapper manualRedactionMapper;
|
||||||
CommentService commentService;
|
CommentService commentService;
|
||||||
|
|
||||||
|
|
||||||
@ -158,26 +159,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AddRedactionRequest> requests = addRedactionRequests.stream()
|
List<AddRedactionRequest> requests = manualRedactionMapper.toAddRedactionRequestList(dossierId, addRedactionRequests, dossier);
|
||||||
.map(addRedactionRequest -> AddRedactionRequest.builder()
|
|
||||||
.value(addRedactionRequest.getValue())
|
|
||||||
.legalBasis(addRedactionRequest.getLegalBasis())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.dossierTemplateTypeId(toTypeId(addRedactionRequest.getType(), dossier.getDossierTemplateId()))
|
|
||||||
.reason(addRedactionRequest.getReason())
|
|
||||||
.addToDictionary(addRedactionRequest.isAddToDictionary())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.comment(addRedactionRequest.getComment() != null ? addRedactionRequest.getComment().getText() : null)
|
|
||||||
.section(addRedactionRequest.getSection())
|
|
||||||
.rectangle(addRedactionRequest.isRectangle())
|
|
||||||
.addToAllDossiers(addRedactionRequest.isAddToAllDossiers())
|
|
||||||
.forceAddToDictionary(addRedactionRequest.isForceAddToDictionary())
|
|
||||||
.positions(addRedactionRequest.getPositions())
|
|
||||||
.sourceId(addRedactionRequest.getSourceId())
|
|
||||||
.dossierId(dossierId)
|
|
||||||
.dictionaryEntryType(addRedactionRequest.getDictionaryEntryType())
|
|
||||||
.build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addAddRedaction(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addAddRedaction(dossierId, fileId, requests);
|
||||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||||
@ -196,6 +178,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
@RequestBody Set<RemoveRedactionRequestModel> removeRedactionRequests) {
|
@RequestBody Set<RemoveRedactionRequestModel> removeRedactionRequests) {
|
||||||
|
|
||||||
|
var dossier = dossierManagementService.getDossierById(dossierId, false, false);
|
||||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||||
if (removeRedactionRequests.stream().anyMatch(RemoveRedactionRequestModel::isRemoveFromAllDossiers)) {
|
if (removeRedactionRequests.stream().anyMatch(RemoveRedactionRequestModel::isRemoveFromAllDossiers)) {
|
||||||
accessControlService.verifyUserIsApprover(dossierId);
|
accessControlService.verifyUserIsApprover(dossierId);
|
||||||
@ -203,22 +186,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest> requests = new ArrayList<>();
|
List<RemoveRedactionRequest> requests = manualRedactionMapper.toRemoveRedactionRequestList(dossierId, fileId, dossier.getDossierTemplateId(), removeRedactionRequests);
|
||||||
|
|
||||||
for (var removeRedactionRequest : removeRedactionRequests) {
|
|
||||||
var removeRedactionRequestBuilder = com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest.builder()
|
|
||||||
.annotationId(removeRedactionRequest.getAnnotationId())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.removeFromDictionary(removeRedactionRequest.isRemoveFromDictionary())
|
|
||||||
.removeFromAllDossiers(removeRedactionRequest.isRemoveFromAllDossiers());
|
|
||||||
|
|
||||||
if (removeRedactionRequest.getComment() != null) {
|
|
||||||
removeRedactionRequestBuilder.comment(removeRedactionRequest.getComment());
|
|
||||||
}
|
|
||||||
|
|
||||||
requests.add(removeRedactionRequestBuilder.build());
|
|
||||||
}
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addRemoveRedaction(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addRemoveRedaction(dossierId, fileId, requests);
|
||||||
|
|
||||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||||
@ -241,15 +209,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
|
|
||||||
List<com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest> requests = forceRedactionRequests.stream()
|
List<ForceRedactionRequest> requests = manualRedactionMapper.toForceRedactionRequestList(forceRedactionRequests);
|
||||||
.map(forceRedactionRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest.builder()
|
|
||||||
.annotationId(forceRedactionRequest.getAnnotationId())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.legalBasis(forceRedactionRequest.getLegalBasis())
|
|
||||||
.comment(forceRedactionRequest.getComment())
|
|
||||||
.build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addForceRedaction(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addForceRedaction(dossierId, fileId, requests);
|
||||||
|
|
||||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||||
@ -272,17 +232,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
|
|
||||||
List<com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest> requests = legalBasisChangeRequests.stream()
|
List<LegalBasisChangeRequest> requests = manualRedactionMapper.toLegalBasisChangeRequestList(legalBasisChangeRequests);
|
||||||
.map(legalBasisChangeRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest.builder()
|
|
||||||
.annotationId(legalBasisChangeRequest.getAnnotationId())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.section(legalBasisChangeRequest.getSection())
|
|
||||||
.legalBasis(legalBasisChangeRequest.getLegalBasis())
|
|
||||||
.comment(legalBasisChangeRequest.getComment())
|
|
||||||
.value(legalBasisChangeRequest.getValue())
|
|
||||||
.build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addLegalBasisChange(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addLegalBasisChange(dossierId, fileId, requests);
|
||||||
|
|
||||||
@ -307,19 +257,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
|
|
||||||
List<RecategorizationRequest> requests = recategorizationRequests.stream()
|
List<RecategorizationRequest> requests = manualRedactionMapper.toRecategorizationRequestList(dossierId, fileId, dossier.getDossierTemplateId(), recategorizationRequests);
|
||||||
.map(recategorizationRequest -> RecategorizationRequest.builder()
|
|
||||||
.annotationId(recategorizationRequest.getAnnotationId())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.dossierTemplateTypeId(toTypeId(recategorizationRequest.getType(), dossier.getDossierTemplateId()))
|
|
||||||
.comment(recategorizationRequest.getComment())
|
|
||||||
.dossierId(dossierId)
|
|
||||||
.addToDictionary(recategorizationRequest.isAddToDictionary())
|
|
||||||
.addToAllDossiers(recategorizationRequest.isAddToAllDossiers())
|
|
||||||
.dictionaryEntryType(DictionaryEntryType.ENTRY)
|
|
||||||
.build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addRecategorization(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addRecategorization(dossierId, fileId, requests);
|
||||||
|
|
||||||
@ -343,19 +281,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
|||||||
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
accessControlService.verifyFileIsNotApproved(dossierId, fileId);
|
||||||
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
accessControlService.verifyUserIsMemberOrApprover(dossierId);
|
||||||
|
|
||||||
List<com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest> requests = resizeRedactionRequests.stream()
|
List<ResizeRedactionRequest> requests = manualRedactionMapper.toResizeRedactionRequestList(resizeRedactionRequests);
|
||||||
.map(resizeRedactionRequest -> com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest.builder()
|
|
||||||
.annotationId(resizeRedactionRequest.getAnnotationId())
|
|
||||||
.user(KeycloakSecurity.getUserId())
|
|
||||||
.status(AnnotationStatus.APPROVED)
|
|
||||||
.positions(resizeRedactionRequest.getPositions())
|
|
||||||
.value(resizeRedactionRequest.getValue())
|
|
||||||
.comment(resizeRedactionRequest.getComment())
|
|
||||||
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
|
|
||||||
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
|
|
||||||
.build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
List<ManualAddResponse> responseList = manualRedactionService.addResizeRedaction(dossierId, fileId, requests);
|
List<ManualAddResponse> responseList = manualRedactionService.addResizeRedaction(dossierId, fileId, requests);
|
||||||
|
|
||||||
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
responseList.forEach(response -> auditPersistenceService.audit(AuditRequest.builder()
|
||||||
|
|||||||
@ -41,8 +41,6 @@ public class RedactionLogService {
|
|||||||
redactionLog.setRedactionLogEntry(new ArrayList<>());
|
redactionLog.setRedactionLogEntry(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileStatus.isHasUpdates())
|
|
||||||
|
|
||||||
if (excludedTypes != null) {
|
if (excludedTypes != null) {
|
||||||
redactionLog.getRedactionLogEntry().removeIf(nextEntry -> excludedTypes.contains(nextEntry.getType()));
|
redactionLog.getRedactionLogEntry().removeIf(nextEntry -> excludedTypes.contains(nextEntry.getType()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,20 +63,22 @@ public class ManualRedactionDictionaryUpdateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private Set<String> addToDossierTemplateDictionary(String fileId,
|
||||||
|
String value,
|
||||||
private Set<String> addToDossierTemplateDictionary(String fileId, String value, ManualRequestWithAddToDictionary manualRequestWithAddToDictionary, Set<String> typeIdsOfModifiedDictionaries) {
|
ManualRequestWithAddToDictionary manualRequestWithAddToDictionary,
|
||||||
|
Set<String> typeIdsOfModifiedDictionaries) {
|
||||||
|
|
||||||
List<DictionaryEntry> dictionaryEntriesToUnDelete = dictionaryManagementService.getAllEntriesInDossierTemplate(manualRequestWithAddToDictionary.getDossierTemplateTypeId(),
|
List<DictionaryEntry> dictionaryEntriesToUnDelete = dictionaryManagementService.getAllEntriesInDossierTemplate(manualRequestWithAddToDictionary.getDossierTemplateTypeId(),
|
||||||
value, manualRequestWithAddToDictionary.getDictionaryEntryType());
|
value,
|
||||||
|
manualRequestWithAddToDictionary.getDictionaryEntryType());
|
||||||
dictionaryEntriesToUnDelete.forEach(entry -> {
|
dictionaryEntriesToUnDelete.forEach(entry -> {
|
||||||
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
||||||
addToDictionary(entry.getTypeId(), value,
|
addToDictionary(entry.getTypeId(), value, manualRequestWithAddToDictionary.getDossierId(), fileId, manualRequestWithAddToDictionary.getDictionaryEntryType());
|
||||||
manualRequestWithAddToDictionary.getDossierId(), fileId,
|
|
||||||
manualRequestWithAddToDictionary.getDictionaryEntryType());
|
|
||||||
});
|
});
|
||||||
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId(), value,
|
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId(),
|
||||||
manualRequestWithAddToDictionary.getDossierId(), fileId,
|
value,
|
||||||
|
manualRequestWithAddToDictionary.getDossierId(),
|
||||||
|
fileId,
|
||||||
manualRequestWithAddToDictionary.getDictionaryEntryType());
|
manualRequestWithAddToDictionary.getDictionaryEntryType());
|
||||||
typeIdsOfModifiedDictionaries.add(manualRequestWithAddToDictionary.getDossierTemplateTypeId());
|
typeIdsOfModifiedDictionaries.add(manualRequestWithAddToDictionary.getDossierTemplateTypeId());
|
||||||
return typeIdsOfModifiedDictionaries;
|
return typeIdsOfModifiedDictionaries;
|
||||||
@ -88,41 +90,46 @@ public class ManualRedactionDictionaryUpdateHandler {
|
|||||||
ManualRequestWithAddToDictionary manualRequestWithAddToDictionary,
|
ManualRequestWithAddToDictionary manualRequestWithAddToDictionary,
|
||||||
Set<String> typeIdsOfModifiedDictionaries) {
|
Set<String> typeIdsOfModifiedDictionaries) {
|
||||||
|
|
||||||
addToDictionary(manualRequestWithAddToDictionary.getDossierTemplateTypeId() + ":" + manualRequestWithAddToDictionary.getDossierId(),
|
String dossierDictionaryTypeId = manualRequestWithAddToDictionary.getDossierTemplateTypeId() + ":" + manualRequestWithAddToDictionary.getDossierId();
|
||||||
value,
|
addToDictionary(dossierDictionaryTypeId, value, manualRequestWithAddToDictionary.getDossierId(), fileId, manualRequestWithAddToDictionary.getDictionaryEntryType());
|
||||||
manualRequestWithAddToDictionary.getDossierId(),
|
typeIdsOfModifiedDictionaries.add(dossierDictionaryTypeId);
|
||||||
fileId,
|
|
||||||
manualRequestWithAddToDictionary.getDictionaryEntryType());
|
|
||||||
typeIdsOfModifiedDictionaries.add(manualRequestWithAddToDictionary.getDossierTemplateTypeId() + ":" + manualRequestWithAddToDictionary.getDossierId());
|
|
||||||
return typeIdsOfModifiedDictionaries;
|
return typeIdsOfModifiedDictionaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> handleRemoveFromDictionaryAndReturnModifiedTypeIds(RedactionLogEntry redactionLogEntry,
|
|
||||||
String fileId,
|
public Set<String> handleRemoveFromDictionaryAndReturnModifiedTypeIds(String fileId, ManualRequestWithRemoveFromDictionary manualRequestWithRemoveFromDictionary) {
|
||||||
String dossierId,
|
|
||||||
String dossierTemplateId,
|
|
||||||
ManualRequestWithRemoveFromDictionary manualRequestWithRemoveFromDictionary) {
|
|
||||||
|
|
||||||
if (!manualRequestWithRemoveFromDictionary.isRemoveFromDictionary()) {
|
if (!manualRequestWithRemoveFromDictionary.isRemoveFromDictionary()) {
|
||||||
|
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
String dossierId = manualRequestWithRemoveFromDictionary.getDossierId();
|
||||||
|
String dossierTemplateId = manualRequestWithRemoveFromDictionary.getDossierTemplateId();
|
||||||
|
|
||||||
|
DictionaryEntryType dictionaryEntryType = manualRequestWithRemoveFromDictionary.getDictionaryEntryType();
|
||||||
Set<String> typeIdsOfModifiedDictionaries = new HashSet<>();
|
Set<String> typeIdsOfModifiedDictionaries = new HashSet<>();
|
||||||
|
String dossierTemplateDictionaryTypeId = toTypeId(manualRequestWithRemoveFromDictionary.getTypeToRemove(), manualRequestWithRemoveFromDictionary.getDossierTemplateId());
|
||||||
|
String dossierDictionaryTypeId = toTypeId(manualRequestWithRemoveFromDictionary.getTypeToRemove(),
|
||||||
|
manualRequestWithRemoveFromDictionary.getDossierTemplateId(),
|
||||||
|
manualRequestWithRemoveFromDictionary.getDossierId());
|
||||||
|
|
||||||
if (manualRequestWithRemoveFromDictionary.isRemoveFromAllDossiers()) {
|
if (manualRequestWithRemoveFromDictionary.isRemoveFromAllDossiers()) {
|
||||||
var dictionaryEntriesToRemove = dictionaryManagementService.getAllEntriesInDossierTemplate(toTypeId(redactionLogEntry.getType(), dossierTemplateId),
|
|
||||||
redactionLogEntry.getValue(), getDictionaryEntryType(redactionLogEntry));
|
var dictionaryEntriesToRemove = dictionaryManagementService.getAllEntriesInDossierTemplate(dossierTemplateDictionaryTypeId,
|
||||||
|
manualRequestWithRemoveFromDictionary.getValue(),
|
||||||
|
dictionaryEntryType);
|
||||||
|
|
||||||
dictionaryEntriesToRemove.forEach(entry -> {
|
dictionaryEntriesToRemove.forEach(entry -> {
|
||||||
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
typeIdsOfModifiedDictionaries.add(entry.getTypeId());
|
||||||
removeFromDictionary(entry.getTypeId(), entry.getValue(), dossierId, fileId, getDictionaryEntryType(redactionLogEntry));
|
removeFromDictionary(entry.getTypeId(), entry.getValue(), dossierId, fileId, dictionaryEntryType);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
typeIdsOfModifiedDictionaries.add(toTypeId(redactionLogEntry.getType(), dossierTemplateId, dossierId));
|
|
||||||
removeFromDictionary(toTypeId(redactionLogEntry.getType(), dossierTemplateId, dossierId), redactionLogEntry.getValue(), dossierId, fileId, getDictionaryEntryType(redactionLogEntry));
|
removeFromDictionary(dossierDictionaryTypeId, manualRequestWithRemoveFromDictionary.getValue(), dossierId, fileId, dictionaryEntryType);
|
||||||
|
typeIdsOfModifiedDictionaries.add(dossierDictionaryTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is needed to remove resizeRedactions with addToDictionary.
|
// This is needed to remove resizeRedactions with addToDictionary.
|
||||||
removeResizeRedactionsWithAddToDictionary(dossierTemplateId, redactionLogEntry.getValue());
|
removeResizeRedactionsWithAddToDictionary(dossierTemplateId, manualRequestWithRemoveFromDictionary.getValue());
|
||||||
|
|
||||||
return typeIdsOfModifiedDictionaries;
|
return typeIdsOfModifiedDictionaries;
|
||||||
}
|
}
|
||||||
@ -135,7 +142,7 @@ public class ManualRedactionDictionaryUpdateHandler {
|
|||||||
|
|
||||||
var dossier = dossierPersistenceService.findByDossierId(dossierId);
|
var dossier = dossierPersistenceService.findByDossierId(dossierId);
|
||||||
|
|
||||||
var typeId = buildTypeId(redactionLogEntry, resizeRedaction, dossier);
|
var typeId = buildTypeId(redactionLogEntry.getType(), resizeRedaction, dossier);
|
||||||
var newValue = resizeRedaction.getValue();
|
var newValue = resizeRedaction.getValue();
|
||||||
var oldValue = redactionLogEntry.getValue();
|
var oldValue = redactionLogEntry.getValue();
|
||||||
var dictionaryEntryType = getDictionaryEntryType(redactionLogEntry);
|
var dictionaryEntryType = getDictionaryEntryType(redactionLogEntry);
|
||||||
@ -172,12 +179,12 @@ public class ManualRedactionDictionaryUpdateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String buildTypeId(RedactionLogEntry redactionLogEntry, ManualResizeRedactionEntity resizeRedaction, DossierEntity dossier) {
|
private String buildTypeId(String type, ManualResizeRedactionEntity resizeRedaction, DossierEntity dossier) {
|
||||||
|
|
||||||
if (resizeRedaction.isAddToAllDossiers()) {
|
if (resizeRedaction.isAddToAllDossiers()) {
|
||||||
return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId());
|
return toTypeId(type, dossier.getDossierTemplateId());
|
||||||
} else {
|
} else {
|
||||||
return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId(), dossier.getId());
|
return toTypeId(type, dossier.getDossierTemplateId(), dossier.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -233,10 +240,10 @@ public class ManualRedactionDictionaryUpdateHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void validateDictionariesForDelete(ManualRequestWithRemoveFromDictionary request, RedactionLogEntry redactionLogEntry, String dossierTemplateId) {
|
public void validateDictionariesForDelete(ManualRequestWithRemoveFromDictionary request, String type, String dossierTemplateId) {
|
||||||
|
|
||||||
if (request.isRemoveFromDictionary()) {
|
if (request.isRemoveFromDictionary()) {
|
||||||
var dossierTemplateTypeId = toTypeId(redactionLogEntry.getType(), dossierTemplateId);
|
var dossierTemplateTypeId = toTypeId(type, dossierTemplateId);
|
||||||
dictionaryManagementService.validateAddRemoveToDossierTemplateDictionary(dossierTemplateTypeId, request.isRemoveFromDictionary(), request.isRemoveFromAllDossiers());
|
dictionaryManagementService.validateAddRemoveToDossierTemplateDictionary(dossierTemplateTypeId, request.isRemoveFromDictionary(), request.isRemoveFromAllDossiers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,201 @@
|
|||||||
|
package com.iqser.red.service.persistence.management.v1.processor.service.manualredactions;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.RedactionLogService;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AddRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ForceRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.LegalBasisChangeRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RecategorizationRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.Dossier;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.AddRedactionRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ForceRedactionRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.LegalBasisChangeRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.RecategorizationRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.RemoveRedactionRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.manual.ResizeRedactionRequestModel;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
|
||||||
|
import com.knecon.fforesight.keycloakcommons.security.KeycloakSecurity;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
|
||||||
|
public class ManualRedactionMapper {
|
||||||
|
|
||||||
|
RedactionLogService redactionLogService;
|
||||||
|
|
||||||
|
|
||||||
|
public List<AddRedactionRequest> toAddRedactionRequestList(String dossierId, Set<AddRedactionRequestModel> addRedactionRequests, Dossier dossier) {
|
||||||
|
|
||||||
|
return addRedactionRequests.stream()
|
||||||
|
.map(addRedactionRequest -> toAddRedactionRequest(dossierId, dossier.getDossierTemplateId(), addRedactionRequest))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public AddRedactionRequest toAddRedactionRequest(String dossierId, String dossierTemplateId, AddRedactionRequestModel addRedactionRequest) {
|
||||||
|
|
||||||
|
return AddRedactionRequest.builder()
|
||||||
|
.value(addRedactionRequest.getValue())
|
||||||
|
.legalBasis(addRedactionRequest.getLegalBasis())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.dossierTemplateTypeId(toTypeId(addRedactionRequest.getType(), dossierTemplateId))
|
||||||
|
.reason(addRedactionRequest.getReason())
|
||||||
|
.addToDictionary(addRedactionRequest.isAddToDictionary())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.comment(addRedactionRequest.getComment() != null ? addRedactionRequest.getComment().getText() : null)
|
||||||
|
.section(addRedactionRequest.getSection())
|
||||||
|
.rectangle(addRedactionRequest.isRectangle())
|
||||||
|
.addToAllDossiers(addRedactionRequest.isAddToAllDossiers())
|
||||||
|
.forceAddToDictionary(addRedactionRequest.isForceAddToDictionary())
|
||||||
|
.positions(addRedactionRequest.getPositions())
|
||||||
|
.sourceId(addRedactionRequest.getSourceId())
|
||||||
|
.dossierId(dossierId)
|
||||||
|
.dictionaryEntryType(addRedactionRequest.getDictionaryEntryType())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<RemoveRedactionRequest> toRemoveRedactionRequestList(String dossierId, String fileId, String dossierTemplateId,Set<RemoveRedactionRequestModel> removeRedactionRequests) {
|
||||||
|
|
||||||
|
List<RemoveRedactionRequest> requests = new ArrayList<>();
|
||||||
|
RedactionLog redactionLog = redactionLogService.getRedactionLog(dossierId, fileId);
|
||||||
|
for (var removeRedactionRequest : removeRedactionRequests) {
|
||||||
|
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, removeRedactionRequest.getAnnotationId());
|
||||||
|
var removeRedactionRequestBuilder = RemoveRedactionRequest.builder()
|
||||||
|
.annotationId(removeRedactionRequest.getAnnotationId())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.removeFromDictionary(removeRedactionRequest.isRemoveFromDictionary())
|
||||||
|
.removeFromAllDossiers(removeRedactionRequest.isRemoveFromAllDossiers())
|
||||||
|
.value(redactionLogEntry.getValue())
|
||||||
|
.dictionaryEntryType(getDictionaryEntryType(redactionLogEntry))
|
||||||
|
.typeToRemove(redactionLogEntry.getType())
|
||||||
|
.dossierId(dossierId)
|
||||||
|
.dossierTemplateId(dossierTemplateId);
|
||||||
|
|
||||||
|
if (removeRedactionRequest.getComment() != null) {
|
||||||
|
removeRedactionRequestBuilder.comment(removeRedactionRequest.getComment());
|
||||||
|
}
|
||||||
|
|
||||||
|
requests.add(removeRedactionRequestBuilder.build());
|
||||||
|
}
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<ForceRedactionRequest> toForceRedactionRequestList(Set<ForceRedactionRequestModel> forceRedactionRequests) {
|
||||||
|
|
||||||
|
return forceRedactionRequests.stream()
|
||||||
|
.map(forceRedactionRequest -> ForceRedactionRequest.builder()
|
||||||
|
.annotationId(forceRedactionRequest.getAnnotationId())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.legalBasis(forceRedactionRequest.getLegalBasis())
|
||||||
|
.comment(forceRedactionRequest.getComment())
|
||||||
|
.build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<LegalBasisChangeRequest> toLegalBasisChangeRequestList(Set<LegalBasisChangeRequestModel> legalBasisChangeRequests) {
|
||||||
|
|
||||||
|
return legalBasisChangeRequests.stream()
|
||||||
|
.map(legalBasisChangeRequest -> LegalBasisChangeRequest.builder()
|
||||||
|
.annotationId(legalBasisChangeRequest.getAnnotationId())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.section(legalBasisChangeRequest.getSection())
|
||||||
|
.legalBasis(legalBasisChangeRequest.getLegalBasis())
|
||||||
|
.comment(legalBasisChangeRequest.getComment())
|
||||||
|
.value(legalBasisChangeRequest.getValue())
|
||||||
|
.build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<RecategorizationRequest> toRecategorizationRequestList(String dossierId,
|
||||||
|
String fileId,
|
||||||
|
String dossierTemplateId,
|
||||||
|
Set<RecategorizationRequestModel> recategorizationRequests) {
|
||||||
|
|
||||||
|
RedactionLog redactionLog = redactionLogService.getRedactionLog(dossierId, fileId);
|
||||||
|
List<RecategorizationRequest> requests = new ArrayList<>();
|
||||||
|
for (RecategorizationRequestModel recategorizationRequest : recategorizationRequests) {
|
||||||
|
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, recategorizationRequest.getAnnotationId());
|
||||||
|
RecategorizationRequest build = RecategorizationRequest.builder()
|
||||||
|
.annotationId(recategorizationRequest.getAnnotationId())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.dossierTemplateId(dossierTemplateId)
|
||||||
|
.comment(recategorizationRequest.getComment())
|
||||||
|
.dossierId(dossierId)
|
||||||
|
.addToDictionary(recategorizationRequest.isAddToDictionary())
|
||||||
|
.addToAllDossiers(recategorizationRequest.isAddToAllDossiers())
|
||||||
|
.dictionaryEntryType(getDictionaryEntryType(redactionLogEntry))
|
||||||
|
.value(redactionLogEntry.getValue())
|
||||||
|
.typeToRemove(redactionLogEntry.getType())
|
||||||
|
.dossierTemplateTypeId(toTypeId(recategorizationRequest.getType(), dossierTemplateId))
|
||||||
|
.build();
|
||||||
|
requests.add(build);
|
||||||
|
}
|
||||||
|
|
||||||
|
return requests;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ResizeRedactionRequest> toResizeRedactionRequestList(Set<ResizeRedactionRequestModel> resizeRedactionRequests) {
|
||||||
|
|
||||||
|
return resizeRedactionRequests.stream()
|
||||||
|
.map(resizeRedactionRequest ->ResizeRedactionRequest.builder()
|
||||||
|
.annotationId(resizeRedactionRequest.getAnnotationId())
|
||||||
|
.user(KeycloakSecurity.getUserId())
|
||||||
|
.status(AnnotationStatus.APPROVED)
|
||||||
|
.positions(resizeRedactionRequest.getPositions())
|
||||||
|
.value(resizeRedactionRequest.getValue())
|
||||||
|
.comment(resizeRedactionRequest.getComment())
|
||||||
|
.updateDictionary(resizeRedactionRequest.getUpdateDictionary())
|
||||||
|
.addToAllDossiers(resizeRedactionRequest.isAddToAllDossiers())
|
||||||
|
.build())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private RedactionLogEntry getRedactionLogEntry(RedactionLog redactionLog, String annotationId) {
|
||||||
|
|
||||||
|
return redactionLog.getRedactionLogEntry()
|
||||||
|
.stream()
|
||||||
|
.filter(entry -> entry.getId().equals(annotationId))
|
||||||
|
.findFirst()
|
||||||
|
.orElseThrow(() -> new NotFoundException("Annotation does not exist in redaction log."));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private DictionaryEntryType getDictionaryEntryType(RedactionLogEntry redactionLogEntry) {
|
||||||
|
|
||||||
|
if (redactionLogEntry.isRecommendation() && redactionLogEntry.isFalsePositive()) {
|
||||||
|
return DictionaryEntryType.FALSE_RECOMMENDATION;
|
||||||
|
} else if (redactionLogEntry.isFalsePositive()) {
|
||||||
|
return DictionaryEntryType.FALSE_POSITIVE;
|
||||||
|
} else {
|
||||||
|
return DictionaryEntryType.ENTRY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -34,11 +34,9 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations
|
|||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RecategorizationRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RecategorizationRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.RemoveRedactionRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ResizeRedactionRequest;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLog;
|
||||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.redactionlog.RedactionLogEntry;
|
||||||
|
|
||||||
import feign.FeignException;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
@ -82,7 +80,9 @@ public class ManualRedactionService {
|
|||||||
|
|
||||||
addRedactionPersistenceService.insert(fileId, annotationId, addRedactionRequest);
|
addRedactionPersistenceService.insert(fileId, annotationId, addRedactionRequest);
|
||||||
|
|
||||||
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId, addRedactionRequest.getValue(), addRedactionRequest);
|
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId,
|
||||||
|
addRedactionRequest.getValue(),
|
||||||
|
addRedactionRequest);
|
||||||
|
|
||||||
addRedactionPersistenceService.updateStatus(fileId,
|
addRedactionPersistenceService.updateStatus(fileId,
|
||||||
annotationId,
|
annotationId,
|
||||||
@ -105,21 +105,19 @@ public class ManualRedactionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public List<ManualAddResponse> addRemoveRedaction(String dossierId, String fileId, List<RemoveRedactionRequest> removeRedactionRequests) {
|
public List<ManualAddResponse> addRemoveRedaction(String dossierId, String fileId, List<RemoveRedactionRequest> removeRedactionRequests) {
|
||||||
|
|
||||||
var response = new ArrayList<ManualAddResponse>();
|
var response = new ArrayList<ManualAddResponse>();
|
||||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
|
||||||
RedactionLog redactionLog = redactionLogService.getRedactionLog(dossier.getId(), fileId);
|
|
||||||
|
|
||||||
var requiresReAnalysis = false;
|
var requiresReAnalysis = false;
|
||||||
var manualRedactions = manualRedactionProviderService.getManualRedactions(fileId);
|
var manualRedactions = manualRedactionProviderService.getManualRedactions(fileId);
|
||||||
|
|
||||||
//validate removing from dossier template dictionary
|
//validate removing from dossier template dictionary
|
||||||
|
|
||||||
for (RemoveRedactionRequest removeRedactionRequest : removeRedactionRequests) {
|
for (RemoveRedactionRequest removeRedactionRequest : removeRedactionRequests) {
|
||||||
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, removeRedactionRequest.getAnnotationId());
|
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(removeRedactionRequest,
|
||||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(removeRedactionRequest, redactionLogEntry, dossier.getDossierTemplateId());
|
removeRedactionRequest.getTypeToRemove(),
|
||||||
|
removeRedactionRequest.getDossierTemplateId());
|
||||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||||
|
|
||||||
if (manualAddRedactionsContains(manualRedactions, removeRedactionRequest.getAnnotationId())) {
|
if (manualAddRedactionsContains(manualRedactions, removeRedactionRequest.getAnnotationId())) {
|
||||||
@ -136,12 +134,7 @@ public class ManualRedactionService {
|
|||||||
removeRedactionRequest.getComment(),
|
removeRedactionRequest.getComment(),
|
||||||
removeRedactionRequest.getUser());
|
removeRedactionRequest.getUser());
|
||||||
|
|
||||||
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(//
|
Set<String> typeIdsOfModifiedDictionaries = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(fileId, removeRedactionRequest);
|
||||||
redactionLogEntry,//
|
|
||||||
fileId,//
|
|
||||||
dossierId, //
|
|
||||||
dossier.getDossierTemplateId(),//
|
|
||||||
removeRedactionRequest);
|
|
||||||
|
|
||||||
boolean removedFromDictionary = !typeIdsOfModifiedDictionaries.isEmpty();
|
boolean removedFromDictionary = !typeIdsOfModifiedDictionaries.isEmpty();
|
||||||
|
|
||||||
@ -222,20 +215,18 @@ public class ManualRedactionService {
|
|||||||
|
|
||||||
var response = new ArrayList<ManualAddResponse>();
|
var response = new ArrayList<ManualAddResponse>();
|
||||||
var requiresReanalysis = false;
|
var requiresReanalysis = false;
|
||||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
|
||||||
RedactionLog redactionLog = redactionLogService.getRedactionLog(dossierId, fileId);
|
|
||||||
for (var recategorizationRequest : recategorizationRequests) {
|
for (var recategorizationRequest : recategorizationRequests) {
|
||||||
RedactionLogEntry redactionLogEntry = getRedactionLogEntry(redactionLog, recategorizationRequest.getAnnotationId());
|
manualRedactionDictionaryUpdateHandler.validateDictionariesForAdd(recategorizationRequest, recategorizationRequest.getValue());
|
||||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForAdd(recategorizationRequest, redactionLogEntry.getValue());
|
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(recategorizationRequest,
|
||||||
manualRedactionDictionaryUpdateHandler.validateDictionariesForDelete(recategorizationRequest, redactionLogEntry, dossier.getDossierTemplateId());
|
recategorizationRequest.getTypeToRemove(),
|
||||||
|
recategorizationRequest.getDossierTemplateId());
|
||||||
|
|
||||||
recategorizationPersistenceService.insert(fileId, recategorizationRequest);
|
recategorizationPersistenceService.insert(fileId, recategorizationRequest);
|
||||||
|
|
||||||
Set<String> typeIdsOfDictionariesWithAdd = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId, redactionLogEntry.getValue(), recategorizationRequest);
|
Set<String> typeIdsOfDictionariesWithAdd = manualRedactionDictionaryUpdateHandler.handleAddToDictionaryAndReturnModifiedTypeIds(fileId,
|
||||||
Set<String> typeIdsOfDictionariesWithDelete = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(redactionLogEntry,
|
recategorizationRequest.getValue(),
|
||||||
fileId,
|
recategorizationRequest);
|
||||||
recategorizationRequest.getDossierId(),
|
Set<String> typeIdsOfDictionariesWithDelete = manualRedactionDictionaryUpdateHandler.handleRemoveFromDictionaryAndReturnModifiedTypeIds(fileId,
|
||||||
dossier.getDossierTemplateId(),
|
|
||||||
recategorizationRequest);
|
recategorizationRequest);
|
||||||
|
|
||||||
recategorizationPersistenceService.updateStatus(fileId,
|
recategorizationPersistenceService.updateStatus(fileId,
|
||||||
@ -317,28 +308,6 @@ public class ManualRedactionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void removeFromDictionary(String typeId, String value, String dossierId, String fileId, DictionaryEntryType dictionaryEntryType) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.debug("Deleting entries to {} for {} / {}", typeId, dossierId, fileId);
|
|
||||||
dictionaryManagementService.deleteEntries(typeId, List.of(value), dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
|
||||||
} catch (FeignException e) {
|
|
||||||
throw new BadRequestException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void addToDictionary(String typeId, String value, String dossierId, String fileId, DictionaryEntryType dictionaryEntryType) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.debug("Adding entry: {} to {} for {} / {}", value, typeId, dossierId, fileId);
|
|
||||||
dictionaryManagementService.addEntries(typeId, List.of(value), false, false, dictionaryEntryType != null ? dictionaryEntryType : DictionaryEntryType.ENTRY);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BadRequestException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean manualAddRedactionsContains(ManualRedactions manualRedactions, String annotationId) {
|
private boolean manualAddRedactionsContains(ManualRedactions manualRedactions, String annotationId) {
|
||||||
|
|
||||||
return manualRedactions.getEntriesToAdd().stream().anyMatch(m -> annotationId.equals(m.getAnnotationId()));
|
return manualRedactions.getEntriesToAdd().stream().anyMatch(m -> annotationId.equals(m.getAnnotationId()));
|
||||||
|
|||||||
@ -4,6 +4,9 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
|
|||||||
|
|
||||||
public interface ManualRequestWithAddToDictionary extends BaseManualRequest {
|
public interface ManualRequestWithAddToDictionary extends BaseManualRequest {
|
||||||
|
|
||||||
|
String getValue();
|
||||||
|
|
||||||
|
|
||||||
String getDossierId();
|
String getDossierId();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,26 @@
|
|||||||
package com.iqser.red.service.persistence.service.v1.api.shared.model.annotations;
|
package com.iqser.red.service.persistence.service.v1.api.shared.model.annotations;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||||
|
|
||||||
public interface ManualRequestWithRemoveFromDictionary extends BaseManualRequest {
|
public interface ManualRequestWithRemoveFromDictionary extends BaseManualRequest {
|
||||||
|
|
||||||
String getAnnotationId();
|
String getAnnotationId();
|
||||||
|
|
||||||
|
|
||||||
|
String getValue();
|
||||||
|
|
||||||
|
String getTypeToRemove();
|
||||||
|
|
||||||
|
String getDossierTemplateId();
|
||||||
|
|
||||||
|
String getDossierId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DictionaryEntryType getDictionaryEntryType();
|
||||||
|
|
||||||
|
|
||||||
boolean isRemoveFromDictionary();
|
boolean isRemoveFromDictionary();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -18,9 +18,12 @@ public class RecategorizationRequest implements ManualRequestWithAddToDictionary
|
|||||||
|
|
||||||
String annotationId;
|
String annotationId;
|
||||||
String user;
|
String user;
|
||||||
|
String value;
|
||||||
AnnotationStatus status;
|
AnnotationStatus status;
|
||||||
String dossierTemplateTypeId;
|
String typeToRemove;
|
||||||
|
String dossierTemplateId;
|
||||||
String dossierId;
|
String dossierId;
|
||||||
|
String dossierTemplateTypeId;
|
||||||
String comment;
|
String comment;
|
||||||
int page;
|
int page;
|
||||||
boolean addToDictionary;
|
boolean addToDictionary;
|
||||||
|
|||||||
@ -1,22 +1,32 @@
|
|||||||
package com.iqser.red.service.persistence.service.v1.api.shared.model.annotations;
|
package com.iqser.red.service.persistence.service.v1.api.shared.model.annotations;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.type.DictionaryEntryType;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
@Builder
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||||
public class RemoveRedactionRequest implements ManualRequestWithRemoveFromDictionary {
|
public class RemoveRedactionRequest implements ManualRequestWithRemoveFromDictionary {
|
||||||
|
|
||||||
private String annotationId;
|
String annotationId;
|
||||||
private String user;
|
String value;
|
||||||
private AnnotationStatus status;
|
DictionaryEntryType dictionaryEntryType;
|
||||||
private boolean removeFromDictionary;
|
String user;
|
||||||
private boolean removeFromAllDossiers;
|
String dossierId;
|
||||||
private String comment;
|
String dossierTemplateId;
|
||||||
private int page;
|
String typeToRemove;
|
||||||
|
AnnotationStatus status;
|
||||||
|
boolean removeFromDictionary;
|
||||||
|
boolean removeFromAllDossiers;
|
||||||
|
String comment;
|
||||||
|
int page;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user