Pull request #313: Processed value for manual redactions that are dictionary entries

Merge in RED/persistence-service from processed-date-patch-m to master

* commit '01c129866a3c0bbf3550f51574a5710891536085':
  Processed value for manual redactions that are dictionary entries
This commit is contained in:
Timo Bejan 2022-03-21 09:54:33 +01:00
commit abe621570e
3 changed files with 16 additions and 4 deletions

View File

@ -9,6 +9,7 @@ import java.util.Set;
import javax.transaction.Transactional;
import com.iqser.red.service.persistence.service.v1.api.model.annotations.entitymapped.ManualRedactionEntry;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -41,7 +42,8 @@ public class AddRedactionPersistenceService {
manualRedactionEntry.setTypeId(addRedactionRequest.getTypeId());
manualRedactionEntry.setDictionaryEntryType(addRedactionRequest.getDictionaryEntryType());
if (addRedactionRequest.getStatus() == AnnotationStatus.APPROVED) {
if (addRedactionRequest.getStatus() == AnnotationStatus.APPROVED
&& !(addRedactionRequest.isAddToDictionary() || addRedactionRequest.isAddToDossierDictionary())) {
manualRedactionEntry.setProcessedDate(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
}
@ -125,4 +127,9 @@ public class AddRedactionPersistenceService {
manualRedactionRepository.updateStatus(fileIds, value, AnnotationStatus.REQUESTED, AnnotationStatus.APPROVED, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
}
@Transactional
public void markAsProcessed(ManualRedactionEntry e) {
manualRedactionRepository.markAsProcessed(new AnnotationEntityId(e.getAnnotationId(), e.getFileId()), OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
}
}

View File

@ -50,4 +50,7 @@ public interface ManualRedactionRepository extends JpaRepository<ManualRedaction
@Query("update ManualRedactionEntryEntity m set m.status = :newStatus, m.processedDate = :processedDate where m.id.fileId in :fileIds and m.value = :filterValue and m.addToDictionary = true and m.status = :filterStatus ")
void updateStatus(Set<String> fileIds, String filterValue, AnnotationStatus filterStatus, AnnotationStatus newStatus, OffsetDateTime processedDate);
@Modifying
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate where m.id = :annotationEntityId")
void markAsProcessed(AnnotationEntityId annotationEntityId, OffsetDateTime processedDate);
}

View File

@ -480,7 +480,7 @@ public class ManualRedactionService {
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId, DictionaryEntryType.ENTRY);
}
}
} else if(redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint()){
} else if (redactionLogEntryOptional.isPresent() && redactionLogEntryOptional.get().isHint()) {
reprocess(dossierId, fileId);
}
@ -597,6 +597,9 @@ public class ManualRedactionService {
// These are marked as processed once analysis completes, not when they are set as approved
if (manualRedactions != null) {
if (manualRedactions.getEntriesToAdd() != null) {
manualRedactions.getEntriesToAdd().forEach(addRedactionPersistenceService::markAsProcessed);
}
if (manualRedactions.getIdsToRemove() != null) {
manualRedactions.getIdsToRemove().forEach(removeRedactionPersistenceService::markAsProcessed);
}
@ -604,8 +607,7 @@ public class ManualRedactionService {
manualRedactions.getForceRedactions().forEach(forceRedactionPersistenceService::markAsProcessed);
}
if (manualRedactions.getImageRecategorization() != null) {
manualRedactions.getImageRecategorization()
.forEach(recategorizationPersistenceService::markAsProcessed);
manualRedactions.getImageRecategorization().forEach(recategorizationPersistenceService::markAsProcessed);
}
}
}