RED-8702: Explore document databases to store entityLog
* added new endpoints to query entitylog given pages and given starting analysisnumber, also refactored filter logic so that the filter is applied on query * refactored tests for above changes
This commit is contained in:
parent
d447a08c69
commit
7212b43693
@ -51,4 +51,26 @@ public class EntityLogController implements EntityLogResource {
|
||||
return entityLogResponseMapper.toLogResponse(entityLogService.getFilteredEntityLog(dossierId, fileId, filteredEntityLogRequest));
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public EntityLogResponse getEntityLogWithEntriesOnPages(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody List<Integer> pageNumbers) {
|
||||
|
||||
accessControlService.checkViewPermissionsToDossier(dossierId);
|
||||
accessControlService.validateFileResourceExistence(fileId);
|
||||
return entityLogResponseMapper.toLogResponse(entityLogService.getEntityLogWithEntriesOnPages(dossierId, fileId, pageNumbers));
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||
public EntityLogResponse getEntityLogWithEntriesAnalysedAfterIteration(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber) {
|
||||
|
||||
accessControlService.checkViewPermissionsToDossier(dossierId);
|
||||
accessControlService.validateFileResourceExistence(fileId);
|
||||
return entityLogResponseMapper.toLogResponse(entityLogService.getEntityLogWithEntriesHavingAnalysisNumberGreaterEquals(dossierId, fileId, analysisNumber));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,8 @@ public interface EntityLogResource {
|
||||
|
||||
String DOSSIER_ID = "dossierId";
|
||||
String DOSSIER_ID_PATH_VARIABLE = "/{" + DOSSIER_ID + "}";
|
||||
String ANALYSIS_NUMBER = "analysisNumber";
|
||||
String ANALYSIS_NUMBER_PATH_VARIABLE = "/{" + ANALYSIS_NUMBER + "}";
|
||||
|
||||
String FALSE = "false";
|
||||
|
||||
@ -45,10 +47,24 @@ public interface EntityLogResource {
|
||||
|
||||
|
||||
@PostMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE + "/filtered", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the entity log for a fileId grater than the specified date", description = "None")
|
||||
@Operation(summary = "Gets the entity log for a fileId greater than the specified date", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The dossier / file / entity log is not found.")})
|
||||
EntityLogResponse getFilteredEntityLog(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest);
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@RequestBody FilteredEntityLogRequest filteredEntityLogRequest);
|
||||
|
||||
|
||||
@PostMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE + "/pages", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the entity log for a fileId with all entities found on the given page numbers", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The dossier / file / entity log is not found.")})
|
||||
EntityLogResponse getEntityLogWithEntriesOnPages(@PathVariable(DOSSIER_ID) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody List<Integer> pageNumbers);
|
||||
|
||||
|
||||
@PostMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE + ANALYSIS_NUMBER_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Gets the entity log for a fileId with all entities being analysed in or after iteration with given number", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The dossier / file / entity log is not found.")})
|
||||
EntityLogResponse getEntityLogWithEntriesAnalysedAfterIteration(@PathVariable(DOSSIER_ID) String dossierId,
|
||||
@PathVariable(FILE_ID) String fileId,
|
||||
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber);
|
||||
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class SaasMigrationService implements TenantSyncService {
|
||||
|
||||
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.DOCUMENT_FILES_MIGRATED);
|
||||
|
||||
if(fileStatusPersistenceService.getStatus(fileId).getWorkflowStatus().equals(WorkflowStatus.APPROVED)) {
|
||||
if (fileStatusPersistenceService.getStatus(fileId).getWorkflowStatus().equals(WorkflowStatus.APPROVED)) {
|
||||
manualRedactionProviderService.convertUnprocessedAddToDictionariesToLocalChanges(fileId);
|
||||
}
|
||||
|
||||
@ -209,12 +209,10 @@ public class SaasMigrationService implements TenantSyncService {
|
||||
}
|
||||
|
||||
|
||||
//todo: 8702
|
||||
private boolean entityLogMigrationFilesExist(String dossierId, String fileId) {
|
||||
|
||||
return storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, ENTITY_LOG)) && storageService.objectExists(
|
||||
TenantContext.getTenantId(),
|
||||
StorageIdUtils.getStorageId(dossierId, fileId, FileType.MIGRATED_IDS));
|
||||
return storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, ENTITY_LOG))
|
||||
&& storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.MIGRATED_IDS));
|
||||
}
|
||||
|
||||
|
||||
@ -259,8 +257,6 @@ public class SaasMigrationService implements TenantSyncService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private int addManualRedactionEntries(List<ManualRedactionEntry> manualRedactionEntriesToAdd) {
|
||||
|
||||
return manualRedactionService.addManualRedactionEntries(manualRedactionEntriesToAdd, true);
|
||||
|
||||
@ -47,7 +47,7 @@ public class AnalysisFlagsCalculationService {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
var file = fileStatusPersistenceService.getStatus(fileId);
|
||||
var entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), true);
|
||||
var entityLog = entityLogService.getEntityLog(dossierId, fileId, true);
|
||||
|
||||
var viewedPagesForCurrentAssignee = viewedPagesPersistenceService.findViewedPages(fileId, file.getAssignee());
|
||||
|
||||
|
||||
@ -41,27 +41,36 @@ public class EntityLogService {
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLog(String dossierId, String fileId) {
|
||||
|
||||
return getEntityLog(dossierId, fileId, Collections.emptyList(), false);
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLog(dossierId, fileId);
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLog(String dossierId, String fileId, boolean includeUnProcessed) {
|
||||
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLog(dossierId, fileId);
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, includeUnProcessed);
|
||||
return entityLog;
|
||||
}
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLog(String dossierId, String fileId, List<String> excludedTypes, boolean includeUnProcessed) {
|
||||
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLogExcludeTypes(dossierId, fileId, excludedTypes);
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, includeUnProcessed);
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLog(String dossierId, String fileId, List<String> excludedTypes, boolean includeUnprocessed) {
|
||||
@Observed(name = "EntityLogService", contextualName = "post-process-entity-log")
|
||||
private void postProcessEntityLog(String dossierId, String fileId, EntityLog entityLog, boolean includeUnprocessed) {
|
||||
|
||||
var fileStatus = fileStatusService.getStatus(fileId);
|
||||
|
||||
EntityLog entityLog;
|
||||
|
||||
entityLog = fileManagementStorageService.getEntityLog(dossierId, fileId);
|
||||
|
||||
if (fileStatus.isExcluded()) {
|
||||
entityLog.setEntityLogEntry(new ArrayList<>());
|
||||
}
|
||||
|
||||
if (excludedTypes != null) {
|
||||
entityLog.getEntityLogEntry().removeIf(entry -> excludedTypes.contains(entry.getType()));
|
||||
}
|
||||
|
||||
if (includeUnprocessed) {
|
||||
DossierEntity dossier = dossierService.getDossierById(dossierId);
|
||||
ManualRedactions unprocessedManualRedactions = manualRedactionProviderService.getManualRedactions(fileId, ManualChangesQueryOptions.unprocessedOnly());
|
||||
@ -81,18 +90,18 @@ public class EntityLogService {
|
||||
Map<String, Integer> commentCountPerAnnotationId = commentService.getCommentCounts(fileId);
|
||||
entityLog.getEntityLogEntry()
|
||||
.forEach(entityLogEntry -> entityLogEntry.setNumberOfComments(commentCountPerAnnotationId.getOrDefault(entityLogEntry.getId(), 0)));
|
||||
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getFilteredEntityLog(String dossierId, String fileId, FilteredEntityLogRequest filteredEntityLogRequest) {
|
||||
|
||||
if (filteredEntityLogRequest.getSpecifiedDate() == null) {
|
||||
filteredEntityLogRequest.setSpecifiedDate(OffsetDateTime.MIN);
|
||||
}
|
||||
|
||||
var entityLog = getEntityLog(dossierId, fileId, filteredEntityLogRequest.getExcludedTypes(), false);
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLogExcludeTypes(dossierId, fileId, filteredEntityLogRequest.getExcludedTypes());
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
||||
var entityLogEntry = entityLog.getEntityLogEntry();
|
||||
|
||||
Iterator<EntityLogEntry> it = entityLogEntry.iterator();
|
||||
@ -122,4 +131,22 @@ public class EntityLogService {
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLogWithEntriesOnPages(String dossierId, String fileId, List<Integer> pageNumbers) {
|
||||
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLogStartingWithEntriesOnPages(dossierId, fileId, pageNumbers);
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
|
||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||
public EntityLog getEntityLogWithEntriesHavingAnalysisNumberGreaterEquals(String dossierId, String fileId, Integer analysisNumber) {
|
||||
|
||||
EntityLog entityLog = fileManagementStorageService.getEntityLogStartingFromAnalysisNumber(dossierId, fileId, analysisNumber);
|
||||
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
||||
return entityLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -103,11 +104,39 @@ public class FileManagementStorageService {
|
||||
public EntityLog getEntityLog(String dossierId, String fileId) {
|
||||
|
||||
return entityLogMongoService.findEntityLogByDossierIdAndFileId(dossierId, fileId)
|
||||
.orElseThrow(() -> new NotFoundException(String.format("EntityLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId)));
|
||||
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EntityLog getEntityLogExcludeTypes(String dossierId, String fileId, List<String> excludedTypes) {
|
||||
|
||||
return entityLogMongoService.findEntityLogWithoutExcludedEntryTypes(dossierId, fileId, excludedTypes)
|
||||
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public EntityLog getEntityLogStartingFromAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
||||
|
||||
return entityLogMongoService.findEntityLogWithEntriesStartingFromAnalysisNumber(dossierId, fileId, analysisNumber)
|
||||
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
||||
|
||||
}
|
||||
public EntityLog getEntityLogStartingWithEntriesOnPages(String dossierId, String fileId, List<Integer> pageNumbers) {
|
||||
|
||||
return entityLogMongoService.findEntityLogWithEntriesOnPages(dossierId, fileId, pageNumbers)
|
||||
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static String getEntityLogNotFoundErrorMessage(String dossierId, String fileId) {
|
||||
|
||||
return String.format("EntityLog does not exist for Dossier ID \"%s\" and File ID \"%s\"!", dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
public void saveEntityLog(String dossierId, String fileId, EntityLog entityLog) {
|
||||
|
||||
|
||||
@ -83,7 +83,7 @@ public class ManualRedactionMapper {
|
||||
boolean includeUnprocessed) {
|
||||
|
||||
List<RemoveRedactionRequest> requests = new ArrayList<>();
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, includeUnprocessed);
|
||||
for (var removeRedactionRequest : removeRedactionRequests) {
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, removeRedactionRequest.getAnnotationId());
|
||||
var removeRedactionRequestBuilder = RemoveRedactionRequest.builder()
|
||||
@ -142,7 +142,7 @@ public class ManualRedactionMapper {
|
||||
Set<RecategorizationRequestModel> recategorizationRequests,
|
||||
boolean includeUnprocessed) {
|
||||
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, includeUnprocessed);
|
||||
List<RecategorizationRequest> requests = new ArrayList<>();
|
||||
for (RecategorizationRequestModel recategorizationRequest : recategorizationRequests) {
|
||||
EntityLogEntry entityLogEntry = getEntityLogEntry(entityLog, recategorizationRequest.getAnnotationId());
|
||||
|
||||
@ -277,7 +277,7 @@ public class ManualRedactionService {
|
||||
|
||||
List<ManualAddResponse> response = new ArrayList<>();
|
||||
List<ManualResizeRedactionEntity> manualResizeRedactionEntities = new ArrayList<>();
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, includeUnprocessed);
|
||||
|
||||
for (ResizeRedactionRequest resizeRedactionRequest : resizeRedactionRequests) {
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ public class ManualRedactionUndoService {
|
||||
private void deleteRecategorization(String dossierId, String fileId, List<String> annotationIds, boolean includeUnprocessed) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), includeUnprocessed);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, includeUnprocessed);
|
||||
|
||||
for (var annotationId : annotationIds) {
|
||||
ManualRecategorizationEntity recategorizationEntity = recategorizationPersistenceService.findRecategorization(fileId, annotationId);
|
||||
@ -284,7 +284,7 @@ public class ManualRedactionUndoService {
|
||||
private void deleteRemoveRedaction(String dossierId, String fileId, List<String> annotationIds) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, Collections.emptyList(), true);
|
||||
EntityLog entityLog = entityLogService.getEntityLog(dossierId, fileId, true);
|
||||
|
||||
for (String annotationId : annotationIds) {
|
||||
|
||||
|
||||
@ -40,7 +40,6 @@ spring:
|
||||
data:
|
||||
mongodb:
|
||||
auto-index-creation: true
|
||||
# todo: multi-tenancy
|
||||
database: redaction
|
||||
host: ${MONGODB_HOST:localhost}
|
||||
port: 27017
|
||||
|
||||
@ -384,7 +384,7 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
0,
|
||||
0);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
assertThat(fileClient.getDossierStatus(dossier.getId()).size()).isEqualTo(1);
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), Mockito.anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
Assertions.assertThrows(FeignException.Forbidden.class,
|
||||
() -> manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
@ -335,7 +335,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -395,7 +395,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -450,7 +450,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -545,7 +545,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier1.getId(), file1.getId(), entityLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file1.getDossierId()), eq(file1.getFileId()), any(), anyBoolean())).thenReturn(entityLog1);
|
||||
when(entityLogService.getEntityLog(eq(file1.getDossierId()), eq(file1.getFileId()), anyBoolean())).thenReturn(entityLog1);
|
||||
|
||||
var entityLog2 = new EntityLog(1,
|
||||
1,
|
||||
@ -564,7 +564,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier2.getId(), file2.getId(), entityLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), any(), anyBoolean())).thenReturn(entityLog2);
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), anyBoolean())).thenReturn(entityLog2);
|
||||
|
||||
// resize redaction in dossier 1
|
||||
var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequestModel.builder()
|
||||
@ -710,7 +710,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier1.getId(), file1.getId(), entityLog1);
|
||||
var redactionRequest1 = RedactionRequest.builder().dossierId(file1.getDossierId()).fileId(file1.getFileId()).dossierTemplateId(file1.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file1.getDossierId()), eq(file1.getFileId()), any(), anyBoolean())).thenReturn(entityLog1);
|
||||
when(entityLogService.getEntityLog(eq(file1.getDossierId()), eq(file1.getFileId()), anyBoolean())).thenReturn(entityLog1);
|
||||
|
||||
var entityLog2 = new EntityLog(1,
|
||||
1,
|
||||
@ -729,7 +729,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier2.getId(), file2.getId(), entityLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), any(), anyBoolean())).thenReturn(entityLog2);
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), anyBoolean())).thenReturn(entityLog2);
|
||||
|
||||
// resize redaction in dossier 1
|
||||
var resizeRedactionDosAndAddToAllDos = ResizeRedactionRequestModel.builder()
|
||||
@ -898,7 +898,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier2.getId(), file2.getId(), entityLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), any(), anyBoolean())).thenReturn(entityLog2);
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), anyBoolean())).thenReturn(entityLog2);
|
||||
|
||||
// resize redaction in dossier dict
|
||||
var resizeRedactionDosTemp = ResizeRedactionRequestModel.builder()
|
||||
@ -1064,7 +1064,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier2.getId(), file2.getId(), entityLog2);
|
||||
var redactionRequest2 = RedactionRequest.builder().dossierId(file2.getDossierId()).fileId(file2.getFileId()).dossierTemplateId(file2.getDossierTemplateId()).build();
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), any(), anyBoolean())).thenReturn(entityLog2);
|
||||
when(entityLogService.getEntityLog(eq(file2.getDossierId()), eq(file2.getFileId()), anyBoolean())).thenReturn(entityLog2);
|
||||
|
||||
// resize redaction in dossier dict
|
||||
var resizeRedactionDosTemp = ResizeRedactionRequestModel.builder()
|
||||
@ -1188,7 +1188,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.recategorizeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1273,7 +1273,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.recategorizeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1453,7 +1453,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.removeRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1652,7 +1652,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
manualRedactionClient.recategorizeBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -1957,7 +1957,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
var recatModel = RecategorizationRequestModel.builder()
|
||||
.type(type.getType())
|
||||
@ -2045,8 +2045,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
fileManagementStorageService.storeJSONObject(dossier.getId(), file.getId(), FileType.ENTITY_LOG, entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), any(), anyBoolean())).thenReturn(entityLog);
|
||||
fileManagementStorageService.saveEntityLog(dossier.getId(), file.getId(), entityLog);
|
||||
when(entityLogService.getEntityLog(Mockito.any(), Mockito.any(), anyBoolean())).thenReturn(entityLog);
|
||||
|
||||
var recatModel = RecategorizationRequestModel.builder()
|
||||
.type(type.getType())
|
||||
|
||||
@ -22,7 +22,6 @@ spring:
|
||||
data:
|
||||
mongodb:
|
||||
auto-index-creation: true
|
||||
# todo: multi-tenancy
|
||||
database: redaction
|
||||
host: ${MONGODB_HOST:localhost}
|
||||
port: 27017
|
||||
|
||||
@ -2,7 +2,6 @@ package com.iqser.red.service.persistence.service.v1.api.shared.mongo.repository
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
import org.springframework.data.mongodb.repository.Query;
|
||||
@ -21,6 +20,10 @@ public interface EntityLogEntryDocumentRepository extends MongoRepository<Entity
|
||||
List<EntityLogEntryDocument> findByEntityLogIdAndChangesAnalysisNumber(String entityLogId, int analysisNumber);
|
||||
|
||||
|
||||
@Query("{ 'entityLogId' : ?0, 'changes.analysisNumber' : ?1 }")
|
||||
List<EntityLogEntryDocument> findByEntityLogIdAndChangesAnalysisNumberGreaterEquals(String entityLogId, Integer analysisNumber);
|
||||
|
||||
|
||||
@Query("{ 'entityLogId' : ?0}")
|
||||
List<EntityLogEntryDocument> findByEntityLogId(String entityLogId);
|
||||
|
||||
@ -34,13 +37,24 @@ public interface EntityLogEntryDocumentRepository extends MongoRepository<Entity
|
||||
|
||||
|
||||
@Query(value = "{ 'id' : { $in: ?0 }, 'containingNodeId' : { $exists: true, $not: { $size: 0 } } }", fields = "{ 'containingNodeId.0': 1 }")
|
||||
List<EntityLogEntryDocument> findContainingNodeIdForAllByIdAndContainingNodeIdNotEmpty(List<String> ids);
|
||||
List<EntityLogEntryDocument> findContainingNodeIdForAllByIdAndContainingNodeIdNotEmpty(List<String> ids);
|
||||
|
||||
|
||||
@Query("{ 'entityLogId' : ?0, $or: [ { 'containingNodeId' : { $exists: true, $eq: { $size: 0 } } }, { 'containingNodeId.0' : { $in: ?1 } } ] }")
|
||||
List<EntityLogEntryDocument> findByEntityLogIdAndNotContainedOrFirstContainedByElementInList(String entityLogId, Collection<Integer> containingNodeIds);
|
||||
|
||||
|
||||
@Query("{'entityLogId' : ?0, 'positions': { $elemMatch: { 'pageNumber': { $in: ?0 } } } }")
|
||||
List<EntityLogEntryDocument> findByEntityLogIdAndPositionsPageNumberIn(String entityLogId, List<Integer> pageNumbers);
|
||||
|
||||
|
||||
@Query(value = "{ 'entityLogId': ?0, 'type': { '$not': { '$in': ?1 } } }")
|
||||
List<EntityLogEntryDocument> findEntityLogDocumentByIdAndExcludedTypes(String entityLogId, List<String> excludedTypes);
|
||||
|
||||
|
||||
@Query(value = "{ 'entityLogId' : ?0}", delete = true)
|
||||
void deleteByEntityLogId(String entityLogId);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -243,6 +243,47 @@ public class EntityLogMongoService {
|
||||
}
|
||||
|
||||
|
||||
public Optional<EntityLog> findEntityLogWithoutExcludedEntryTypes(String dossierId, String fileId, List<String> excludedTypes) {
|
||||
|
||||
String entityLogId = mapper.getLogId(dossierId, fileId);
|
||||
Optional<EntityLog> optionalEntityLog = entityLogDocumentRepository.findEntityLogDocumentWithoutEntriesById(entityLogId)
|
||||
.map(mapper::fromLogDocument);
|
||||
optionalEntityLog.ifPresent(entityLog -> entityLog.getEntityLogEntry()
|
||||
.addAll(entityLogEntryDocumentRepository.findEntityLogDocumentByIdAndExcludedTypes(entityLogId, excludedTypes)
|
||||
.stream()
|
||||
.map(mapper::fromLogEntryDocument)
|
||||
.toList()));
|
||||
return optionalEntityLog;
|
||||
}
|
||||
|
||||
|
||||
public Optional<EntityLog> findEntityLogWithEntriesOnPages(String dossierId, String fileId, List<Integer> pageNumbers) {
|
||||
|
||||
String entityLogId = mapper.getLogId(dossierId, fileId);
|
||||
Optional<EntityLog> optionalEntityLog = entityLogDocumentRepository.findEntityLogDocumentWithoutEntriesById(entityLogId)
|
||||
.map(mapper::fromLogDocument);
|
||||
optionalEntityLog.ifPresent(entityLog -> entityLog.getEntityLogEntry()
|
||||
.addAll(entityLogEntryDocumentRepository.findByEntityLogIdAndPositionsPageNumberIn(entityLogId, pageNumbers)
|
||||
.stream()
|
||||
.map(mapper::fromLogEntryDocument)
|
||||
.toList()));
|
||||
return optionalEntityLog;
|
||||
}
|
||||
|
||||
public Optional<EntityLog> findEntityLogWithEntriesStartingFromAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
||||
|
||||
String entityLogId = mapper.getLogId(dossierId, fileId);
|
||||
Optional<EntityLog> optionalEntityLog = entityLogDocumentRepository.findEntityLogDocumentWithoutEntriesById(entityLogId)
|
||||
.map(mapper::fromLogDocument);
|
||||
optionalEntityLog.ifPresent(entityLog -> entityLog.getEntityLogEntry()
|
||||
.addAll(entityLogEntryDocumentRepository.findByEntityLogIdAndChangesAnalysisNumberGreaterEquals(entityLogId, analysisNumber)
|
||||
.stream()
|
||||
.map(mapper::fromLogEntryDocument)
|
||||
.toList()));
|
||||
return optionalEntityLog;
|
||||
}
|
||||
|
||||
|
||||
public void saveEntityLogWithoutEntries(String dossierId, String fileId, EntityLog entityLog) {
|
||||
|
||||
entityLogDocumentUpdateService.updateEntityLogDocumentWithoutEntries(dossierId, fileId, entityLog);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user