RED-7928: Reset ocr status values if ocr fails #312
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user