RED-9140 - Add more information to changes
This commit is contained in:
parent
05679289a3
commit
aa25e9c25c
@ -64,13 +64,13 @@ public class EntityLogController implements EntityLogResource {
|
|||||||
|
|
||||||
|
|
||||||
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
@PreAuthorize("hasAuthority('" + READ_REDACTION_LOG + "')")
|
||||||
public EntityLogResponse getEntityLogWithEntriesAnalysedAfterIteration(@PathVariable(DOSSIER_ID) String dossierId,
|
public EntityLogResponse getEntityLogDeltaUpdate(@PathVariable(DOSSIER_ID) String dossierId,
|
||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber) {
|
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber) {
|
||||||
|
|
||||||
accessControlService.checkViewPermissionsToDossier(dossierId);
|
accessControlService.checkViewPermissionsToDossier(dossierId);
|
||||||
accessControlService.validateFileResourceExistence(fileId);
|
accessControlService.validateFileResourceExistence(fileId);
|
||||||
return entityLogResponseMapper.toLogResponse(entityLogService.getEntityLogWithEntriesWithEntriesByAnalysisNumber(dossierId, fileId, analysisNumber));
|
return entityLogResponseMapper.toLogResponse(entityLogService.getEntityLogWithEntriesWithEntriesSinceAnalysisNumber(dossierId, fileId, analysisNumber));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public interface EntityLogResource {
|
|||||||
@GetMapping(value = ENTITY_LOG_PATH + DOSSIER_ID_PATH_VARIABLE + FILE_ID_PATH_VARIABLE + ANALYSIS_NUMBER_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
@GetMapping(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")
|
@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.")})
|
@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,
|
EntityLogResponse getEntityLogDeltaUpdate(@PathVariable(DOSSIER_ID) String dossierId,
|
||||||
@PathVariable(FILE_ID) String fileId,
|
@PathVariable(FILE_ID) String fileId,
|
||||||
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber);
|
@PathVariable(ANALYSIS_NUMBER) Integer analysisNumber);
|
||||||
|
|
||||||
|
|||||||
@ -142,9 +142,9 @@ public class EntityLogService {
|
|||||||
|
|
||||||
|
|
||||||
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
@Observed(name = "EntityLogService", contextualName = "get-entity-log")
|
||||||
public EntityLog getEntityLogWithEntriesWithEntriesByAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
public EntityLog getEntityLogWithEntriesWithEntriesSinceAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
||||||
|
|
||||||
EntityLog entityLog = fileManagementStorageService.getEntityLogWithEntriesByAnalysisNumber(dossierId, fileId, analysisNumber);
|
EntityLog entityLog = fileManagementStorageService.getEntityLogWithEntriesSinceAnalysisNumber(dossierId, fileId, analysisNumber);
|
||||||
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
postProcessEntityLog(dossierId, fileId, entityLog, false);
|
||||||
return entityLog;
|
return entityLog;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,9 +117,9 @@ public class FileManagementStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public EntityLog getEntityLogWithEntriesByAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
public EntityLog getEntityLogWithEntriesSinceAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
||||||
|
|
||||||
return entityLogMongoService.findEntityLogWithEntriesByAnalysisNumber(dossierId, fileId, analysisNumber)
|
return entityLogMongoService.findEntityLogWithEntriesSinceAnalysisNumber(dossierId, fileId, analysisNumber)
|
||||||
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
.orElseThrow(() -> new NotFoundException(getEntityLogNotFoundErrorMessage(dossierId, fileId)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ public class EntityLogMongoServiceTest extends AbstractPersistenceServerServiceT
|
|||||||
private final String ENTITY_LOG2 = "files/entity-log/6f2a9d4b5d4e11211fc0d7732fd45b78.ENTITY_LOG.json";
|
private final String ENTITY_LOG2 = "files/entity-log/6f2a9d4b5d4e11211fc0d7732fd45b78.ENTITY_LOG.json";
|
||||||
private final String ENTITY_LOG3_BEFORE = "files/entity-log/c3b23116f2d277170d303bfc6fb82e6a-before.ENTITY_LOG.json";
|
private final String ENTITY_LOG3_BEFORE = "files/entity-log/c3b23116f2d277170d303bfc6fb82e6a-before.ENTITY_LOG.json";
|
||||||
private final String ENTITY_LOG3_AFTER = "files/entity-log/c3b23116f2d277170d303bfc6fb82e6a-after.ENTITY_LOG.json";
|
private final String ENTITY_LOG3_AFTER = "files/entity-log/c3b23116f2d277170d303bfc6fb82e6a-after.ENTITY_LOG.json";
|
||||||
|
private final String ENTITY_LOG_WITH_CHANGES = "files/entity-log/entitylog-with-changes.json";
|
||||||
|
|
||||||
private static final String TEST_DOSSIER_ID = "91ce8e90-9aec-473c-b8c3-cbe16443ad34";
|
private static final String TEST_DOSSIER_ID = "91ce8e90-9aec-473c-b8c3-cbe16443ad34";
|
||||||
private static final String TEST_FILE1_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
private static final String TEST_FILE1_ID = "b2cbdd4dca0aa1aa0ebbfc5cc1462df0";
|
||||||
@ -305,4 +306,24 @@ public class EntityLogMongoServiceTest extends AbstractPersistenceServerServiceT
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SneakyThrows
|
||||||
|
public void testGetEntityLogDeltaUpdate() {
|
||||||
|
|
||||||
|
var file = new ClassPathResource(ENTITY_LOG_WITH_CHANGES);
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
|
||||||
|
EntityLog entityLog = objectMapper.readValue(file.getInputStream(), EntityLog.class);
|
||||||
|
|
||||||
|
entityLogMongoService.saveEntityLog(TEST_DOSSIER_ID, TEST_FILE1_ID, entityLog);
|
||||||
|
|
||||||
|
Optional<EntityLog> optionalEntityLog = entityLogMongoService.findEntityLogWithEntriesSinceAnalysisNumber(TEST_DOSSIER_ID, TEST_FILE1_ID, 2);
|
||||||
|
assertTrue(optionalEntityLog.isPresent());
|
||||||
|
|
||||||
|
EntityLog response = optionalEntityLog.get();
|
||||||
|
assertEquals(response.getEntityLogEntry().size(), 14);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -21,6 +21,10 @@ public interface EntityLogEntryDocumentRepository extends MongoRepository<Entity
|
|||||||
List<EntityLogEntryDocument> findByEntityLogIdAndChangesAnalysisNumberEquals(String entityLogId, Integer analysisNumber);
|
List<EntityLogEntryDocument> findByEntityLogIdAndChangesAnalysisNumberEquals(String entityLogId, Integer analysisNumber);
|
||||||
|
|
||||||
|
|
||||||
|
@Query("{ 'entityLogId' : ?0, 'changes.analysisNumber' : { $gte: ?1, $lte: ?2 } }")
|
||||||
|
List<EntityLogEntryDocument> findByEntityLogIdAndChangesAnalysisNumberBetween(String entityLogId, Integer analysisNumberStart, Integer analysisNumberEnd);
|
||||||
|
|
||||||
|
|
||||||
@Query("{ 'entityLogId' : ?0}")
|
@Query("{ 'entityLogId' : ?0}")
|
||||||
List<EntityLogEntryDocument> findByEntityLogId(String entityLogId);
|
List<EntityLogEntryDocument> findByEntityLogId(String entityLogId);
|
||||||
|
|
||||||
|
|||||||
@ -314,13 +314,13 @@ public class EntityLogMongoService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Optional<EntityLog> findEntityLogWithEntriesByAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
public Optional<EntityLog> findEntityLogWithEntriesSinceAnalysisNumber(String dossierId, String fileId, Integer analysisNumber) {
|
||||||
|
|
||||||
String entityLogId = mapper.getLogId(dossierId, fileId);
|
String entityLogId = mapper.getLogId(dossierId, fileId);
|
||||||
Optional<EntityLog> optionalEntityLog = entityLogDocumentRepository.findEntityLogDocumentWithoutEntriesById(entityLogId)
|
Optional<EntityLog> optionalEntityLog = entityLogDocumentRepository.findEntityLogDocumentWithoutEntriesById(entityLogId)
|
||||||
.map(mapper::fromLogDocument);
|
.map(mapper::fromLogDocument);
|
||||||
optionalEntityLog.ifPresent(entityLog -> entityLog.getEntityLogEntry()
|
optionalEntityLog.ifPresent(entityLog -> entityLog.getEntityLogEntry()
|
||||||
.addAll(entityLogEntryDocumentRepository.findByEntityLogIdAndChangesAnalysisNumberEquals(entityLogId, analysisNumber)
|
.addAll(entityLogEntryDocumentRepository.findByEntityLogIdAndChangesAnalysisNumberBetween(entityLogId, analysisNumber, entityLog.getAnalysisNumber())
|
||||||
.stream()
|
.stream()
|
||||||
.map(mapper::fromLogEntryDocument)
|
.map(mapper::fromLogEntryDocument)
|
||||||
.toList()));
|
.toList()));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user