RED-3382 - Manual redaction controller needs to support bulk requests
- refactoring the apis to support bulk operations (without addRedaction and addComment) - update junit tests
This commit is contained in:
parent
efda92de6b
commit
cecd7fb6d5
@ -0,0 +1,17 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.model.annotations;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateRedactionRequest {
|
||||
private List<String> annotationIds;
|
||||
private AnnotationStatus annotationStatus;
|
||||
}
|
||||
@ -2,11 +2,12 @@ package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public interface ManualRedactionResource {
|
||||
|
||||
@ -24,6 +25,8 @@ public interface ManualRedactionResource {
|
||||
String COMMENT_ID = "commentId";
|
||||
String COMMENT_ID_PATH_VARIABLE = "/{" + COMMENT_ID + "}";
|
||||
|
||||
String DELETE_PATH = "/delete";
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@ -31,27 +34,27 @@ public interface ManualRedactionResource {
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody RemoveRedactionRequest removeRedactionRequest);
|
||||
List<ManualAddResponse> addRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody List<RemoveRedactionRequest> removeRedactionRequest);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addForceRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
List<ManualAddResponse> addForceRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ForceRedactionRequest forceRedactionRequest);
|
||||
@RequestBody List<ForceRedactionRequest> forceRedactionRequests);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
List<ManualAddResponse> addLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody LegalBasisChangeRequest legalBasisChangeRequest);
|
||||
@RequestBody List<LegalBasisChangeRequest> legalBasisChangeRequests);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
List<ManualAddResponse> addImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ImageRecategorizationRequest imageRecategorizationRequest);
|
||||
@RequestBody List<ImageRecategorizationRequest> imageRecategorizationRequests);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/comment" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ -60,9 +63,9 @@ public interface ManualRedactionResource {
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ManualAddResponse addResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
List<ManualAddResponse> addResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ResizeRedactionRequest resizeRedactionRequest);
|
||||
@RequestBody List<ResizeRedactionRequest> resizeRedactionRequests);
|
||||
|
||||
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + "/add" + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ -99,74 +102,68 @@ public interface ManualRedactionResource {
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/comment" + FILE_ID_PATH_VARIABLE + COMMENT_ID_PATH_VARIABLE)
|
||||
void deleteComment(@PathVariable(FILE_ID) String fileId, @PathVariable(COMMENT_ID) long commentId);
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/comment" + FILE_ID_PATH_VARIABLE)
|
||||
void deleteComment(@PathVariable(FILE_ID) String fileId, @RequestBody List<Long> commentIds);
|
||||
|
||||
|
||||
@DeleteMapping(MANUAL_REDACTION_REST_PATH + "/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE)
|
||||
@PostMapping(MANUAL_REDACTION_REST_PATH + DELETE_PATH + "/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE)
|
||||
void deleteResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId);
|
||||
@RequestBody List<String> annotationIds);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/add" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateAddRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/remove" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateRemoveRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/force" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateForceRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/legalBasis" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateLegalBasisChangeStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/recategorize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateImageRecategorizationStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + ANNOTATION_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = MANUAL_REDACTION_REST_PATH + "/status/resize" + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
void updateResizeRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest);
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest);
|
||||
|
||||
|
||||
@GetMapping(value = MANUAL_REDACTION_REST_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@ -6,13 +6,14 @@ import com.iqser.red.service.peristence.v1.server.utils.ManualRedactionMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.utils.ManualResizeRedactionMapper;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.*;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
import com.iqser.red.service.persistence.service.v1.api.resources.ManualRedactionResource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
@RestController
|
||||
@ -32,38 +33,38 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
|
||||
|
||||
@Override
|
||||
public ManualAddResponse addRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
public List<ManualAddResponse> addRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody RemoveRedactionRequest removeRedactionRequest) {
|
||||
@RequestBody List<RemoveRedactionRequest> removeRedactionRequests) {
|
||||
|
||||
return manualRedactionService.addRemoveRedaction(dossierId, fileId, removeRedactionRequest);
|
||||
return manualRedactionService.addRemoveRedaction(dossierId, fileId, removeRedactionRequests);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManualAddResponse addForceRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
public List<ManualAddResponse> addForceRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ForceRedactionRequest forceRedactionRequest) {
|
||||
@RequestBody List<ForceRedactionRequest> forceRedactionRequests) {
|
||||
|
||||
return manualRedactionService.addForceRedaction(dossierId, fileId, forceRedactionRequest);
|
||||
return manualRedactionService.addForceRedaction(dossierId, fileId, forceRedactionRequests);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManualAddResponse addLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
public List<ManualAddResponse> addLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody LegalBasisChangeRequest legalBasisChangeRequest) {
|
||||
@RequestBody List<LegalBasisChangeRequest> legalBasisChangeRequests) {
|
||||
|
||||
return manualRedactionService.addLegalBasisChange(dossierId, fileId, legalBasisChangeRequest);
|
||||
return manualRedactionService.addLegalBasisChange(dossierId, fileId, legalBasisChangeRequests);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManualAddResponse addImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
public List<ManualAddResponse> addImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ImageRecategorizationRequest imageRecategorizationRequest) {
|
||||
@RequestBody List<ImageRecategorizationRequest> imageRecategorizationRequests) {
|
||||
|
||||
return manualRedactionService.addImageRecategorization(dossierId, fileId, imageRecategorizationRequest);
|
||||
return manualRedactionService.addImageRecategorization(dossierId, fileId, imageRecategorizationRequests);
|
||||
}
|
||||
|
||||
|
||||
@ -77,11 +78,11 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
|
||||
|
||||
@Override
|
||||
public ManualAddResponse addResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
public List<ManualAddResponse> addResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody ResizeRedactionRequest resizeRedactionRequest) {
|
||||
@RequestBody List<ResizeRedactionRequest> resizeRedactionRequests) {
|
||||
|
||||
return manualRedactionService.addResizeRedaction(dossierId, fileId, resizeRedactionRequest);
|
||||
return manualRedactionService.addResizeRedaction(dossierId, fileId, resizeRedactionRequests);
|
||||
}
|
||||
|
||||
|
||||
@ -139,116 +140,110 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
|
||||
@Override
|
||||
public void deleteAddRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteAddRedaction(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteAddRedaction(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteRemoveRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteRemoveRedaction(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteRemoveRedaction(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteForceRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteForceRedaction(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteForceRedaction(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteLegalBasisChange(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteLegalBasisChange(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteLegalBasisChange(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteImageRecategorization(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteImageRecategorization(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteImageRecategorization(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteComment(@PathVariable(FILE_ID) String fileId, @PathVariable(COMMENT_ID) long commentId) {
|
||||
public void deleteComment(@PathVariable(FILE_ID) String fileId, @RequestBody List<Long> commentIds) {
|
||||
|
||||
manualRedactionService.deleteComment(fileId, commentId);
|
||||
manualRedactionService.deleteComment(fileId, commentIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteResizeRedaction(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId) {
|
||||
@RequestBody List<String> annotationIds) {
|
||||
|
||||
manualRedactionService.deleteResizeRedaction(dossierId, fileId, annotationId);
|
||||
manualRedactionService.deleteResizeRedaction(dossierId, fileId, annotationIds);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateAddRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateAddRedactionStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateAddRedactionStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateRemoveRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateRemoveRedactionStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateRemoveRedactionStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateForceRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateForceRedactionStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateForceRedactionStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
public void updateLegalBasisChangeStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateLegalBasisChangeStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateLegalBasisChangeStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateImageRecategorizationStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateImageRecategorizationStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateImageRecategorizationStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateResizeRedactionStatus(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANNOTATION_ID) String annotationId,
|
||||
@RequestBody JSONPrimitive<AnnotationStatus> updateStatusRequest) {
|
||||
@RequestBody UpdateRedactionRequest updateStatusRequest) {
|
||||
|
||||
manualRedactionService.updateResizeRedactionStatus(dossierId, fileId, annotationId, updateStatusRequest.getValue());
|
||||
manualRedactionService.updateResizeRedactionStatus(dossierId, fileId, updateStatusRequest.getAnnotationIds(), updateStatusRequest.getAnnotationStatus());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -102,11 +102,9 @@ public class ManualRedactionService {
|
||||
|
||||
if (addRedactionRequest.isAddToDictionary() || addRedactionRequest.isAddToDossierDictionary()) {
|
||||
try {
|
||||
|
||||
if (!addRedactionRequest.isForceAddToDictionary() && stopwordService.isStopword(addRedactionRequest.getValue())) {
|
||||
throw new ConflictException("The entry you are trying to add is a stopword");
|
||||
}
|
||||
|
||||
dictionaryController.getDictionaryForType(addRedactionRequest.getTypeId());
|
||||
} catch (NotFoundException e) {
|
||||
throw new BadRequestException("Invalid type: " + addRedactionRequest.getTypeId());
|
||||
@ -114,146 +112,139 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
String annotationId = hashFunction.hashString(fileId + addRedactionRequest, StandardCharsets.UTF_8).toString();
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
|
||||
addRedactionPersistenceService.insert(fileId, annotationId, addRedactionRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (addRedactionRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, annotationId, addRedactionRequest.getComment(), addRedactionRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
handleAddToDictionary(fileId, annotationId, addRedactionRequest.getTypeId(), addRedactionRequest.getValue(), addRedactionRequest.getStatus(), addRedactionRequest.isAddToDictionary(), addRedactionRequest.isAddToDossierDictionary(), false, dossierId);
|
||||
var actionPerformed = handleAddToDictionary(fileId, annotationId, addRedactionRequest.getTypeId(), addRedactionRequest.getValue(), addRedactionRequest.getStatus(), addRedactionRequest.isAddToDictionary(), addRedactionRequest.isAddToDossierDictionary(), false, dossierId);
|
||||
|
||||
if (addRedactionRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
if(actionPerformed){
|
||||
// in case of add to dict, there is no need to process surrounding text
|
||||
reprocess(dossierId,fileId);
|
||||
}else{
|
||||
if (!addRedactionRequest.isAddToDictionary() && !addRedactionRequest.isAddToDossierDictionary() && !addRedactionRequest.isRectangle()) {
|
||||
var loaded = convert(getAddRedaction(fileId, annotationId), ManualRedactionEntry.class, new ManualRedactionMapper());
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(Set.of(loaded)).build();
|
||||
addManualRedactionToAnalysisQueue(dossierId, fileId, manualRedactions);
|
||||
}
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
if (!addRedactionRequest.isAddToDictionary() && !addRedactionRequest.isAddToDossierDictionary() && !addRedactionRequest.isRectangle()) {
|
||||
var loaded = convert(getAddRedaction(fileId, annotationId), ManualRedactionEntry.class, new ManualRedactionMapper());
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().entriesToAdd(Set.of(loaded)).build();
|
||||
addManualRedactionToAnalysisQueue(dossierId, fileId, manualRedactions);
|
||||
}
|
||||
|
||||
return ManualAddResponse.builder().annotationId(annotationId).commentId(commentId).build();
|
||||
}
|
||||
|
||||
|
||||
public ManualAddResponse addRemoveRedaction(String dossierId, String fileId, RemoveRedactionRequest removeRedactionRequest) {
|
||||
public List<ManualAddResponse> addRemoveRedaction(String dossierId, String fileId, List<RemoveRedactionRequest> removeRedactionRequests) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var actionPerformed = false;
|
||||
var redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), fileId);
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||
for(var removeRedactionRequest : removeRedactionRequests ){
|
||||
|
||||
Long commentId = null;
|
||||
if (removeRedactionRequest.getComment() != null) {
|
||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||
|
||||
commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getComment(), removeRedactionRequest.getUser()).getId();
|
||||
Long commentId = null;
|
||||
if (removeRedactionRequest.getComment() != null) {
|
||||
commentId = addComment(fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getComment(), removeRedactionRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
actionPerformed = actionPerformed || handleRemoveFromDictionary(redactionLog, dossier, fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getStatus(), removeRedactionRequest.isRemoveFromDictionary(), false);
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
}
|
||||
|
||||
handleRemoveFromDictionary(dossierId, fileId, removeRedactionRequest.getAnnotationId(), removeRedactionRequest.getStatus(), removeRedactionRequest.isRemoveFromDictionary(), false);
|
||||
|
||||
if (removeRedactionRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
}
|
||||
|
||||
if (!removeRedactionRequest.isRemoveFromDictionary()) {
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
if (removeRedactionRequest.getStatus().equals(AnnotationStatus.APPROVED)) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
return ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build();
|
||||
}
|
||||
|
||||
|
||||
public ManualAddResponse addForceRedaction(String dossierId, String fileId, ForceRedactionRequest forceRedactionRequest) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
forceRedactionPersistenceService.insert(fileId, forceRedactionRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (forceRedactionRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, forceRedactionRequest.getAnnotationId(), forceRedactionRequest.getComment(), forceRedactionRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
if (forceRedactionRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
if (forceRedactionRequest.getStatus().equals(AnnotationStatus.APPROVED)) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
return ManualAddResponse.builder().annotationId(forceRedactionRequest.getAnnotationId()).commentId(commentId).build();
|
||||
}
|
||||
|
||||
|
||||
public ManualAddResponse addLegalBasisChange(String dossierId, String fileId, LegalBasisChangeRequest legalBasisChangeRequest) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
legalBasisChangePersistenceService.insert(fileId, legalBasisChangeRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (legalBasisChangeRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, legalBasisChangeRequest.getAnnotationId(), legalBasisChangeRequest.getComment(), legalBasisChangeRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
if (legalBasisChangeRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
return ManualAddResponse.builder().annotationId(legalBasisChangeRequest.getAnnotationId()).commentId(commentId).build();
|
||||
}
|
||||
|
||||
|
||||
public ManualAddResponse addImageRecategorization(String dossierId, String fileId, ImageRecategorizationRequest imageRecategorizationRequest) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
recategorizationPersistenceService.insert(fileId, imageRecategorizationRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (imageRecategorizationRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, imageRecategorizationRequest.getAnnotationId(), imageRecategorizationRequest.getComment(), imageRecategorizationRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
if (imageRecategorizationRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
if(actionPerformed){
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
return ManualAddResponse.builder().annotationId(imageRecategorizationRequest.getAnnotationId()).commentId(commentId).build();
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public List<ManualAddResponse> addForceRedaction(String dossierId, String fileId, List<ForceRedactionRequest> forceRedactionRequests) {
|
||||
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var actionPerformed = false;
|
||||
|
||||
for(var forceRedactionRequest : forceRedactionRequests ) {
|
||||
forceRedactionPersistenceService.insert(fileId, forceRedactionRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (forceRedactionRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, forceRedactionRequest.getAnnotationId(), forceRedactionRequest.getComment(), forceRedactionRequest.getUser()).getId();
|
||||
}
|
||||
actionPerformed = actionPerformed || AnnotationStatus.APPROVED.equals(forceRedactionRequest.getStatus());
|
||||
response.add(ManualAddResponse.builder().annotationId(forceRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
}
|
||||
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public List<ManualAddResponse> addLegalBasisChange(String dossierId, String fileId, List<LegalBasisChangeRequest> legalBasisChangeRequests) {
|
||||
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
for(var legalBasisChangeRequest : legalBasisChangeRequests) {
|
||||
legalBasisChangePersistenceService.insert(fileId, legalBasisChangeRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (legalBasisChangeRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, legalBasisChangeRequest.getAnnotationId(), legalBasisChangeRequest.getComment(), legalBasisChangeRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(legalBasisChangeRequest.getAnnotationId()).commentId(commentId).build());
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
public List<ManualAddResponse> addImageRecategorization(String dossierId, String fileId, List<ImageRecategorizationRequest> imageRecategorizationRequests) {
|
||||
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
var actionPerformed = false;
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
for(var imageRecategorizationRequest : imageRecategorizationRequests) {
|
||||
recategorizationPersistenceService.insert(fileId, imageRecategorizationRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (imageRecategorizationRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, imageRecategorizationRequest.getAnnotationId(), imageRecategorizationRequest.getComment(), imageRecategorizationRequest.getUser()).getId();
|
||||
}
|
||||
|
||||
actionPerformed = actionPerformed || !AnnotationStatus.REQUESTED.equals(imageRecategorizationRequest.getStatus());
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(imageRecategorizationRequest.getAnnotationId()).commentId(commentId).build());
|
||||
}
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@ -310,198 +301,185 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
public void deleteAddRedaction(String dossierId, String fileId, String annotationId) {
|
||||
public void deleteAddRedaction(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
var addRedaction = getAddRedaction(fileId, annotationId);
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var actionPerformed = false;
|
||||
|
||||
handleAddToDictionary(fileId, annotationId, addRedaction.getTypeId(), addRedaction.getValue(), addRedaction.getStatus(), addRedaction.isAddToDictionary(), addRedaction.isAddToDossierDictionary(), true, dossier.getId());
|
||||
|
||||
addRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
|
||||
if (addRedaction.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
for(var annotationId : annotationIds) {
|
||||
var addRedaction = getAddRedaction(fileId, annotationId);
|
||||
actionPerformed = actionPerformed || handleAddToDictionary(fileId, annotationId, addRedaction.getTypeId(), addRedaction.getValue(), addRedaction.getStatus(), addRedaction.isAddToDictionary(), addRedaction.isAddToDossierDictionary(), true, dossier.getId());
|
||||
addRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteRemoveRedaction(String dossierId, String fileId, String annotationId) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
var removeRedaction = getRemoveRedaction(fileId, annotationId);
|
||||
|
||||
handleRemoveFromDictionary(dossierId, fileId, annotationId, removeRedaction.getStatus(), removeRedaction.isRemoveFromDictionary(), true);
|
||||
removeRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
|
||||
if (removeRedaction.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteForceRedaction(String dossierId, String fileId, String annotationId) {
|
||||
public void deleteRemoveRedaction(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
var forceRedaction = getForceRedaction(fileId, annotationId);
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var actionPerformed = false;
|
||||
var redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), fileId);
|
||||
|
||||
forceRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
for(var annotationId : annotationIds) {
|
||||
|
||||
if (forceRedaction.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
var removeRedaction = getRemoveRedaction(fileId, annotationId);
|
||||
|
||||
actionPerformed = actionPerformed || handleRemoveFromDictionary(redactionLog , dossier, fileId, annotationId, removeRedaction.getStatus(), removeRedaction.isRemoveFromDictionary(), true);
|
||||
removeRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
if(actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteLegalBasisChange(String dossierId, String fileId, String annotationId) {
|
||||
public void deleteForceRedaction(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
var legalBasisChange = getLegalBasisChange(fileId, annotationId);
|
||||
var now = OffsetDateTime.now();
|
||||
|
||||
legalBasisChangePersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
if (legalBasisChange.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
for(var annotationId : annotationIds ) {
|
||||
forceRedactionPersistenceService.softDelete(fileId, annotationId, now);
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteImageRecategorization(String dossierId, String fileId, String annotationId) {
|
||||
public void deleteLegalBasisChange(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
var imageRecategorization = getImageRecategorization(fileId, annotationId);
|
||||
for(var annotationId : annotationIds) {
|
||||
legalBasisChangePersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
recategorizationPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
if (imageRecategorization.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
|
||||
public void deleteImageRecategorization(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
var actionPerformed = false;
|
||||
for(var annotationId : annotationIds) {
|
||||
var imageRecategorization = getImageRecategorization(fileId, annotationId);
|
||||
|
||||
recategorizationPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
|
||||
actionPerformed = actionPerformed || !AnnotationStatus.REQUESTED.equals(imageRecategorization.getStatus());
|
||||
}
|
||||
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void deleteComment(String fileId, long commentId) {
|
||||
|
||||
public void deleteComment(String fileId, List<Long> commentIds) {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
commentPersistenceService.softDelete(commentId, OffsetDateTime.now());
|
||||
|
||||
for(var commentId : commentIds) {
|
||||
commentPersistenceService.softDelete(commentId, OffsetDateTime.now());
|
||||
}
|
||||
// update indicator
|
||||
fileStatusPersistenceService.updateHasComments(fileId, commentPersistenceService.fileHasComments(fileId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void deleteResizeRedaction(String dossierId, String fileId, String annotationId) {
|
||||
|
||||
var resizeRedaction = getResizeRedaction(fileId, annotationId);
|
||||
|
||||
resizeRedactionPersistenceService.softDelete(fileId, annotationId, OffsetDateTime.now());
|
||||
|
||||
if (resizeRedaction.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public ManualAddResponse addResizeRedaction(String dossierId, String fileId, ResizeRedactionRequest resizeRedactionRequest) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
public void deleteResizeRedaction(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
OffsetDateTime now = OffsetDateTime.now();
|
||||
resizeRedactionPersistenceService.insert(fileId, resizeRedactionRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (resizeRedactionRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, resizeRedactionRequest.getAnnotationId(), resizeRedactionRequest.getComment(), resizeRedactionRequest.getUser()).getId();
|
||||
for(var annotationId : annotationIds ) {
|
||||
resizeRedactionPersistenceService.softDelete(fileId, annotationId, now);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
if (resizeRedactionRequest.getStatus().equals(AnnotationStatus.REQUESTED)) {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, now, true);
|
||||
} else {
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, now);
|
||||
|
||||
public List<ManualAddResponse> addResizeRedaction(String dossierId, String fileId, List<ResizeRedactionRequest> resizeRedactionRequests) {
|
||||
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
for(var resizeRedactionRequest : resizeRedactionRequests ) {
|
||||
resizeRedactionPersistenceService.insert(fileId, resizeRedactionRequest);
|
||||
|
||||
Long commentId = null;
|
||||
if (resizeRedactionRequest.getComment() != null) {
|
||||
|
||||
commentId = addComment(fileId, resizeRedactionRequest.getAnnotationId(), resizeRedactionRequest.getComment(), resizeRedactionRequest.getUser()).getId();
|
||||
}
|
||||
var loaded = convert(getResizeRedaction(fileId, resizeRedactionRequest.getAnnotationId()), ManualResizeRedaction.class, new ManualResizeRedactionMapper());
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().resizeRedactions(Set.of(loaded)).build();
|
||||
addManualRedactionToAnalysisQueue(dossierId, fileId, manualRedactions);
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(resizeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
}
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
|
||||
var loaded = convert(getResizeRedaction(fileId, resizeRedactionRequest.getAnnotationId()), ManualResizeRedaction.class, new ManualResizeRedactionMapper());
|
||||
ManualRedactions manualRedactions = ManualRedactions.builder().resizeRedactions(Set.of(loaded)).build();
|
||||
addManualRedactionToAnalysisQueue(dossierId, fileId, manualRedactions);
|
||||
|
||||
return ManualAddResponse.builder().annotationId(resizeRedactionRequest.getAnnotationId()).commentId(commentId).build();
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("PMD")
|
||||
public void updateRemoveRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateRemoveRedactionStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
|
||||
IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId);
|
||||
if (idRemoval.isRemoveFromDictionary()) {
|
||||
for(var annotationId : annotationIds) {
|
||||
IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId);
|
||||
if (idRemoval.isRemoveFromDictionary()) {
|
||||
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getId().getAnnotationId()))
|
||||
.findFirst();
|
||||
|
||||
if (redactionLogEntryOptional.isEmpty()) {
|
||||
throw new NotFoundException("Annotation does not exist in redaction log.");
|
||||
}
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getId().getAnnotationId()))
|
||||
.findFirst();
|
||||
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
if (redactionLogEntryOptional.isEmpty()) {
|
||||
throw new NotFoundException("Annotation does not exist in redaction log.");
|
||||
}
|
||||
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue());
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
} else if (annotationStatus == AnnotationStatus.DECLINED) {
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
approveStatusForRedactionsWithSameValue(dossier, false, true, redactionLogEntry.getValue());
|
||||
|
||||
// if it was previously approved, revert the delete
|
||||
if (idRemoval.getStatus() == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
} else if (annotationStatus == AnnotationStatus.DECLINED) {
|
||||
|
||||
// if it was previously approved, revert the delete
|
||||
if (idRemoval.getStatus() == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void updateForceRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateForceRedactionStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
forceRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
for(var annotationId : annotationIds) {
|
||||
forceRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -513,34 +491,38 @@ public class ManualRedactionService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLegalBasisChangeStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateLegalBasisChangeStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
legalBasisChangePersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
for(var annotationId : annotationIds) {
|
||||
legalBasisChangePersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public void updateImageRecategorizationStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateImageRecategorizationStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
ManualImageRecategorizationEntity imageRecategorization = recategorizationPersistenceService.findRecategorization(fileId, annotationId);
|
||||
var actionPerformed = false;
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
if (annotationStatus.equals(AnnotationStatus.DECLINED)) {
|
||||
for(var annotationId : annotationIds) {
|
||||
ManualImageRecategorizationEntity imageRecategorization = recategorizationPersistenceService.findRecategorization(fileId, annotationId);
|
||||
|
||||
// if it was previously approved, revert the delete
|
||||
if (imageRecategorization.getStatus() == AnnotationStatus.APPROVED) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
} else if (annotationStatus.equals(AnnotationStatus.APPROVED)) {
|
||||
actionPerformed = actionPerformed ||
|
||||
(AnnotationStatus.DECLINED.equals(annotationStatus)
|
||||
&& AnnotationStatus.APPROVED.equals(imageRecategorization.getStatus()));
|
||||
actionPerformed = actionPerformed || AnnotationStatus.APPROVED.equals(annotationStatus);
|
||||
|
||||
recategorizationPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
recategorizationPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -556,41 +538,43 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
public void updateResizeRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateResizeRedactionStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
resizeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
for (var annotationId : annotationIds) {
|
||||
resizeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("PMD")
|
||||
public void updateAddRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
public void updateAddRedactionStatus(String dossierId, String fileId, List<String> annotationIds, AnnotationStatus annotationStatus) {
|
||||
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
for(var annotationId : annotationIds) {
|
||||
ManualRedactionEntryEntity manualRedactionEntry = addRedactionPersistenceService.findAddRedaction(fileId, annotationId);
|
||||
if (manualRedactionEntry.isAddToDictionary() || manualRedactionEntry.isAddToDossierDictionary()) {
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId);
|
||||
|
||||
ManualRedactionEntryEntity manualRedactionEntry = addRedactionPersistenceService.findAddRedaction(fileId, annotationId);
|
||||
if (manualRedactionEntry.isAddToDictionary() || manualRedactionEntry.isAddToDossierDictionary()) {
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId);
|
||||
approveStatusForRedactionsWithSameValue(dossier, manualRedactionEntry.isAddToDictionary(), manualRedactionEntry.isAddToDossierDictionary(), manualRedactionEntry.getValue());
|
||||
|
||||
approveStatusForRedactionsWithSameValue(dossier, manualRedactionEntry.isAddToDictionary(), manualRedactionEntry.isAddToDossierDictionary(), manualRedactionEntry.getValue());
|
||||
|
||||
} else if (annotationStatus == AnnotationStatus.DECLINED) {
|
||||
// if it was previously approved, revert the add
|
||||
if (manualRedactionEntry.getStatus() == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId);
|
||||
} else if (annotationStatus == AnnotationStatus.DECLINED) {
|
||||
// if it was previously approved, revert the add
|
||||
if (manualRedactionEntry.getStatus() == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(manualRedactionEntry.getTypeId(), manualRedactionEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), hasSuggestions);
|
||||
}
|
||||
|
||||
addRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), hasSuggestions);
|
||||
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -662,15 +646,13 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
private void handleRemoveFromDictionary(String dossierId, String fileId, String annotationId, AnnotationStatus status, boolean removeFromDictionary, boolean revert) {
|
||||
private boolean handleRemoveFromDictionary(RedactionLog redactionLog, DossierEntity dossier, String fileId, String annotationId, AnnotationStatus status, boolean removeFromDictionary, boolean revert) {
|
||||
|
||||
if (status == AnnotationStatus.APPROVED) {
|
||||
|
||||
if (removeFromDictionary) {
|
||||
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(annotationId))
|
||||
@ -683,13 +665,16 @@ public class ManualRedactionService {
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (revert) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossier.getId(), fileId);
|
||||
} else {
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossier.getId(), fileId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, status, removeFromDictionary);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -698,8 +683,6 @@ public class ManualRedactionService {
|
||||
try {
|
||||
log.debug("Adding entry: {} to {} for {} / {}", value, typeId, dossierId, fileId);
|
||||
dictionaryController.addEntries(typeId, List.of(value), false, false);
|
||||
|
||||
reprocess(dossierId, fileId);
|
||||
} catch (Exception e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
@ -711,7 +694,6 @@ public class ManualRedactionService {
|
||||
try {
|
||||
log.debug("Deleting entries to {} for {} / {}", typeId, dossierId, fileId);
|
||||
dictionaryController.deleteEntries(typeId, List.of(value));
|
||||
reprocess(dossierId, fileId);
|
||||
} catch (FeignException e) {
|
||||
throw new BadRequestException(e.getMessage());
|
||||
}
|
||||
@ -720,17 +702,13 @@ public class ManualRedactionService {
|
||||
|
||||
private CommentEntity addComment(String fileId, String annotationId, String comment, String user) {
|
||||
|
||||
var createdComment = commentPersistenceService.insert(CommentEntity.builder()
|
||||
return commentPersistenceService.insert(CommentEntity.builder()
|
||||
.text(comment)
|
||||
.fileId(fileId)
|
||||
.annotationId(annotationId)
|
||||
.user(user)
|
||||
.date(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS))
|
||||
.build());
|
||||
|
||||
fileStatusPersistenceService.updateHasComments(fileId, true);
|
||||
|
||||
return createdComment;
|
||||
}
|
||||
|
||||
|
||||
@ -771,7 +749,7 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
private void handleAddToDictionary(String fileId, String annotationId, String typeId, String value, AnnotationStatus status, boolean addToDictionary,
|
||||
private boolean handleAddToDictionary(String fileId, String annotationId, String typeId, String value, AnnotationStatus status, boolean addToDictionary,
|
||||
boolean addToDossierDictionary, boolean revert, String dossierId) {
|
||||
|
||||
if (status == AnnotationStatus.APPROVED) {
|
||||
@ -783,9 +761,11 @@ public class ManualRedactionService {
|
||||
} else {
|
||||
addToDictionary(typeId, value, dossierId, fileId);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.integration.client.DossierClient;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.CreateOrUpdateDossierRequest;
|
||||
@ -257,10 +258,6 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
assertThat(fileClient.getDossierStatus(dossier.getId()).size()).isEqualTo(1);
|
||||
|
||||
BinaryFileRequest upload = new BinaryFileRequest("test".getBytes(StandardCharsets.UTF_8), "test.pdf", dossier.getId(), "1");
|
||||
JSONPrimitive<String> uploadResult = uploadClient.upload(upload);
|
||||
var secondFile = fileClient.getFileStatus(dossier.getId(), uploadResult.getValue());
|
||||
|
||||
var addRedaction = manualRedactionClient.addAddRedaction(dossierId, fileId, AddRedactionRequest.builder()
|
||||
.addToDictionary(true)
|
||||
.addToDossierDictionary(false)
|
||||
@ -272,34 +269,34 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
.value("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
var removeRedaction = manualRedactionClient.addRemoveRedaction(dossierId, fileId, RemoveRedactionRequest.builder()
|
||||
.annotationId("removeRedactionAnnotation")
|
||||
var removeRedaction = manualRedactionClient.addRemoveRedaction(dossierId, fileId, List.of(RemoveRedactionRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.removeFromDictionary(false)
|
||||
.build());
|
||||
var forceRedaction = manualRedactionClient.addForceRedaction(dossierId, fileId, ForceRedactionRequest.builder()
|
||||
.build())).get(0);
|
||||
var forceRedaction = manualRedactionClient.addForceRedaction(dossierId, fileId, List.of(ForceRedactionRequest.builder()
|
||||
.annotationId("forceRedactionAnnotation")
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
var legalBasisChange = manualRedactionClient.addLegalBasisChange(dossierId, fileId, LegalBasisChangeRequest.builder()
|
||||
.build())).get(0);
|
||||
var legalBasisChange = manualRedactionClient.addLegalBasisChange(dossierId, fileId, List.of(LegalBasisChangeRequest.builder()
|
||||
.annotationId("legalBasisChangeAnnotation")
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
var imageRecategorization = manualRedactionClient.addImageRecategorization(dossierId, fileId, ImageRecategorizationRequest.builder()
|
||||
.build())).get(0);
|
||||
var imageRecategorization = manualRedactionClient.addImageRecategorization(dossierId, fileId, List.of(ImageRecategorizationRequest.builder()
|
||||
.annotationId("imageRecategorizationAnnotation")
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.typeId("new-type:id")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
|
||||
var loadedFile = fileClient.getFileStatus(dossierId, fileId);
|
||||
|
||||
|
||||
@ -3,7 +3,9 @@ package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -14,17 +16,6 @@ import com.iqser.red.service.peristence.v1.server.integration.service.DossierTes
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.FileTesterAndProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.service.TypeProvider;
|
||||
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AddRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.CommentRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ForceRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ImageRecategorizationRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.LegalBasisChangeRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactions;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.Rectangle;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.RemoveRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ResizeRedactionRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.common.JSONPrimitive;
|
||||
|
||||
public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
@ -88,11 +79,17 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedAddRedaction.getTextAfter()).isEqualTo("Text After");
|
||||
assertThat(loadedAddRedaction.getTextBefore()).isEqualTo("Text Before");
|
||||
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(), addRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(addRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedAddRedaction = manualRedactionClient.getAddRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(), addRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(addRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedAddRedaction = manualRedactionClient.getAddRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedAddRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
@ -109,128 +106,170 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.section("section2")
|
||||
.build());
|
||||
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(), addRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateAddRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(addRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
var loadedAddRedaction2 = manualRedactionClient.getAddRedaction(file.getId(), addRedaction2.getAnnotationId());
|
||||
assertThat(loadedAddRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
assertThat(loadedAddRedaction2.isAddToDossierDictionary()).isEqualTo(false);
|
||||
assertThat(loadedAddRedaction2.isAddToDictionary()).isEqualTo(true);
|
||||
assertThat(loadedAddRedaction2.getSection()).contains("section2");
|
||||
|
||||
var removeRedaction = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), RemoveRedactionRequest.builder()
|
||||
var removeRedaction = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), List.of(RemoveRedactionRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.removeFromDictionary(false)
|
||||
.build());
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
.build())).get(0);
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
var loadedRemoveRedaction = manualRedactionClient.getRemoveRedaction(file.getId(), removeRedaction.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction.isRemoveFromDictionary()).isEqualTo(false);
|
||||
assertThat(loadedRemoveRedaction.getSoftDeletedTime()).isNull();
|
||||
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedRemoveRedaction = manualRedactionClient.getRemoveRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedRemoveRedaction = manualRedactionClient.getRemoveRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
var removeRedaction2 = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), RemoveRedactionRequest.builder()
|
||||
var removeRedaction2 = manualRedactionClient.addRemoveRedaction(dossier.getId(), file.getId(), List.of(RemoveRedactionRequest.builder()
|
||||
.annotationId("annotationId")
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.APPROVED)
|
||||
.user("test")
|
||||
.removeFromDictionary(true)
|
||||
.build());
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
.build())).get(0);
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
var loadedRemoveRedaction2 = manualRedactionClient.getRemoveRedaction(file.getId(), removeRedaction2.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
assertThat(dictionaryClient.getDictionaryForType(type.getId()).getEntries().isEmpty());
|
||||
assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isEqualTo(true);
|
||||
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedRemoveRedaction2 = manualRedactionClient.getRemoveRedaction(file.getId(), removeRedaction2.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), removeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(removeRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
loadedRemoveRedaction2 = manualRedactionClient.getRemoveRedaction(file.getId(), removeRedaction2.getAnnotationId());
|
||||
assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
|
||||
var forceRedaction = manualRedactionClient.addForceRedaction(dossier.getId(), file.getId(), ForceRedactionRequest.builder()
|
||||
var forceRedaction = manualRedactionClient.addForceRedaction(dossier.getId(), file.getId(), List.of(ForceRedactionRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedForceRedaction = manualRedactionClient.getForceRedaction(file.getId(), forceRedaction.getAnnotationId());
|
||||
assertThat(loadedForceRedaction.getLegalBasis()).isEqualTo("1");
|
||||
assertThat(loadedForceRedaction.getUser()).isEqualTo("test");
|
||||
assertThat(loadedForceRedaction.getAnnotationId()).isEqualTo(loadedForceRedaction.getAnnotationId());
|
||||
assertThat(loadedForceRedaction.getFileId()).isEqualTo(loadedForceRedaction.getFileId());
|
||||
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(), forceRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(forceRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedForceRedaction = manualRedactionClient.getForceRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(), forceRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(forceRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedForceRedaction = manualRedactionClient.getForceRedaction(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedForceRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
var legalBasisChange = manualRedactionClient.addLegalBasisChange(dossier.getId(), file.getId(), LegalBasisChangeRequest.builder()
|
||||
var legalBasisChange = manualRedactionClient.addLegalBasisChange(dossier.getId(), file.getId(), List.of(LegalBasisChangeRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedLegalBasisChange = manualRedactionClient.getLegalBasisChange(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange.getAnnotationId()).isEqualTo(legalBasisChange.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange.getUser()).isEqualTo("test");
|
||||
assertThat(loadedLegalBasisChange.getLegalBasis()).isEqualTo("1");
|
||||
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(), legalBasisChange.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(legalBasisChange.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedLegalBasisChange = manualRedactionClient.getLegalBasisChange(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(), legalBasisChange.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(legalBasisChange.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedLegalBasisChange = manualRedactionClient.getLegalBasisChange(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
var imageRecategorization = manualRedactionClient.addImageRecategorization(dossier.getId(), file.getId(), ImageRecategorizationRequest.builder()
|
||||
var imageRecategorization = manualRedactionClient.addImageRecategorization(dossier.getId(), file.getId(), List.of(ImageRecategorizationRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.REQUESTED)
|
||||
.user("test")
|
||||
.typeId("new-type:id")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedImageRecategorization = manualRedactionClient.getImageRecategorization(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedImageRecategorization.getAnnotationId()).isEqualTo(imageRecategorization.getAnnotationId());
|
||||
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(), imageRecategorization.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(imageRecategorization.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedImageRecategorization = manualRedactionClient.getImageRecategorization(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(), imageRecategorization.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(imageRecategorization.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedImageRecategorization = manualRedactionClient.getImageRecategorization(file.getId(), addRedaction.getAnnotationId());
|
||||
assertThat(loadedImageRecategorization.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
var imageRecategorization2 = manualRedactionClient.addImageRecategorization(dossier.getId(), file.getId(), ImageRecategorizationRequest.builder()
|
||||
var imageRecategorization2 = manualRedactionClient.addImageRecategorization(dossier.getId(), file.getId(), List.of(ImageRecategorizationRequest.builder()
|
||||
.annotationId(addRedaction2.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.APPROVED)
|
||||
.user("test")
|
||||
.typeId("new-type:id")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedImageRecategorization2 = manualRedactionClient.getImageRecategorization(file.getId(), imageRecategorization2.getAnnotationId());
|
||||
assertThat(loadedImageRecategorization2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(), imageRecategorization2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateImageRecategorizationStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(imageRecategorization2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
loadedImageRecategorization2 = manualRedactionClient.getImageRecategorization(file.getId(), imageRecategorization2.getAnnotationId());
|
||||
assertThat(loadedImageRecategorization2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
|
||||
var resizeRedaction = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
||||
var resizeRedaction = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), List.of(ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.page(1)
|
||||
.comment("comment")
|
||||
@ -240,7 +279,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.value("some value")
|
||||
.textAfter("Text After")
|
||||
.textBefore("Text Before")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
||||
assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
assertThat(loadedResizeRedaction.getUser()).isEqualTo("test");
|
||||
@ -249,11 +288,17 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(loadedResizeRedaction.getTextAfter()).isEqualTo("Text After");
|
||||
assertThat(loadedResizeRedaction.getTextBefore()).isEqualTo("Text Before");
|
||||
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.APPROVED));
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(resizeRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.APPROVED).build());
|
||||
loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
||||
assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.DECLINED));
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(resizeRedaction.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.DECLINED).build());
|
||||
loadedResizeRedaction = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction.getAnnotationId());
|
||||
assertThat(loadedResizeRedaction.getStatus()).isEqualTo(AnnotationStatus.DECLINED);
|
||||
|
||||
@ -266,60 +311,68 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(manualRedactions.getComments()).isNotEmpty();
|
||||
assertThat(manualRedactions.getResizeRedactions()).isNotEmpty();
|
||||
|
||||
manualRedactions.getForceRedactions()
|
||||
.forEach(e -> manualRedactionClient.deleteForceRedaction(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
List<String> annotationIds = manualRedactions.getForceRedactions().stream().map(f -> f.getAnnotationId()).collect(Collectors.toList());
|
||||
manualRedactionClient.deleteForceRedaction(dossier.getId(), file.getId(), annotationIds);
|
||||
// manualRedactions.getForceRedactions()
|
||||
// .forEach(e -> manualRedactionClient.deleteForceRedaction(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
manualRedactions.getLegalBasisChanges()
|
||||
.forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
manualRedactions.getEntriesToAdd()
|
||||
.forEach(e -> manualRedactionClient.deleteAddRedaction(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteAddRedaction(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
manualRedactions.getIdsToRemove()
|
||||
.forEach(e -> manualRedactionClient.deleteRemoveRedaction(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteRemoveRedaction(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
manualRedactions.getImageRecategorization()
|
||||
.forEach(e -> manualRedactionClient.deleteImageRecategorization(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteImageRecategorization(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
manualRedactions.getResizeRedactions()
|
||||
.forEach(e -> manualRedactionClient.deleteResizeRedaction(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteResizeRedaction(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
|
||||
manualRedactions.getComments()
|
||||
.forEach((key, value) -> value.forEach(c -> manualRedactionClient.deleteComment(file.getId(), c.getId())));
|
||||
.forEach((key, value) -> value.forEach(c -> manualRedactionClient.deleteComment(file.getId(), List.of(c.getId()))));
|
||||
|
||||
var forceRedaction2 = manualRedactionClient.addForceRedaction(dossier.getId(), file.getId(), ForceRedactionRequest.builder()
|
||||
var forceRedaction2 = manualRedactionClient.addForceRedaction(dossier.getId(), file.getId(), List.of(ForceRedactionRequest.builder()
|
||||
.annotationId(addRedaction2.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.APPROVED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedForceRedaction2 = manualRedactionClient.getForceRedaction(file.getId(), forceRedaction2.getAnnotationId());
|
||||
assertThat(loadedForceRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
assertThat(loadedForceRedaction2.getProcessedDate()).isNull();
|
||||
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(), forceRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateForceRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(forceRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
loadedForceRedaction2 = manualRedactionClient.getForceRedaction(file.getId(), forceRedaction2.getAnnotationId());
|
||||
assertThat(loadedForceRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
|
||||
manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId());
|
||||
manualRedactions.getForceRedactions()
|
||||
.forEach(e -> manualRedactionClient.deleteForceRedaction(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteForceRedaction(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
|
||||
var legalBasisChange2 = manualRedactionClient.addLegalBasisChange(dossier.getId(), file.getId(), LegalBasisChangeRequest.builder()
|
||||
var legalBasisChange2 = manualRedactionClient.addLegalBasisChange(dossier.getId(), file.getId(), List.of(LegalBasisChangeRequest.builder()
|
||||
.annotationId(addRedaction2.getAnnotationId())
|
||||
.comment("comment")
|
||||
.status(AnnotationStatus.APPROVED)
|
||||
.user("test")
|
||||
.legalBasis("1")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedLegalBasisChange2 = manualRedactionClient.getLegalBasisChange(file.getId(), legalBasisChange2.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(), legalBasisChange2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateLegalBasisChangeStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(legalBasisChange2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
loadedLegalBasisChange2 = manualRedactionClient.getLegalBasisChange(file.getId(), legalBasisChange2.getAnnotationId());
|
||||
assertThat(loadedLegalBasisChange2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
|
||||
manualRedactions = manualRedactionClient.getManualRedactions(dossier.getId(), file.getId());
|
||||
manualRedactions.getLegalBasisChanges()
|
||||
.forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), e.getAnnotationId()));
|
||||
.forEach(e -> manualRedactionClient.deleteLegalBasisChange(dossier.getId(), file.getId(), List.of(e.getAnnotationId())));
|
||||
|
||||
var resizeRedaction2 = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), ResizeRedactionRequest.builder()
|
||||
var resizeRedaction2 = manualRedactionClient.addResizeRedaction(dossier.getId(), file.getId(), List.of(ResizeRedactionRequest.builder()
|
||||
.annotationId(addRedaction.getAnnotationId())
|
||||
.page(1)
|
||||
.comment("comment")
|
||||
@ -327,14 +380,17 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.positions(List.of(Rectangle.builder().topLeftY(2).topLeftX(2).height(2).width(2).build()))
|
||||
.user("test")
|
||||
.value("some value")
|
||||
.build());
|
||||
.build())).get(0);
|
||||
var loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
||||
assertThat(loadedResizeRedaction2.getStatus()).isEqualTo(AnnotationStatus.APPROVED);
|
||||
assertThat(loadedResizeRedaction2.getUser()).isEqualTo("test");
|
||||
assertThat(loadedResizeRedaction2.getPositions()).isNotEmpty();
|
||||
assertThat(loadedResizeRedaction2.getValue()).isEqualTo("some value");
|
||||
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(), resizeRedaction2.getAnnotationId(), JSONPrimitive.of(AnnotationStatus.REQUESTED));
|
||||
manualRedactionClient.updateResizeRedactionStatus(dossier.getId(), file.getId(),
|
||||
UpdateRedactionRequest.builder()
|
||||
.annotationIds(List.of(resizeRedaction2.getAnnotationId()))
|
||||
.annotationStatus(AnnotationStatus.REQUESTED).build());
|
||||
loadedResizeRedaction2 = manualRedactionClient.getResizeRedaction(file.getId(), resizeRedaction2.getAnnotationId());
|
||||
assertThat(loadedResizeRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user