Merge branch 'RED-9849-bp' into 'release/2.465.x'

RED-9849: Counter for re-uploaded files

See merge request redactmanager/persistence-service!739
This commit is contained in:
Maverick Studer 2024-09-13 14:29:36 +02:00
commit ee42183d08
6 changed files with 20 additions and 2 deletions

View File

@ -201,6 +201,8 @@ public class FileEntity {
@ElementCollection
private List<FileEntityComponentMappingVersionEntity> componentMappingVersions;
@Column
private Integer overwriteFileCounter;
public OffsetDateTime getLastOCRTime() {

View File

@ -72,7 +72,6 @@ public class FileService {
if (existingStatus != null) {
// the file is already uploaded, just reanalyse it.
fileStatusService.overwriteFile(request.getDossierId(), request.getFileId(), request.getUploader(), request.getFilename(), keepManualRedactions, disableAutomaticAnalysis);
} else {
// the file is new, should create a new status for it.

View File

@ -66,6 +66,7 @@ public class FileStatusPersistenceService {
file.setLastUpdated(now);
file.setFileManipulationDate(now);
file.setProcessingErrorCounter(0);
file.setOverwriteFileCounter(0);
file.setFileSize(size);
file.setComponentMappingVersions(new ArrayList<>());
file.setExcludedFromAutomaticAnalysis(disableAutomaticAnalysis);

View File

@ -219,6 +219,7 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
+ "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, "
+ "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, "
+ "f.processingErrorCounter = 0, f.errorCause = null, f.errorQueue = null, f.errorService = null, "
+ "f.overwriteFileCounter = coalesce(f.overwriteFileCounter, 0) + 1, "
+ "f.errorTimestamp = null where f.id = :fileId")
int overwriteFile(@Param("fileId") String fileId,
@Param("filename") String filename,
@ -238,6 +239,7 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
+ "f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, "
+ "f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, "
+ "f.deleted = null, f.hardDeletedTime = null, f.hasHighlights = false, f.processingErrorCounter = 0, "
+ "f.overwriteFileCounter = coalesce(f.overwriteFileCounter, 0) + 1, "
+ "f.ocrStartTime = null, f.ocrEndTime = null, f.numberOfPagesToOCR = null, f.numberOfOCRedPages = null, "
+ "f.errorCause = null, f.errorQueue = null, f.errorService = null, f.errorTimestamp = null "
+ "where f.id = :fileId")

View File

@ -214,4 +214,6 @@ databaseChangeLog:
- include:
file: db/changelog/tenant/129-add-component-table.yaml
- include:
file: db/changelog/tenant/131-changed-max-size-for-id-in-entity.yaml
file: db/changelog/tenant/131-changed-max-size-for-id-in-entity.yaml
- include:
file: db/changelog/tenant/141-add-overwrite-file-counter-to-file.yaml

View File

@ -0,0 +1,12 @@
databaseChangeLog:
- changeSet:
id: add-overwrite-file-counter-to-file
author: maverick
changes:
- addColumn:
columns:
- column:
name: overwrite_file_counter
type: INTEGER
defaultValue: '0'
tableName: file