Master ports for analysis falgs calculation service
This commit is contained in:
parent
bfd03ed9d0
commit
0a6b5bc241
@ -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,14 @@ 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.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@ -30,7 +27,6 @@ public class AnalysisFlagsCalculationService {
|
||||
private final ViewedPagesPersistenceService viewedPagesPersistenceService;
|
||||
|
||||
|
||||
@Async
|
||||
public void calculateFlags(String dossierId, String fileId) {
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
@ -49,7 +45,7 @@ public class AnalysisFlagsCalculationService {
|
||||
boolean hasUpdates = false;
|
||||
boolean hasComments = false;
|
||||
|
||||
OffsetDateTime lastModification = null;
|
||||
OffsetDateTime lastRedactionModification = null;
|
||||
OffsetDateTime lastManualChangeDate = null;
|
||||
|
||||
for (RedactionLogEntry entry : redactionLog.getRedactionLogEntry()) {
|
||||
@ -61,21 +57,33 @@ public class AnalysisFlagsCalculationService {
|
||||
|
||||
var lastChange = entry.getChanges().isEmpty() ? null : entry.getChanges().get(entry.getChanges().size() - 1);
|
||||
|
||||
if (entry.getManualChanges() != null && !entry.getManualChanges().isEmpty() && !entry.isHint() && !entry.isRecommendation() && StringUtils.isNotEmpty(entry.getReason())) {
|
||||
if (entry.getManualChanges() != null && !entry.getManualChanges().isEmpty()) {
|
||||
|
||||
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)) {
|
||||
lastModification = manualChange.getProcessedDate();
|
||||
if (!entry.isHint() && !entry.isRecommendation() && StringUtils.isNotEmpty(entry.getReason()) &&
|
||||
(manualChange.getManualRedactionType().equals(ManualRedactionType.ADD_LOCALLY) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.RECATEGORIZE) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.REMOVE_LOCALLY) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.FORCE_REDACT) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.FORCE_HINT) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.LEGAL_BASIS_CHANGE) || manualChange.getManualRedactionType()
|
||||
.equals(ManualRedactionType.RESIZE)) && manualChange.getProcessedDate() != null &&
|
||||
(lastRedactionModification == null || manualChange.getProcessedDate().isAfter(lastRedactionModification))) {
|
||||
lastRedactionModification = manualChange.getProcessedDate();
|
||||
}
|
||||
|
||||
if (manualChange.getProcessedDate() != null && (lastManualChangeDate == null || manualChange.getProcessedDate().isAfter(lastManualChangeDate))) {
|
||||
lastManualChangeDate = manualChange.getProcessedDate();
|
||||
}
|
||||
|
||||
if (manualChange.getRequestedDate() != null && (lastManualChangeDate == null || manualChange.getRequestedDate().isAfter(lastManualChangeDate))) {
|
||||
lastManualChangeDate = manualChange.getRequestedDate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastChange != null && (lastModification == null || lastChange.getDateTime().isAfter(lastModification)) && !entry.isHint() && !entry.isRecommendation()) {
|
||||
lastModification = lastChange.getDateTime();
|
||||
if (lastChange != null && (lastRedactionModification == null || lastChange.getDateTime().isAfter(lastRedactionModification)) && !entry.isHint() && !entry.isRecommendation()) {
|
||||
lastRedactionModification = lastChange.getDateTime();
|
||||
}
|
||||
|
||||
if (!hasRedactions && entry.isRedacted() && !entry.isRecommendation()) {
|
||||
@ -115,12 +123,13 @@ public class AnalysisFlagsCalculationService {
|
||||
fileStatusPersistenceService.updateFlags(fileId, hasRedactions, hasHints, hasImages, hasSuggestions, hasComments, hasUpdates);
|
||||
}
|
||||
|
||||
if (lastModification != null && (file.getRedactionModificationDate() == null || file.getRedactionModificationDate().isBefore(lastModification))) {
|
||||
fileStatusPersistenceService.setLastRedactionModificationDateForFile(fileId, lastModification);
|
||||
if (lastRedactionModification != null && (file.getRedactionModificationDate() == null || file.getRedactionModificationDate().isBefore(lastRedactionModification))) {
|
||||
fileStatusPersistenceService.setLastRedactionModificationDateForFile(fileId, lastRedactionModification);
|
||||
}
|
||||
if (lastManualChangeDate != null) {
|
||||
fileStatusPersistenceService.setLastManualChangeDate(fileId, lastManualChangeDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user