RED-8702: Explore document databases to store entityLog
* changed indices
This commit is contained in:
parent
7212b43693
commit
9ab0910a26
@ -140,7 +140,7 @@ public class FileManagementStorageService {
|
||||
@SneakyThrows
|
||||
public void saveEntityLog(String dossierId, String fileId, EntityLog entityLog) {
|
||||
|
||||
entityLogMongoService.saveEntityLog(dossierId, fileId, entityLog);
|
||||
entityLogMongoService.upsertEntityLog(dossierId, fileId, entityLog);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -10,24 +10,35 @@
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"_id": 1,
|
||||
"positions.pageNumber": 1
|
||||
"entityLogId": 1,
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "positions_pageNumber_index"}
|
||||
{name: "entityLogId_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"_id": 1,
|
||||
"changes.analysisNumber": -1
|
||||
"entityLogId": 1,
|
||||
"positions.pageNumber": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "changes_analysisNumber_index"}
|
||||
{name: "entityLogId_positionsPageNumber_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
"containingNodeId": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_containingNodeId_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
<databaseChangeLog
|
||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
|
||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd
|
||||
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
|
||||
|
||||
<changeSet id="createIndicesForEntries" author="maverick">
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
"positions.pageNumber": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_positionsPageNumber_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
"changes.analysisNumber": -1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_changesAnalysisNumber_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
"containingNodeId": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_containingNodeId_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"id": 1,
|
||||
"containingNodeId": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "id_containingNodeId_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
<ext:createIndex collectionName="entity-log-entries">
|
||||
<ext:keys>
|
||||
{
|
||||
"entityLogId": 1,
|
||||
"type": 1
|
||||
}
|
||||
</ext:keys>
|
||||
<ext:options>
|
||||
{name: "entityLogId_type_index"}
|
||||
</ext:options>
|
||||
</ext:createIndex>
|
||||
|
||||
</changeSet>
|
||||
|
||||
|
||||
</databaseChangeLog>
|
||||
@ -247,7 +247,7 @@ public class EntityLogMongoServiceTest extends AbstractPersistenceServerServiceT
|
||||
entityLog = objectMapper.readValue(file.getInputStream(), EntityLog.class);
|
||||
entityLog.setAnalysisNumber(entityLog.getAnalysisNumber() + 1);
|
||||
|
||||
entityLogMongoService.saveEntityLog(TEST_DOSSIER_ID, TEST_FILE3_ID, entityLog);
|
||||
entityLogMongoService.upsertEntityLog(TEST_DOSSIER_ID, TEST_FILE3_ID, entityLog);
|
||||
|
||||
found = entityLogMongoService.findEntityLogByDossierIdAndFileId(TEST_DOSSIER_ID, TEST_FILE3_ID);
|
||||
assertTrue(found.isPresent());
|
||||
|
||||
@ -49,12 +49,10 @@ public class EntityLogMongoService {
|
||||
|
||||
|
||||
// this does everything : insert when not found and update if found
|
||||
// todo: remove and replace when services use insert,update,delete correctly
|
||||
public void saveEntityLog(String dossierId, String fileId, EntityLog entityLog) {
|
||||
public void upsertEntityLog(String dossierId, String fileId, EntityLog entityLog) {
|
||||
|
||||
Optional<EntityLogDocument> optionalEntityLogDocument = entityLogDocumentRepository.findById(mapper.getLogId(dossierId, fileId));
|
||||
if (optionalEntityLogDocument.isEmpty()) {
|
||||
// throw new EntityLogDocumentNotFoundException(String.format("Entity log for dossier %s and file %s not found.", dossierId, fileId));
|
||||
insertEntityLog(dossierId, fileId, entityLog);
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user