dossier status count
This commit is contained in:
parent
f998dd28d3
commit
86aed6b961
@ -29,11 +29,11 @@ public class FileModel {
|
||||
private OffsetDateTime deleted;
|
||||
private OffsetDateTime lastProcessed;
|
||||
private OffsetDateTime lastIndexed;
|
||||
private OffsetDateTime lastManualChangeDate;
|
||||
private int numberOfAnalyses;
|
||||
private String assignee;
|
||||
private String lastReviewer;
|
||||
private String lastApprover;
|
||||
private OffsetDateTime lastManualRedaction;
|
||||
private boolean hasRedactions;
|
||||
private boolean hasHints;
|
||||
private boolean hasSuggestions;
|
||||
|
||||
@ -69,9 +69,6 @@ public class FileEntity {
|
||||
@Column
|
||||
private String lastApprover;
|
||||
|
||||
@Column
|
||||
private OffsetDateTime lastManualRedaction;
|
||||
|
||||
@Column
|
||||
private boolean hasRedactions;
|
||||
|
||||
@ -138,6 +135,9 @@ public class FileEntity {
|
||||
@Column
|
||||
private OffsetDateTime fileManipulationDate;
|
||||
|
||||
@Column
|
||||
private OffsetDateTime lastManualChangeDate;
|
||||
|
||||
@Column(columnDefinition = "text", name = "excluded_pages")
|
||||
@Convert(converter = JSONIntegerSetConverter.class)
|
||||
private Set<Integer> excludedPages = new HashSet<>();
|
||||
|
||||
@ -139,16 +139,6 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastManualRedaction(String fileId, OffsetDateTime date) {
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateLastManualRedaction(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), date);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateStatusIndexingSuccessful(String fileId) {
|
||||
|
||||
@ -181,17 +171,6 @@ public class FileStatusPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime date, boolean hasSuggestions) {
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now()
|
||||
.truncatedTo(ChronoUnit.MILLIS), date, hasSuggestions);
|
||||
}
|
||||
|
||||
|
||||
public FileEntity getStatus(String fileId) {
|
||||
|
||||
return fileRepository.findById(fileId).orElseThrow(() -> new NotFoundException("Unknown file=" + fileId));
|
||||
@ -207,7 +186,6 @@ public class FileStatusPersistenceService {
|
||||
return;
|
||||
}
|
||||
|
||||
file.setLastManualRedaction(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setExcludedPages(excludedPages);
|
||||
}, () -> {
|
||||
@ -360,6 +338,12 @@ public class FileStatusPersistenceService {
|
||||
fileRepository.setLastRedactionModificationDateForFile(fileId, changeDate);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setLastManualChangeDate(String fileId, OffsetDateTime lastManualChangeDate) {
|
||||
|
||||
fileRepository.setLastManualChangeDate(fileId, lastManualChangeDate);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasChangesSince(String dossierId, OffsetDateTime since) {
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ public interface DossierStatusRepository extends JpaRepository<DossierStatusEnti
|
||||
|
||||
@Query("select new com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name," +
|
||||
"s.description, s.color, s.dossierTemplateId, count(d)) from DossierStatusEntity s left outer join s.dossiers d where s.dossierTemplateId in ( :dossierTemplateIds ) group by s")
|
||||
List<DossierStatusInfo> getAllDossierStatusForDossierTemplate(List<String> dossierTemplateId);
|
||||
List<DossierStatusInfo> getAllDossierStatusForDossierTemplate(List<String> dossierTemplateIds);
|
||||
|
||||
@Query("select new com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStatusInfo(s.id, s.name," +
|
||||
"s.description, s.color, s.dossierTemplateId, count(d)) from DossierStatusEntity s left outer join s.dossiers d where s.id = :dossierStatusId group by s")
|
||||
|
||||
@ -82,15 +82,6 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.hasAnnotationComments = :hasAnnotationComments where f.id = :fileId")
|
||||
void updateHasComments(String fileId, OffsetDateTime lastUpdated, boolean hasAnnotationComments);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastManualRedaction = :lastManualRedaction where f.id = :fileId")
|
||||
void updateLastManualRedaction(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastManualRedaction);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastManualRedaction = :lastManualRedaction, " +
|
||||
"f.hasSuggestions = :hasSuggestions where f.id = :fileId")
|
||||
void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastManualRedaction,
|
||||
boolean hasSuggestions);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, " +
|
||||
@ -126,7 +117,7 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
@Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " +
|
||||
"f.workflowStatus = :workflowStatus, f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, f.fileManipulationDate = :lastUploaded, " +
|
||||
"f.lastOCRTime = null, f.excluded = false, f.lastProcessed = null, f.lastReviewer = null, f.lastApprover = null, " +
|
||||
"f.assignee = null, f.approvalDate = null, f.lastManualRedaction = null, f.numberOfAnalyses = 0, " +
|
||||
"f.assignee = null, f.approvalDate = null, f.numberOfAnalyses = 0, f.lastManualChangeDate = null, f.redactionModificationDate = null," +
|
||||
"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 " +
|
||||
@ -144,6 +135,10 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
@Query("update FileEntity f set f.redactionModificationDate = :redactionModificationDate where f.id = :fileId")
|
||||
void setLastRedactionModificationDateForFile(String fileId, OffsetDateTime redactionModificationDate);
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query("update FileEntity f set f.lastManualChangeDate = :lastManualChangeDate where f.id = :fileId")
|
||||
void setLastManualChangeDate(String fileId, OffsetDateTime lastManualChangeDate);
|
||||
|
||||
@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' )" +
|
||||
"and d.softDeletedTime is null and d.hardDeletedTime is null and d.status = 'ACTIVE' " )
|
||||
|
||||
@ -1,80 +0,0 @@
|
||||
package com.iqser.red.service.peristence.v1.server.acl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCache;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
|
||||
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
|
||||
import org.springframework.security.acls.AclPermissionEvaluator;
|
||||
import org.springframework.security.acls.domain.AclAuthorizationStrategy;
|
||||
import org.springframework.security.acls.domain.ConsoleAuditLogger;
|
||||
import org.springframework.security.acls.domain.DefaultPermissionGrantingStrategy;
|
||||
import org.springframework.security.acls.domain.SpringCacheBasedAclCache;
|
||||
import org.springframework.security.acls.jdbc.BasicLookupStrategy;
|
||||
import org.springframework.security.acls.jdbc.JdbcMutableAclService;
|
||||
import org.springframework.security.acls.jdbc.LookupStrategy;
|
||||
import org.springframework.security.acls.model.PermissionGrantingStrategy;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@RequiredArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
public class AclMethodSecurityConfiguration extends GlobalMethodSecurityConfiguration {
|
||||
|
||||
private final MethodSecurityExpressionHandler defaultMethodSecurityExpressionHandler;
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
@Bean
|
||||
public AclAuthorizationStrategy aclAuthorizationStrategy() {
|
||||
return (acl, changeType) -> {
|
||||
// no-op
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PermissionGrantingStrategy permissionGrantingStrategy() {
|
||||
return new DefaultPermissionGrantingStrategy(new ConsoleAuditLogger());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SpringCacheBasedAclCache aclCache() {
|
||||
return new SpringCacheBasedAclCache(new ConcurrentMapCache("acl"),
|
||||
permissionGrantingStrategy(),
|
||||
aclAuthorizationStrategy()
|
||||
);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LookupStrategy lookupStrategy() {
|
||||
return new BasicLookupStrategy(
|
||||
dataSource,
|
||||
aclCache(),
|
||||
aclAuthorizationStrategy(),
|
||||
new ConsoleAuditLogger()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MethodSecurityExpressionHandler createExpressionHandler() {
|
||||
return defaultMethodSecurityExpressionHandler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MethodSecurityExpressionHandler defaultMethodSecurityExpressionHandler() {
|
||||
DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler();
|
||||
AclPermissionEvaluator permissionEvaluator = new AclPermissionEvaluator(aclService());
|
||||
expressionHandler.setPermissionEvaluator(permissionEvaluator);
|
||||
return expressionHandler;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JdbcMutableAclService aclService() {
|
||||
return new JdbcMutableAclService(dataSource, lookupStrategy(), aclCache());
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,5 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
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;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ViewedPageEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.ViewedPagesPersistenceService;
|
||||
@ -16,9 +8,15 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.do
|
||||
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;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -50,6 +48,7 @@ public class AnalysisFlagsCalculationService {
|
||||
boolean hasComments = false;
|
||||
|
||||
OffsetDateTime lastModification = null;
|
||||
OffsetDateTime lastManualChangeDate = null;
|
||||
|
||||
for (RedactionLogEntry entry : redactionLog.getRedactionLogEntry()) {
|
||||
if (entry.isExcluded()) {
|
||||
@ -64,10 +63,11 @@ public class AnalysisFlagsCalculationService {
|
||||
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()!= null && manualChange.getProcessedDate().isAfter(lastModification)) {
|
||||
.equals(ManualRedactionType.FORCE_REDACT) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.LEGAL_BASIS_CHANGE) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.RESIZE)) && manualChange.getProcessedDate() != null && manualChange.getProcessedDate().isAfter(lastModification)) {
|
||||
lastModification = manualChange.getProcessedDate();
|
||||
lastManualChangeDate = manualChange.getProcessedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,6 +116,9 @@ public class AnalysisFlagsCalculationService {
|
||||
if (lastModification != null && (file.getRedactionModificationDate() == null || file.getRedactionModificationDate().isBefore(lastModification))) {
|
||||
fileStatusPersistenceService.setLastRedactionModificationDateForFile(fileId, lastModification);
|
||||
}
|
||||
if (lastManualChangeDate != null) {
|
||||
fileStatusPersistenceService.setLastManualChangeDate(fileId, lastManualChangeDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -124,4 +127,4 @@ public class AnalysisFlagsCalculationService {
|
||||
return typeId.split(":")[0];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +255,6 @@ public class ManualRedactionService {
|
||||
|
||||
var createdComment = addComment(fileId, annotationId, commentRequest.getText(), commentRequest.getUser());
|
||||
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
fileStatusPersistenceService.updateHasComments(fileId, true);
|
||||
|
||||
return createdComment;
|
||||
@ -387,7 +386,6 @@ public class ManualRedactionService {
|
||||
|
||||
public void deleteComment(String fileId, List<Long> commentIds) {
|
||||
|
||||
fileStatusPersistenceService.updateLastManualRedaction(fileId, OffsetDateTime.now());
|
||||
for (var commentId : commentIds) {
|
||||
commentPersistenceService.softDelete(commentId, OffsetDateTime.now());
|
||||
}
|
||||
@ -473,8 +471,6 @@ public class ManualRedactionService {
|
||||
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
@ -486,8 +482,6 @@ public class ManualRedactionService {
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
for (var annotationId : annotationIds) {
|
||||
forceRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
@ -506,8 +500,6 @@ public class ManualRedactionService {
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
for (var annotationId : annotationIds) {
|
||||
legalBasisChangePersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
@ -526,8 +518,6 @@ public class ManualRedactionService {
|
||||
actionPerformed = actionPerformed || AnnotationStatus.APPROVED.equals(annotationStatus);
|
||||
|
||||
recategorizationPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
if (actionPerformed) {
|
||||
reprocess(dossierId, fileId);
|
||||
@ -553,8 +543,6 @@ public class ManualRedactionService {
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
for (var annotationId : annotationIds) {
|
||||
resizeRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus);
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
@ -583,9 +571,6 @@ public class ManualRedactionService {
|
||||
|
||||
addRedactionPersistenceService.updateStatus(fileId, annotationId, annotationStatus, OffsetDateTime.now()
|
||||
.truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
// boolean hasSuggestions = calculateHasSuggestions(fileId);
|
||||
// fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), hasSuggestions);
|
||||
}
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ databaseChangeLog:
|
||||
- addColumn:
|
||||
columns:
|
||||
- column:
|
||||
name: visbility
|
||||
name: visibility
|
||||
type: VARCHAR(40)
|
||||
defaultValue: PUBLIC
|
||||
tableName: dossier
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
databaseChangeLog:
|
||||
- changeSet:
|
||||
id: add-file-manual-change-date-column
|
||||
author: timo
|
||||
changes:
|
||||
- removeColumn:
|
||||
columns:
|
||||
- name: last_manual_redaction
|
||||
tableName: file
|
||||
- addColumn:
|
||||
columns:
|
||||
- column:
|
||||
name: last_manual_change_date
|
||||
type: TIMESTAMP WITHOUT TIME ZONE
|
||||
defaultValue: now()
|
||||
tableName: file
|
||||
@ -24,4 +24,8 @@ databaseChangeLog:
|
||||
- include:
|
||||
file: db/changelog/sql/10-set-file-manipulation-date.sql
|
||||
- include:
|
||||
file: db/changelog/11-added-dictionary_false_positive_tables.changelog.yaml
|
||||
file: db/changelog/11-added-dictionary_false_positive_tables.changelog.yaml
|
||||
- include:
|
||||
file: db/changelog/12-dossier-visibility.changelog.yaml
|
||||
- include:
|
||||
file: db/changelog/13-file-manual-change-date.changelog.yaml
|
||||
|
||||
@ -158,7 +158,6 @@ public class FilePerformanceTest extends AbstractPersistenceServerServiceTest {
|
||||
f.setLastUploaded(OffsetDateTime.now());
|
||||
f.setLastProcessed(OffsetDateTime.now());
|
||||
f.setLastFileAttributeChange(OffsetDateTime.now());
|
||||
f.setLastManualRedaction(OffsetDateTime.now());
|
||||
f.setDossierId(d.getId());
|
||||
files.add(f);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user