RED-3241: As a user I want to know the last modification date of the files UPDATE
This commit is contained in:
parent
afc847895e
commit
e734d81d80
@ -59,7 +59,7 @@ public class FileModel {
|
||||
private Set<Integer> excludedPages = new HashSet<>();
|
||||
private Map<String, String> fileAttributes = new HashMap<>();
|
||||
private String dossierId;
|
||||
private OffsetDateTime annotationModificationDate;
|
||||
private OffsetDateTime redactionModificationDate;
|
||||
|
||||
public boolean isAnalysisRequired(){
|
||||
return this.fullAnalysisRequired || this.reanalysisRequired;
|
||||
|
||||
@ -133,7 +133,7 @@ public class FileEntity {
|
||||
private int analysisVersion;
|
||||
|
||||
@Column
|
||||
private OffsetDateTime annotationModificationDate;
|
||||
private OffsetDateTime redactionModificationDate;
|
||||
|
||||
@Column(columnDefinition = "text", name = "excluded_pages")
|
||||
@Convert(converter = JSONIntegerSetConverter.class)
|
||||
|
||||
@ -347,9 +347,9 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setLastAnnotationModificationDateForFile(String fileId, OffsetDateTime changeDate) {
|
||||
public void setLastRedactionModificationDateForFile(String fileId, OffsetDateTime changeDate) {
|
||||
|
||||
fileRepository.setLastAnnotationModificationDateForFile(fileId, changeDate);
|
||||
fileRepository.setLastRedactionModificationDateForFile(fileId, changeDate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -137,8 +137,8 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
List<String> findDossierChangeByLastUpdatedIsAfter(OffsetDateTime since);
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query("update FileEntity f set f.annotationModificationDate = :annotationModificationDate where f.id = :fileId")
|
||||
void setLastAnnotationModificationDateForFile(String fileId, OffsetDateTime annotationModificationDate);
|
||||
@Query("update FileEntity f set f.redactionModificationDate = :redactionModificationDate where f.id = :fileId")
|
||||
void setLastRedactionModificationDateForFile(String fileId, OffsetDateTime redactionModificationDate);
|
||||
|
||||
@Query("select f from FileEntity f join DossierEntity d on d.id = f.dossierId where f.workflowStatus <> 'APPROVED' and f.excludedFromAutomaticAnalysis = false " +
|
||||
"and ( f.processingStatus = 'PROCESSED' or f.processingStatus = 'UNPROCESSED' or f.processingStatus = 'DELETED' or f.processingStatus = 'ERROR' )" +
|
||||
@ -148,6 +148,7 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query("update FileEntity f set f.lastFileAttributeChange = :date, f.lastUpdated = :date")
|
||||
void updateLastAttributeChangeDate(OffsetDateTime date);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ import java.time.OffsetDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -13,6 +14,7 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import com.iqser.red.service.redaction.v1.model.ChangeType;
|
||||
import com.iqser.red.service.redaction.v1.model.ManualRedactionType;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -58,7 +60,19 @@ public class AnalysisFlagsCalculationService {
|
||||
|
||||
var lastChange = entry.getChanges().isEmpty() ? null : entry.getChanges().get(entry.getChanges().size() - 1);
|
||||
|
||||
if (lastChange != null && (lastModification == null || lastChange.getDateTime().isAfter(lastModification))) {
|
||||
if (entry.getManualChanges() != null && !entry.getManualChanges().isEmpty() && !entry.isHint() && !entry.isRecommendation() && StringUtils.isNotEmpty(entry.getReason())) {
|
||||
for (var manualChange : entry.getManualChanges()) {
|
||||
if ((manualChange.getManualRedactionType().equals(ManualRedactionType.ADD_LOCALLY) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.REMOVE_LOCALLY) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.FORCE_REDACT) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.LEGAL_BASIS_CHANGE) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.RESIZE)) && manualChange.getProcessedDate().isAfter(lastModification)) {
|
||||
lastModification = manualChange.getProcessedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastChange != null && (lastModification == null || lastChange.getDateTime().isAfter(lastModification)) && !entry.isHint() && !entry.isRecommendation()) {
|
||||
lastModification = lastChange.getDateTime();
|
||||
}
|
||||
|
||||
@ -99,13 +113,8 @@ public class AnalysisFlagsCalculationService {
|
||||
fileStatusPersistenceService.updateFlags(fileId, hasRedactions, hasHints, hasImages, hasSuggestions, hasComments, hasUpdates);
|
||||
}
|
||||
|
||||
OffsetDateTime lastManualRedactionTime = file.getLastManualRedaction();
|
||||
if (lastModification == null || lastManualRedactionTime != null && lastManualRedactionTime.isAfter(lastModification)) {
|
||||
lastModification = lastManualRedactionTime;
|
||||
}
|
||||
|
||||
if (lastModification != null && (file.getAnnotationModificationDate() == null || file.getAnnotationModificationDate().isBefore(lastModification))) {
|
||||
fileStatusPersistenceService.setLastAnnotationModificationDateForFile(fileId, lastModification);
|
||||
if (lastModification != null && (file.getRedactionModificationDate() == null || file.getRedactionModificationDate().isBefore(lastModification))) {
|
||||
fileStatusPersistenceService.setLastRedactionModificationDateForFile(fileId, lastModification);
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,4 +124,4 @@ public class AnalysisFlagsCalculationService {
|
||||
return typeId.split(":")[0];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: changed-annotation-modification-date
|
||||
author: ali
|
||||
changes:
|
||||
- renameColumn:
|
||||
newColumnName: redaction_modification_date
|
||||
oldColumnName: annotation_modification_date
|
||||
tableName: file
|
||||
@ -17,3 +17,5 @@ databaseChangeLog:
|
||||
file: db/changelog/sql/7.1-set-json-fields.sql
|
||||
- include:
|
||||
file: db/changelog/sql/7.2-set-dossier-status.sql
|
||||
- include:
|
||||
file: db/changelog/9-changed-annotation-modification-date.changelog.yaml
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user