RED-3287: Improve RedactionLog Controller to allow incremental calls
This commit is contained in:
parent
38cce583aa
commit
a2727246e1
@ -1,5 +1,6 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
@ -34,4 +35,11 @@ public interface RedactionLogResource {
|
||||
@GetMapping(value = SECTION_GRID_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
SectionGrid getSectionGrid(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId);
|
||||
|
||||
@GetMapping(value = REDACTION_LOG_PATH + DOSSIER_ID_PATH_PARAM + FILE_ID_PATH_VARIABLE + "/filtered", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
RedactionLog getFilteredRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
||||
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions,
|
||||
@RequestParam(value = "includeFalsePositives", required = false, defaultValue = "false") boolean includeFalsePositives,
|
||||
@RequestParam(value = "specifiedDate") OffsetDateTime specifiedDate);
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.iqser.red.service.peristence.v1.server.controller;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -35,4 +36,12 @@ public class RedactionLogController implements RedactionLogResource {
|
||||
return redactionLogService.getSectionGrid(dossierId, fileId);
|
||||
}
|
||||
|
||||
public RedactionLog getFilteredRedactionLog(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId,
|
||||
@RequestParam(value = "excludedType", required = false) List<String> excludedTypes,
|
||||
@RequestParam(value = "withManualRedactions", required = false, defaultValue = "true") boolean withManualRedactions,
|
||||
@RequestParam(value = "includeFalsePositives", required = false, defaultValue = "false") boolean includeFalsePositives,
|
||||
@RequestParam(value = "specifiedDate") OffsetDateTime specifiedDate) {
|
||||
return redactionLogService.getFilteredRedactionLog(dossierId, fileId, excludedTypes, withManualRedactions, includeFalsePositives, specifiedDate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -9,7 +12,11 @@ import com.iqser.red.service.peristence.v1.server.client.RedactionClient;
|
||||
import com.iqser.red.service.peristence.v1.server.controller.DictionaryController;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.Comment;
|
||||
import com.iqser.red.service.redaction.v1.model.Change;
|
||||
import com.iqser.red.service.redaction.v1.model.ManualChange;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
||||
import com.iqser.red.service.redaction.v1.model.SectionGrid;
|
||||
|
||||
@ -85,4 +92,78 @@ public class RedactionLogService {
|
||||
return fileManagementStorageService.getSectionGrid(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
public RedactionLog getFilteredRedactionLog(String dossierId, String fileId, List<String> excludedTypes, boolean withManualRedactions, boolean includeFalsePositives,
|
||||
OffsetDateTime specifiedDate) {
|
||||
|
||||
var redactionLog = getRedactionLog(dossierId, fileId, excludedTypes, withManualRedactions, includeFalsePositives);
|
||||
|
||||
List<RedactionLogEntry> filteredRedactionLogEntries = new ArrayList<>();
|
||||
RedactionLog filteredRedactionLog = new RedactionLog(redactionLog.getAnalysisVersion(), redactionLog.getAnalysisNumber(), filteredRedactionLogEntries, redactionLog.getLegalBasis(), redactionLog.getDictionaryVersion(), redactionLog.getDossierDictionaryVersion(), redactionLog.getRulesVersion(), redactionLog.getLegalBasisVersion());
|
||||
|
||||
for (var redactionLogEntry : redactionLog.getRedactionLogEntry()) {
|
||||
RedactionLogEntry frle = RedactionLogEntry.builder()
|
||||
.id(redactionLogEntry.getId())
|
||||
.type(redactionLogEntry.getType())
|
||||
.value(redactionLogEntry.getValue())
|
||||
.reason(redactionLogEntry.getReason())
|
||||
.matchedRule(redactionLogEntry.getMatchedRule())
|
||||
.rectangle(redactionLogEntry.isRectangle())
|
||||
.legalBasis(redactionLogEntry.getLegalBasis())
|
||||
.imported(redactionLogEntry.isImported())
|
||||
.redacted(redactionLogEntry.isRedacted())
|
||||
.isHint(redactionLogEntry.isHint())
|
||||
.isRecommendation(redactionLogEntry.isRecommendation())
|
||||
.isFalsePositive(redactionLogEntry.isFalsePositive())
|
||||
.section(redactionLogEntry.getSection())
|
||||
.color(redactionLogEntry.getColor())
|
||||
.positions(redactionLogEntry.getPositions())
|
||||
.sectionNumber(redactionLogEntry.getSectionNumber())
|
||||
.textBefore(redactionLogEntry.getTextBefore())
|
||||
.textAfter(redactionLogEntry.getTextAfter())
|
||||
.startOffset(redactionLogEntry.getStartOffset())
|
||||
.endOffset(redactionLogEntry.getEndOffset())
|
||||
.isImage(redactionLogEntry.isImage())
|
||||
.imageHasTransparency(redactionLogEntry.isImageHasTransparency())
|
||||
.isDictionaryEntry(redactionLogEntry.isDictionaryEntry())
|
||||
.isDossierDictionaryEntry(redactionLogEntry.isDossierDictionaryEntry())
|
||||
.excluded(redactionLogEntry.isExcluded())
|
||||
.engines(redactionLogEntry.getEngines())
|
||||
.reference(redactionLogEntry.getReference())
|
||||
.build();
|
||||
|
||||
var changes = redactionLogEntry.getChanges();
|
||||
List<Change> filteredChanges = new ArrayList<>();
|
||||
for (var change : changes) {
|
||||
if (change.getDateTime().isAfter(specifiedDate)) {
|
||||
filteredChanges.add(change);
|
||||
}
|
||||
}
|
||||
frle.setChanges(filteredChanges);
|
||||
|
||||
var manualChanges = redactionLogEntry.getManualChanges();
|
||||
List<ManualChange> filteredManualChanges = new ArrayList<>();
|
||||
for (var manualChange: manualChanges){
|
||||
if(manualChange.getProcessedDate().isAfter(specifiedDate)) {
|
||||
filteredManualChanges.add(manualChange);
|
||||
}
|
||||
}
|
||||
frle.setManualChanges(filteredManualChanges);
|
||||
|
||||
var comments = redactionLogEntry.getComments();
|
||||
List<Comment> filteredComments = new ArrayList<>();
|
||||
for (var comment: comments) {
|
||||
if(comment.getSoftDeletedTime() != null && comment.getSoftDeletedTime().isAfter(specifiedDate) || comment.getDate().isAfter(specifiedDate)) {
|
||||
filteredComments.add(comment);
|
||||
}
|
||||
}
|
||||
frle.setComments(filteredComments);
|
||||
|
||||
filteredRedactionLogEntries.add(frle);
|
||||
}
|
||||
filteredRedactionLog.setRedactionLogEntry(filteredRedactionLogEntries);
|
||||
|
||||
return filteredRedactionLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package com.iqser.red.service.peristence.v1.server.integration.tests;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@ -30,6 +32,15 @@ public class RedactionLogTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(redactionLogClient.getSectionGrid(dossier.getId(), file.getId())).isNotNull();
|
||||
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null, true, false)).isNotNull();
|
||||
assertThat(redactionLogClient.getRedactionLog(dossier.getId(), file.getId(), null, false, false)).isNotNull();
|
||||
assertThat(redactionLogClient.getFilteredRedactionLog(dossier.getId(), file.getId(), null, true, false, OffsetDateTime.now())).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilteredRedactionLog() {
|
||||
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier();
|
||||
var file = fileTesterAndProvider.testAndProvideFile(dossier);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user