Merge branch 'feature/2.589-index-stats-backport' into 'release/2.589.x'

RED-10071 - Create system-managed entities automatically - fix component definitions - bp

See merge request redactmanager/persistence-service!840
This commit is contained in:
Timo Bejan 2024-11-07 08:25:56 +01:00
commit 335b12fb2e
4 changed files with 269 additions and 7 deletions

View File

@ -60,8 +60,9 @@ public class ReanalysisRequiredStatusService {
Map<String, Map<VersionType, Long>> dossierTemplateVersionMap = new HashMap<>();
Map<String, Long> dossierVersionMap = new HashMap<>();
Map<String, DossierEntity> dossierMap = new HashMap<>();
Map<String, Map<String, Integer>> componentMappingVersionMap = new HashMap<>();
fileModels.forEach(entry -> {
var analysisRequiredResult = computeAnalysisRequired(entry, ignoreProcessingStates, dossierTemplateVersionMap, dossierVersionMap, dossierMap);
var analysisRequiredResult = computeAnalysisRequired(entry, ignoreProcessingStates, dossierTemplateVersionMap, dossierVersionMap, dossierMap, componentMappingVersionMap);
entry.setReanalysisRequired(analysisRequiredResult.isReanalysisRequired());
entry.setFullAnalysisRequired(analysisRequiredResult.isFullAnalysisRequired());
entry.setComponentReanalysisRequired(analysisRequiredResult.isComponentReanalysisRequired());
@ -75,7 +76,8 @@ public class ReanalysisRequiredStatusService {
boolean ignoreProcessingStates,
Map<String, Map<VersionType, Long>> dossierTemplateVersionMap,
Map<String, Long> dossierVersionMap,
Map<String, DossierEntity> dossierMap) {
Map<String, DossierEntity> dossierMap,
Map<String, Map<String, Integer>> componentMappingVersionMap) {
// enhance with dossierTemplateId
DossierEntity dossier;
@ -118,7 +120,7 @@ public class ReanalysisRequiredStatusService {
if (fileStatus.getLastFileAttributeChange() != null && fileStatus.getLastProcessed().isBefore(fileStatus.getLastFileAttributeChange())) {
return new AnalysisRequiredResult(true, false);
} else {
return requiresReanalysisBasedOnVersionDifference(fileStatus, dossier, dossierTemplateVersionMap, dossierVersionMap);
return requiresReanalysisBasedOnVersionDifference(fileStatus, dossier, dossierTemplateVersionMap, dossierVersionMap,componentMappingVersionMap);
}
default:
return new AnalysisRequiredResult(false, false);
@ -132,15 +134,17 @@ public class ReanalysisRequiredStatusService {
private AnalysisRequiredResult requiresReanalysisBasedOnVersionDifference(FileModel fileStatus,
DossierEntity dossier,
Map<String, Map<VersionType, Long>> dossierTemplateVersionMap,
Map<String, Long> dossierVersionMap) {
Map<String, Long> dossierVersionMap,
Map<String, Map<String,Integer>> componentMappingVersionMap) {
// get relevant versions
Map<VersionType, Long> dossierTemplateVersions = dossierTemplateVersionMap.computeIfAbsent(dossier.getDossierTemplateId(),
k -> buildVersionData(dossier.getDossierTemplateId()));
Map<String, Integer> componentMappingVersions = componentMappingService.getMetaDataByDossierTemplateId(dossier.getDossierTemplateId())
.stream()
.collect(Collectors.toMap(ComponentMappingMetadata::getName, ComponentMappingMetadata::getVersion));
Map<String, Integer> componentMappingVersions = componentMappingVersionMap.computeIfAbsent(dossier.getDossierTemplateId(),
k -> componentMappingService.getMetaDataByDossierTemplateId(dossier.getDossierTemplateId())
.stream()
.collect(Collectors.toMap(ComponentMappingMetadata::getName, ComponentMappingMetadata::getVersion)));
Long dossierDictionaryVersion = dossierVersionMap.computeIfAbsent(fileStatus.getDossierId(), k -> getDossierVersionData(fileStatus.getDossierId()));

View File

@ -241,3 +241,7 @@ databaseChangeLog:
file: db/changelog/tenant/148-add-quotechar-to-component-mapping.yaml
- include:
file: db/changelog/tenant/149-remove-based-on-dict-annotation-id-columns.yaml
- include:
file: db/changelog/tenant/149-add-indexes-across-tables-for-performance.yaml
- include:
file: db/changelog/tenant/150-add-component-mapping-indexes.yaml

View File

@ -0,0 +1,220 @@
databaseChangeLog:
- changeSet:
id: create_index_if_not_exists_idx_file_last_updated
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_file_last_updated
tableName: file
changes:
- createIndex:
tableName: file
indexName: idx_file_last_updated
columns:
- column:
name: last_updated
- changeSet:
id: create_index_if_not_exists_idx_file_deleted_hard_deleted_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_file_deleted_hard_deleted_time
tableName: file
changes:
- createIndex:
tableName: file
indexName: idx_file_deleted_hard_deleted_time
columns:
- column:
name: deleted
- column:
name: hard_deleted_time
- changeSet:
id: create_index_if_not_exists_idx_file_dossier_id_deleted_hard_deleted_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_file_dossier_id_deleted_hard_deleted_time
tableName: file
changes:
- createIndex:
tableName: file
indexName: idx_file_dossier_id_deleted_hard_deleted_time
columns:
- column:
name: dossier_id
- column:
name: deleted
- column:
name: hard_deleted_time
- changeSet:
id: create_index_if_not_exists_idx_dossier_last_updated
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_dossier_last_updated
tableName: dossier
changes:
- createIndex:
tableName: dossier
indexName: idx_dossier_last_updated
columns:
- column:
name: last_updated
- changeSet:
id: create_index_if_not_exists_idx_dossier_soft_deleted_time_hard_deleted_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_dossier_soft_deleted_time_hard_deleted_time
tableName: dossier
changes:
- createIndex:
tableName: dossier
indexName: idx_dossier_soft_deleted_time_hard_deleted_time
columns:
- column:
name: soft_deleted_time
- column:
name: hard_deleted_time
- changeSet:
id: create_index_if_not_exists_idx_dossier_id_soft_deleted_time_hard_deleted_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_dossier_id_soft_deleted_time_hard_deleted_time
tableName: dossier
changes:
- createIndex:
tableName: dossier
indexName: idx_dossier_id_soft_deleted_time_hard_deleted_time
columns:
- column:
name: id
- column:
name: soft_deleted_time
- column:
name: hard_deleted_time
- changeSet:
id: create_index_if_not_exists_idx_dossier_soft_deleted_time_hard_deleted_time_archived_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_dossier_soft_deleted_time_hard_deleted_time_archived_time
tableName: dossier
changes:
- createIndex:
tableName: dossier
indexName: idx_dossier_soft_deleted_time_hard_deleted_time_archived_time
columns:
- column:
name: soft_deleted_time
- column:
name: hard_deleted_time
- column:
name: archived_time
- changeSet:
id: create_index_if_not_exists_idx_dossier_dossier_template_id_soft_deleted_time_hard_deleted_time_archived_time
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_dossier_dossier_template_id_soft_deleted_time_hard_deleted_time_archived_time
tableName: dossier
changes:
- createIndex:
tableName: dossier
indexName: idx_dossier_dossier_template_id_soft_deleted_time_hard_deleted_time_archived_time
columns:
- column:
name: dossier_template_id
- column:
name: soft_deleted_time
- column:
name: hard_deleted_time
- column:
name: archived_time
- changeSet:
id: create_index_if_not_exists_idx_notification_preference_user_id_in_app_notifications_enabled
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_notification_preference_user_id_in_app_notifications_enabled
tableName: notification_preference
changes:
- createIndex:
tableName: notification_preference
indexName: idx_notification_preference_user_id_in_app_notifications_enabled
columns:
- column:
name: user_id
- column:
name: in_app_notifications_enabled
- changeSet:
id: create_index_if_not_exists_idx_notification_user_id_creation_date_soft_deleted
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_notification_user_id_creation_date_soft_deleted
tableName: notification
changes:
- createIndex:
tableName: notification
indexName: idx_notification_user_id_creation_date_soft_deleted
columns:
- column:
name: user_id
- column:
name: creation_date
- column:
name: soft_deleted
- changeSet:
id: create_index_if_not_exists_idx_entity_dossier_template_id
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_entity_dossier_template_id
tableName: entity
changes:
- createIndex:
tableName: entity
indexName: idx_entity_dossier_template_id
columns:
- column:
name: dossier_template_id
- changeSet:
id: create_index_if_not_exists_idx_entity_dossier_id
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_entity_dossier_id
tableName: entity
changes:
- createIndex:
tableName: entity
indexName: idx_entity_dossier_id
columns:
- column:
name: dossier_id

View File

@ -0,0 +1,34 @@
databaseChangeLog:
- changeSet:
id: create_index_if_not_exists_idx_component_mappings_dossier_template_id
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_component_mappings_dossier_template_id
tableName: component_mappings
changes:
- createIndex:
tableName: component_mappings
indexName: idx_component_mappings_dossier_template_id
columns:
- column:
name: dossier_template_id
- changeSet:
id: create_index_if_not_exists_idx_component_mappings_dossier_template_id_name
author: Timo
preConditions:
- not:
indexExists:
indexName: idx_component_mappings_dossier_template_id_name
tableName: component_mappings
changes:
- createIndex:
tableName: component_mappings
indexName: idx_component_mappings_dossier_template_id_name
columns:
- column:
name: dossier_template_id
- column:
name: name