RED-7928: Reset ocr status values if ocr fails #312

Merged
dominique.eiflaender1 merged 1 commits from RED-7928 into master 2024-01-17 15:45:40 +01:00
3 changed files with 18 additions and 1 deletions

View File

@ -65,6 +65,7 @@ public class FileStatusProcessingUpdateService {
}
@Transactional
public void preprocessingSuccessful(String dossierId, String fileId, UntouchedDocumentResponse untouchedDocumentResponse) {
@ -94,6 +95,7 @@ public class FileStatusProcessingUpdateService {
public void preprocessingFailed(String dossierId, String fileId, FileErrorInfo fileErrorInfo) {
if (fileErrorInfo != null && StringUtils.isEmpty(fileErrorInfo.getCause())) {
fileErrorInfo.setCause("preprocessingFailed");
}
@ -104,7 +106,11 @@ public class FileStatusProcessingUpdateService {
private void setStatusError(String dossierId, String fileId, FileErrorInfo fileErrorInfo) {
retryTemplate.execute(retryContext -> {
log.warn("Retrying {} time to set ERROR status for file {} in dossier {} with reason {} ", retryContext.getRetryCount(), fileId, dossierId, fileErrorInfo != null ? fileErrorInfo.getCause() : null);
log.warn("Retrying {} time to set ERROR status for file {} in dossier {} with reason {} ",
retryContext.getRetryCount(),
fileId,
dossierId,
fileErrorInfo != null ? fileErrorInfo.getCause() : null);
fileStatusService.setStatusError(fileId, fileErrorInfo);
return null;
});
@ -159,6 +165,7 @@ public class FileStatusProcessingUpdateService {
fileErrorInfo.setCause("ocrFailed");
}
setStatusError(dossierId, fileId, fileErrorInfo);
fileStatusPersistenceService.resetOcrStartAndEndDate(fileId);
}

View File

@ -549,6 +549,13 @@ public class FileStatusPersistenceService {
}
@Transactional
public void resetOcrStartAndEndDate(String fileId) {
fileRepository.resetOcrStartAndEndDate(fileId);
}
public void updateLayoutProcessedTime(String fileId) {
fileRepository.updateLayoutProcessedTime(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));

View File

@ -360,6 +360,9 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
@Query("select f.filename from FileEntity f where f.id = :fileId")
Optional<String> getFilenameById(@Param("fileId") String fileId);
@Modifying(clearAutomatically = true)
@Query("update FileEntity f set f.ocrStartTime = NULL, f.ocrEndTime = NULL, f.numberOfPagesToOCR = NULL, f.numberOfOCRedPages = NULL where f.id = :fileId")
void resetOcrStartAndEndDate(@Param("fileId") String fileId);
}