RED-5981 remove from dictionary pending analhysis
This commit is contained in:
parent
2dda4da6a1
commit
7e8d05b512
@ -23,4 +23,9 @@ public class BaseAnnotation {
|
||||
private OffsetDateTime processedDate;
|
||||
private OffsetDateTime softDeletedTime;
|
||||
|
||||
|
||||
public boolean isApproved() {
|
||||
return AnnotationStatus.APPROVED == status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -31,4 +31,5 @@ public class IdRemoval extends BaseAnnotation {
|
||||
this.removeFromDictionary = removeFromDictionary;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -28,14 +28,14 @@ public class RemoveRedactionPersistenceService {
|
||||
private final RemoveRedactionRepository removeRedactionRepository;
|
||||
|
||||
|
||||
public void insert(String fileId, RemoveRedactionRequest removeRedactionRequest) {
|
||||
public IdRemovalEntity insert(String fileId, RemoveRedactionRequest removeRedactionRequest) {
|
||||
|
||||
IdRemovalEntity idRemoval = new IdRemovalEntity();
|
||||
idRemoval.setId(new AnnotationEntityId(removeRedactionRequest.getAnnotationId(), fileId));
|
||||
BeanUtils.copyProperties(removeRedactionRequest, idRemoval);
|
||||
idRemoval.setRequestDate(OffsetDateTime.now());
|
||||
|
||||
removeRedactionRepository.saveAndFlush(idRemoval);
|
||||
return removeRedactionRepository.saveAndFlush(idRemoval);
|
||||
}
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ public class RemoveRedactionPersistenceService {
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
removeRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus, OffsetDateTime.now());
|
||||
removeRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus);
|
||||
}
|
||||
|
||||
|
||||
@ -91,7 +91,6 @@ public class RemoveRedactionPersistenceService {
|
||||
|
||||
removeRedactionRepository.updateStatusAndRemoveFromDictionary(new AnnotationEntityId(annotationId, fileId),
|
||||
annotationStatus,
|
||||
OffsetDateTime.now(),
|
||||
isAddOrRemoveFromDictionary);
|
||||
}
|
||||
|
||||
|
||||
@ -14,22 +14,19 @@ import com.iqser.red.service.persistence.service.v1.api.model.annotations.Annota
|
||||
|
||||
public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity, AnnotationEntityId> {
|
||||
|
||||
List<IdRemovalEntity> findByIdFileId(String fileId);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.softDeletedTime = :softDeletedTime " + "where idr.id = :annotationEntityId")
|
||||
@Query("update IdRemovalEntity idr set idr.softDeletedTime = :softDeletedTime where idr.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus, idr.processedDate = :processedDate " + "where idr.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus where idr.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus);
|
||||
|
||||
|
||||
@Modifying
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus, idr.processedDate = :processedDate, " + "idr.removeFromDictionary = :removeFromDictionary where idr.id = :annotationEntityId")
|
||||
void updateStatusAndRemoveFromDictionary(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate, boolean removeFromDictionary);
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus, idr.removeFromDictionary = :removeFromDictionary where idr.id = :annotationEntityId")
|
||||
void updateStatusAndRemoveFromDictionary(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, boolean removeFromDictionary);
|
||||
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id = :annotationEntityId and idr.softDeletedTime is null")
|
||||
|
||||
@ -15,6 +15,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.IdRemoval;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -197,7 +198,7 @@ public class ManualRedactionService {
|
||||
} else {
|
||||
|
||||
log.info("add removeRedaction for file {} and annotation {}", fileId, removeRedactionRequest.getAnnotationId());
|
||||
removeRedactionPersistenceService.insert(fileId, removeRedactionRequest);
|
||||
var idRemoval = convert(removeRedactionPersistenceService.insert(fileId, removeRedactionRequest), IdRemoval.class);
|
||||
|
||||
if (redactionLog == null) {
|
||||
redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), fileId);
|
||||
@ -213,7 +214,11 @@ public class ManualRedactionService {
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(removeRedactionRequest.getAnnotationId()))
|
||||
.findFirst();
|
||||
actionPerformed = actionPerformed || redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
|
||||
var requiresAnalysis = redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint();
|
||||
actionPerformed = actionPerformed || requiresAnalysis;
|
||||
if (!requiresAnalysis && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
}
|
||||
|
||||
var removedFromDictionary = handleRemoveFromDictionary(redactionLog,
|
||||
@ -224,6 +229,10 @@ public class ManualRedactionService {
|
||||
removeRedactionRequest.isRemoveFromDictionary(),
|
||||
false);
|
||||
|
||||
if (!removedFromDictionary && idRemoval.isApproved()) {
|
||||
removeRedactionPersistenceService.markAsProcessed(idRemoval);
|
||||
}
|
||||
|
||||
actionPerformed = actionPerformed || removedFromDictionary;
|
||||
|
||||
response.add(ManualAddResponse.builder().annotationId(removeRedactionRequest.getAnnotationId()).commentId(commentId).build());
|
||||
@ -572,11 +581,11 @@ public class ManualRedactionService {
|
||||
RedactionLog redactionLog = redactionLogService.getRedactionLog(dossierId, fileId, true, true);
|
||||
|
||||
for (var annotationId : annotationIds) {
|
||||
IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId);
|
||||
var idRemoval = convert(removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId), IdRemoval.class);
|
||||
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getId().getAnnotationId()))
|
||||
.filter(entry -> entry.getId().equals(idRemoval.getAnnotationId()))
|
||||
.findFirst();
|
||||
|
||||
if (redactionLogEntryOptional.isEmpty()) {
|
||||
@ -597,9 +606,10 @@ public class ManualRedactionService {
|
||||
// if it was previously approved, revert the delete
|
||||
if (idRemoval.getStatus() == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint()) {
|
||||
} else if (redactionLogEntryOptional.get().isHint()) {
|
||||
reprocess(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user