Merge branch 'master' into RED-10425

# Conflicts:
#	persistence-service-v1/persistence-service-processor-v1/src/main/resources/mongo/changelog/mongo.changelog-tenant.xml
This commit is contained in:
corinaolariu 2024-11-14 19:32:41 +02:00
commit 9cabeef5d5
36 changed files with 171 additions and 667 deletions

View File

@ -160,4 +160,12 @@ public class RulesController implements RulesResource {
return new ResponseEntity<>(new InputStreamResource(is), httpHeaders, HttpStatus.OK);
}
@Override
@PreAuthorize("hasAuthority('" + WRITE_RULES + "')")
public void unlockRules(String dossierTemplateId, RuleFileType ruleFileType) {
rulesPersistenceService.resetTimeoutDetected(dossierTemplateId, ruleFileType);
}
}

View File

@ -6,6 +6,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
@ -105,4 +106,10 @@ public interface RulesResource {
@GetMapping(value = RULES_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + RULE_FILE_TYPE_PATH_VARIABLE + DOWNLOAD_PATH)
ResponseEntity<?> downloadFile(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType);
@ResponseBody
@ResponseStatus(value = HttpStatus.OK)
@Operation(summary = "Resets the timeout detected flag in a Rule file.")
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "No content")})
@PutMapping(value = RULES_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE + RULE_FILE_TYPE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
void unlockRules(@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId, @PathVariable(RULE_FILE_TYPE_PARAMETER_NAME) RuleFileType ruleFileType);
}

View File

@ -24,7 +24,7 @@ import lombok.extern.slf4j.Slf4j;
@Setter
@Service
@SuppressWarnings("PMD")
public class ReduceTextFileSizeMigration10 extends Migration {
public class V10ReduceTextFileSizeMigration extends Migration {
private static final String NAME = "Reduce TEXT filesize migration";
private static final long VERSION = 10;
@ -42,7 +42,7 @@ public class ReduceTextFileSizeMigration10 extends Migration {
private FileManagementStorageService fileManagementStorageService;
public ReduceTextFileSizeMigration10() {
public V10ReduceTextFileSizeMigration() {
super(NAME, VERSION);
}

View File

@ -17,7 +17,7 @@ import java.util.List;
@Slf4j
@Setter
@Service
public class MissingFileSizeMigration13 extends Migration {
public class V13MissingFileSizeMigration extends Migration {
private static final String NAME = "Add missing file sizes";
private static final long VERSION = 13;
@ -29,7 +29,7 @@ public class MissingFileSizeMigration13 extends Migration {
private FileManagementStorageService fileManagementStorageService;
public MissingFileSizeMigration13() {
public V13MissingFileSizeMigration() {
super(NAME, VERSION);
}

View File

@ -10,13 +10,13 @@ import org.springframework.stereotype.Service;
@Slf4j
@Setter
@Service
public class FixDossierDictionaryEntryInRedactionLog14 extends Migration {
public class V14FixDossierDictionaryEntryInRedactionLog extends Migration {
private static final String NAME = "Fix dossier dictionary entries in redactionLog for non dossier dictionaries";
private static final long VERSION = 14;
public FixDossierDictionaryEntryInRedactionLog14() {
public V14FixDossierDictionaryEntryInRedactionLog() {
super(NAME, VERSION);
}

View File

@ -28,7 +28,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class ManualRedactionTypeRenameMigration15 extends Migration {
public class V15ManualRedactionTypeRenameMigration extends Migration {
@Autowired
private FileStatusPersistenceService fileStatusPersistenceService;
@ -40,7 +40,7 @@ public class ManualRedactionTypeRenameMigration15 extends Migration {
private ManualRedactionService manualRedactionService;
public ManualRedactionTypeRenameMigration15() {
public V15ManualRedactionTypeRenameMigration() {
super(NAME, VERSION);
}

View File

@ -12,13 +12,13 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class RankDeDuplicationMigration16 extends Migration {
public class V16RankDeDuplicationMigration extends Migration {
@Autowired
private RankDeDuplicationService rankDeDuplicationService;
public RankDeDuplicationMigration16() {
public V16RankDeDuplicationMigration() {
super(NAME, VERSION);
}

View File

@ -22,7 +22,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class MigrateImportedRedactionsFiles17 extends Migration {
public class V17MigrateImportedRedactionsFiles extends Migration {
@Autowired
private FileStatusPersistenceService fileStatusPersistenceService;
@ -34,7 +34,7 @@ public class MigrateImportedRedactionsFiles17 extends Migration {
private static final long VERSION = 17;
public MigrateImportedRedactionsFiles17() {
public V17MigrateImportedRedactionsFiles() {
super(NAME, VERSION);
}

View File

@ -11,7 +11,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class StorageToMongoMigration18 extends Migration {
public class V18StorageToMongoMigration extends Migration {
private final StorageToMongoCopyService storageToMongoCopyService;
@ -19,7 +19,7 @@ public class StorageToMongoMigration18 extends Migration {
private static final long VERSION = 18;
public StorageToMongoMigration18(StorageToMongoCopyService storageToMongoCopyService) {
public V18StorageToMongoMigration(StorageToMongoCopyService storageToMongoCopyService) {
super(NAME, VERSION);
this.storageToMongoCopyService = storageToMongoCopyService;

View File

@ -16,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class AddGraphicDictionaryType19 extends Migration {
public class V19AddGraphicDictionaryType extends Migration {
@Autowired
private DossierTemplatePersistenceService dossierTemplatePersistenceService;
@ -31,7 +31,7 @@ public class AddGraphicDictionaryType19 extends Migration {
private static final long VERSION = 19;
public AddGraphicDictionaryType19() {
public V19AddGraphicDictionaryType() {
super(NAME, VERSION);
}

View File

@ -17,7 +17,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class DocumineLayoutRewriteMigration20 extends Migration {
public class V20DocumineLayoutRewriteMigration extends Migration {
private static final String NAME = "Reanalyse layout for not approved Documine files";
private static final long VERSION = 20;
@ -35,7 +35,7 @@ public class DocumineLayoutRewriteMigration20 extends Migration {
private CurrentApplicationTypeProvider currentApplicationTypeProvider;
public DocumineLayoutRewriteMigration20() {
public V20DocumineLayoutRewriteMigration() {
super(NAME, VERSION);
}

View File

@ -17,7 +17,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class ComponentOverridesMigration21 extends Migration {
public class V21ComponentOverridesMigration extends Migration {
private static final String NAME = "Migrate component overrides to mongoDB and create component definitions";
private static final long VERSION = 21;
@ -124,7 +124,7 @@ public class ComponentOverridesMigration21 extends Migration {
private CurrentApplicationTypeProvider currentApplicationTypeProvider;
public ComponentOverridesMigration21() {
public V21ComponentOverridesMigration() {
super(NAME, VERSION);
}

View File

@ -0,0 +1,69 @@
package com.iqser.red.service.persistence.management.v1.processor.migration.migrations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.management.v1.processor.migration.Migration;
import com.iqser.red.service.persistence.management.v1.processor.service.CurrentApplicationTypeProvider;
import com.iqser.red.service.persistence.management.v1.processor.service.FileStatusService;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class V22DocumineHeadlineDetectionMigration extends Migration {
private static final String NAME = "Reanalyse not approved Documine files after new headline detection";
private static final long VERSION = 22;
@Autowired
private FileStatusService fileStatusService;
@Autowired
private DossierPersistenceService dossierPersistenceService;
@Autowired
private FileStatusPersistenceService fileStatusPersistenceService;
@Autowired
private CurrentApplicationTypeProvider currentApplicationTypeProvider;
public V22DocumineHeadlineDetectionMigration() {
super(NAME, VERSION);
}
@Override
protected void migrate() {
log.info("Starting migration DocumineHeadlineDetectionMigration22");
if (!currentApplicationTypeProvider.isDocuMine()) {
log.info("Skipping DocumineHeadlineDetectionMigration22 as application type is not DocuMine!");
return;
}
var dossiers = dossierPersistenceService.findAllDossiers();
dossiers.forEach(dossier -> {
if (dossier.getHardDeletedTime() == null) {
var files = fileStatusPersistenceService.getStatusesForDossier(dossier.getId());
log.info("Start migration of dossier {}", dossier.getId());
files.forEach(file -> {
if (file.getHardDeletedTime() == null && !file.getWorkflowStatus().equals(WorkflowStatus.APPROVED)) {
log.info("Set full reanalyse for file {}", file.getId());
fileStatusService.setStatusFullReprocess(dossier.getId(), file.getId(), false, true, false);
log.info("Finished migration of file {}", file.getId());
}
});
log.info("Finished migration of dossier {}", dossier.getId());
}
});
}
}

View File

@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class ManualChangesReorderingMigration23 extends Migration {
public class V23ManualChangesReorderingMigration extends Migration {
private static final String NAME = "Migration for reordering mixed up manual changes";
private static final long VERSION = 23;
@ -29,9 +29,9 @@ public class ManualChangesReorderingMigration23 extends Migration {
private final FileStatusService fileStatusService;
public ManualChangesReorderingMigration23(EntityLogEntryDocumentRepository entityLogEntryDocumentRepository,
AddRedactionPersistenceService addRedactionPersistenceService,
FileStatusService fileStatusService) {
public V23ManualChangesReorderingMigration(EntityLogEntryDocumentRepository entityLogEntryDocumentRepository,
AddRedactionPersistenceService addRedactionPersistenceService,
FileStatusService fileStatusService) {
super(NAME, VERSION);
this.entityLogEntryDocumentRepository = entityLogEntryDocumentRepository;

View File

@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
@Setter
@Service
public class StorageToMongoMigration24 extends Migration {
public class V24StorageToMongoMigration extends Migration {
private final StorageToMongoCopyService storageToMongoCopyService;
private final MongoTemplate mongoTemplate;
@ -29,7 +29,7 @@ public class StorageToMongoMigration24 extends Migration {
private static final long VERSION = 24;
public StorageToMongoMigration24(StorageToMongoCopyService storageToMongoCopyService, MongoTemplate mongoTemplate) {
public V24StorageToMongoMigration(StorageToMongoCopyService storageToMongoCopyService, MongoTemplate mongoTemplate) {
super(NAME, VERSION);
this.storageToMongoCopyService = storageToMongoCopyService;

View File

@ -19,7 +19,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class AddDateFormatsToTemplatesMigration25 extends Migration {
public class V25AddDateFormatsToTemplatesMigration extends Migration {
private static final String NAME = "Migration for adding date formats files to dossier templates";
private static final long VERSION = 25;
@ -34,7 +34,7 @@ public class AddDateFormatsToTemplatesMigration25 extends Migration {
private CurrentApplicationTypeProvider currentApplicationTypeProvider;
public AddDateFormatsToTemplatesMigration25() {
public V25AddDateFormatsToTemplatesMigration() {
super(NAME, VERSION);
}

View File

@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class RuleFileUpdateMigration26 extends Migration {
public class V26RuleFileUpdateMigration extends Migration {
private final DossierTemplateRepository dossierTemplateRepository;
private final RulesPersistenceService rulesPersistenceService;
@ -29,7 +29,7 @@ public class RuleFileUpdateMigration26 extends Migration {
private static final long VERSION = 26;
public RuleFileUpdateMigration26(DossierTemplateRepository dossierTemplateRepository, RulesPersistenceService rulesPersistenceService) {
public V26RuleFileUpdateMigration(DossierTemplateRepository dossierTemplateRepository, RulesPersistenceService rulesPersistenceService) {
super(NAME, VERSION);
this.dossierTemplateRepository = dossierTemplateRepository;
@ -62,7 +62,7 @@ public class RuleFileUpdateMigration26 extends Migration {
TenantContext.setTenantId(tenantId);
String updatedRules = ruleSet.getValue()
.replaceAll("import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngine;",
"import com.knecon.fforesight.service.layoutparser.internal.api.data.redaction.LayoutEngineProto.LayoutEngine;");
"import com.iqser.red.service.redaction.v1.server.model.document.nodes.LayoutEngine;");
rulesPersistenceService.setRules(updatedRules, ruleSet.getDossierTemplateId(), RuleFileType.ENTITY);
});
}

View File

@ -14,7 +14,7 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class QueueRenameMigration27 extends Migration {
public class V27QueueRenameMigration extends Migration {
private final AmqpAdmin amqpAdmin;
@ -86,7 +86,7 @@ public class QueueRenameMigration27 extends Migration {
"visual_layout_parsing_service_response_queue");
public QueueRenameMigration27(AmqpAdmin amqpAdmin) {
public V27QueueRenameMigration(AmqpAdmin amqpAdmin) {
super(NAME, VERSION);
this.amqpAdmin = amqpAdmin;

View File

@ -12,15 +12,15 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
@Setter
@Service
public class AddTechnicalNameToJustifications22 extends Migration {
public class V28AddTechnicalNameToJustifications extends Migration {
private static final String NAME = "Migration to add a technical name to justifications";
private static final long VERSION = 22;
private static final long VERSION = 28;
@Autowired
private LegalBasisMigrationService legalBasisMigrationService;
public AddTechnicalNameToJustifications22() {
public V28AddTechnicalNameToJustifications() {
super(NAME, VERSION);
}

View File

@ -20,7 +20,6 @@ import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemp
import com.iqser.red.service.persistence.service.v1.api.shared.mongo.service.ComponentLogMongoService;
import com.iqser.red.service.search.v1.model.IndexMessageType;
import groovy.transform.Field;
import jakarta.transaction.Transactional;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
@ -44,7 +43,6 @@ public class FileDeletionService {
FileStatusPersistenceService fileStatusPersistenceService;
FileManagementStorageService fileManagementStorageService;
IndexingService indexingService;
ComponentLogService componentLogService;
ComponentLogMongoService componentLogMongoService;

View File

@ -1,12 +1,11 @@
package com.iqser.red.service.persistence.management.v1.processor.service.persistence;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.LegalBasisEntity;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.LegalBasisMappingRepository;
import jakarta.transaction.Transactional;
@ -19,14 +18,12 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class LegalBasisMigrationService {
private static final HashFunction hashFunction = Hashing.murmur3_128();
private static final Map<String, String> technicalNameMapping = Map.ofEntries(Map.entry("Article 39(e)(3) of Regulation (EC) No 178/2002",
"personal_data_geolocation_article_39e3"),
Map.entry("Article 39(e)(2) of Regulation (EC) No 178/2002",
"vertebrate_study_personal_data_geolocation_article_39e2"),
Map.entry(
"Article 63(2)(a) of Regulation (EC) No 1107/2009 (reference to Article 39 of Regulation EC No 178/2002)",
"Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002)",
"manufacturing_production_process"),
Map.entry(
"Article 63(2)(a) of Regulation (EC) No 1107/2009 (making reference to Article 39 of Regulation EC No 178/2002)",
@ -50,15 +47,19 @@ public class LegalBasisMigrationService {
Map.entry("Article 63(2)(c) of Regulation (EC) No 1107/2009", "results_production_batches"),
Map.entry("Article 63(2)(d) of Regulation (EC) No 1107/2009",
"composition_plant_protection_product"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2g)", "names_addresses_persons"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2d)", "methods_analysis_impurities"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2a)", "method_manufacture"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2b)", "specification_impurity_active_substance"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2c)", "results_production_batches"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2d)", "methods_analysis_impurities"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2e)", "links_producer_applicant"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2f)", "composition_plant_protection_product"),
Map.entry("Reg (EC) No 1107/2009 Art. 63 (2g)", "names_addresses_persons"),
Map.entry("Article 4(1)(b), Regulation (EC) No 1049/2001 (Personal data)",
"personal_data_geolocation"),
Map.entry("Article 4(2), first indent, Regulation (EC) No 1049/2001 (commercial interest)",
"proprietary_information"),
Map.entry("3. n/a", "n_a"));
Map.entry("N/A", "n_a"),
Map.entry("n-a.", "n-a."));
private final LegalBasisMappingRepository legalBasisMappingRepository;
@ -70,17 +71,22 @@ public class LegalBasisMigrationService {
this.legalBasisMappingRepository.findAll()
.stream()
.peek(entry -> entry.getLegalBasis()
.forEach(lb -> {
lb.setTechnicalName(getTechnicalNameOrHash(lb.getReason()));
}))
.forEach(lb -> lb.setTechnicalName(getTechnicalNameOrFallback(lb))))
.forEach(legalBasisMappingRepository::save);
log.info("Finishing migration: Adding technical names to legal basis");
}
private static String getTechnicalNameOrHash(String reason) {
private static String getTechnicalNameOrFallback(LegalBasisEntity legalBasisEntity) {
return technicalNameMapping.getOrDefault(reason, String.valueOf(hashFunction.hashString(reason, StandardCharsets.UTF_8)));
return technicalNameMapping.getOrDefault(legalBasisEntity.getReason(), generateNewTechnicalName(legalBasisEntity.getName()));
}
private static String generateNewTechnicalName(String name) {
return name.toLowerCase(Locale.ROOT).replaceAll("\\.", "").replaceAll("\\s+", "_");
}
}

View File

@ -2,6 +2,7 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
import java.util.Optional;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.RuleSetEntity;
@ -20,11 +21,11 @@ public class RulesPersistenceService {
public static final String DEFAULT_RULES = """
package drools
import static java.lang.String.format;
import static com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility.anyMatch;
import static com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility.exactMatch;
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
@ -32,7 +33,7 @@ public class RulesPersistenceService {
import java.util.Collection;
import java.util.stream.Stream;
import java.util.Optional;
import com.iqser.red.service.redaction.v1.server.model.document.*;
import com.iqser.red.service.redaction.v1.server.model.document.TextRange;
import com.iqser.red.service.redaction.v1.server.model.document.entity.*;
@ -65,7 +66,7 @@ public class RulesPersistenceService {
import com.iqser.red.service.redaction.v1.server.service.document.EntityCreationService;
import com.iqser.red.service.redaction.v1.server.service.ManualChangesApplicationService;
import com.iqser.red.service.redaction.v1.server.utils.RedactionSearchUtility;
import com.iqser.red.service.persistence.service.v1.api.shared.model.FileAttribute;
import com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog.Engine;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualResizeRedaction;
@ -73,20 +74,20 @@ public class RulesPersistenceService {
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualForceRedaction;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualRecategorization;
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.entitymapped.ManualLegalBasisChange;
global Document document
global EntityCreationService entityCreationService
global ManualChangesApplicationService manualChangesApplicationService
global Dictionary dictionary
//------------------------------------ queries ------------------------------------
query "getFileAttributes"
$fileAttribute: FileAttribute()
end
//------------------------------------ Local dictionary search rules ------------------------------------
// Rule unit: LocalDictionarySearch.0
rule "LDS.0.0: run local dictionary search"
agenda-group "LOCAL_DICTIONARY_ADDS"
@ -140,6 +141,7 @@ public class RulesPersistenceService {
});
}
@Transactional
public void setRules(@NonNull String rules, String dossierTemplateId, RuleFileType ruleFileType, long version, boolean timeoutDetected) {
@ -147,7 +149,8 @@ public class RulesPersistenceService {
ruleSet.setDossierTemplateId(dossierTemplateId);
ruleSet.setRuleFileType(ruleFileType.name());
ruleSet.setValue(rules);
ruleSet.setVersion(ruleSet.getVersion() + 1); // Setting rules version in existing dossier template will break analysis, if there are files with higher versions in entity log. So only increment.
// Setting rules version in existing dossier template will break analysis, if there are files with higher versions in entity log. So only increment.
ruleSet.setVersion(ruleSet.getVersion() + 1);
ruleSet.setTimeoutDetected(timeoutDetected);
}, () -> {
RuleSetEntity ruleSet = new RuleSetEntity();
@ -164,7 +167,14 @@ public class RulesPersistenceService {
@Transactional
public void setTimeoutDetected(String dossierTemplateId, RuleFileType ruleFileType) {
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name());
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name(), true);
}
@Transactional
public void resetTimeoutDetected(String dossierTemplateId, RuleFileType ruleFileType) {
ruleSetRepository.updateTimeoutDetected(dossierTemplateId, ruleFileType.name(), false);
}
}

View File

@ -13,8 +13,8 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.configur
public interface RuleSetRepository extends JpaRepository<RuleSetEntity, RuleSetEntityKey> {
@Modifying
@Query("update RuleSetEntity r set r.timeoutDetected = true where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
void updateTimeoutDetected(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType);
@Query("update RuleSetEntity r set r.timeoutDetected = :timeoutDetected where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
void updateTimeoutDetected(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType, @Param("timeoutDetected") boolean timeoutDetected);
@Modifying
@Query("update RuleSetEntity r set r.version = :version where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
@ -27,4 +27,5 @@ public interface RuleSetRepository extends JpaRepository<RuleSetEntity, RuleSetE
@Query("select r.version from RuleSetEntity r where r.dossierTemplateId = :dossierTemplateId and r.ruleFileType = :ruleFileType")
Optional<Long> findVersionByDossierTemplateIdAndRuleFileType(@Param("dossierTemplateId") String dossierTemplateId, @Param("ruleFileType") String ruleFileType);
}

View File

@ -1,13 +0,0 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.20.xsd">
<include file="/mongo/changelog/tenant/1-initial-database.changelog.xml"/>
<include file="/mongo/changelog/tenant/2-create-indices-for-entries.xml"/>
<!-- <include file="/mongo/changelog/tenant/3-add-page-paragraph-idx.xml"/>-->
<!-- <include file="/mongo/changelog/tenant/4-create-component-entities.xml"/>-->
<!-- <include file="/mongo/changelog/tenant/5-add-duplicate-text-ranges.xml"/>-->
<!-- <include file="/mongo/changelog/tenant/6-rename-component-collections.xml"/>-->
<include file="/mongo/changelog/tenant/7-add-entity-log-value-index.xml"/>
<!-- THIS FILE IS NOT RUN IN THE CURRENT CONFIGURATION, PLEASE ADD CHANGES TO redaction-service -->
</databaseChangeLog>

View File

@ -1,224 +0,0 @@
<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="createEntityLogEntryCollection" author="maverick">
<ext:createCollection collectionName="entity-log-entries">
<ext:options>
{
validator: {
$jsonSchema: {
bsonType: "object",
required: ["entryId", "entityLogId", "type", "entryType", "state", "value", "reason", "matchedRule", "legalBasis", "containingNodeId", "closestHeadline", "section",
"positions", "textBefore", "textAfter", "startOffset", "endOffset", "imageHasTransparency", "dictionaryEntry", "dossierDictionaryEntry", "excluded", "changes",
"manualChanges", "engines", "reference", "importedRedactionIntersections", "numberOfComments"],
properties: {
entryId: {
bsonType: "string",
description: "The Entry ID"
},
entityLogId: {
bsonType: "string",
description: "The Entity Log ID"
},
type: {
bsonType: "string",
description: "The Type"
},
entryType: {
bsonType: "string",
description: "The Entry Type"
},
state: {
bsonType: "string",
description: "The Entry State"
},
value: {
bsonType: "string",
description: "The Value"
},
reason: {
bsonType: "string",
description: "The Reason"
},
matchedRule: {
bsonType: "string",
description: "The Matched Rule"
},
legalBasis: {
bsonType: "string",
description: "The Legal Basis"
},
containingNodeId: {
bsonType: "array",
items: {
bsonType: "int",
description: "The Containing Node ID"
}
},
closestHeadline: {
bsonType: "string",
description: "The Closest Headline"
},
section: {
bsonType: "string",
description: "The Section"
},
positions: {
bsonType: "array",
description: "The Positions",
items: {
bsonType: "object"
}
},
textBefore: {
bsonType: "string",
description: "Text before the entry"
},
textAfter: {
bsonType: "string",
description: "Text after the entry"
},
startOffset: {
bsonType: "int",
description: "Start offset of the entry"
},
endOffset: {
bsonType: "int",
description: "End offset of the entry"
},
imageHasTransparency: {
bsonType: "bool",
description: "Whether the image has transparency"
},
dictionaryEntry: {
bsonType: "bool",
description: "Whether it's a dictionary entry"
},
dossierDictionaryEntry: {
bsonType: "bool",
description: "Whether it's a dossier dictionary entry"
},
excluded: {
bsonType: "bool",
description: "Whether it's excluded"
},
changes: {
bsonType: "array",
description: "The Changes",
items: {
bsonType: "object"
}
},
manualChanges: {
bsonType: "array",
description: "The Manual Changes",
items: {
bsonType: "object"
}
},
engines: {
bsonType: "array",
description: "The Engines",
items: {
bsonType: "string"
}
},
reference: {
bsonType: "array",
description: "The Reference",
items: {
bsonType: "string"
}
},
importedRedactionIntersections: {
bsonType: "array",
description: "The Imported Redaction Intersections",
items: {
bsonType: "string"
}
},
numberOfComments: {
bsonType: "int",
description: "The Number of Comments"
}
}
}
},
validationAction: "warn",
validationLevel: "strict"
}
</ext:options>
</ext:createCollection>
<ext:createCollection collectionName="entity-logs">
<ext:options>
{
validator: {
$jsonSchema: {
bsonType: "object",
required: ["dossierId", "fileId", "analysisVersion", "analysisNumber", "entityLogEntryDocument", "legalBasis"],
properties: {
dossierId: {
bsonType: "string",
description: "The Dossier ID"
},
fileId: {
bsonType: "string",
description: "The File ID"
},
analysisVersion: {
bsonType: "long",
description: "The Analysis Version"
},
analysisNumber: {
bsonType: "int",
description: "The Analysis Number"
},
entityLogEntryDocument: {
bsonType: "array",
description: "The Entity Log Entry Documents",
items: {
bsonType: "objectId"
}
},
legalBasis: {
bsonType: "array",
description: "The Legal Basis",
items: {
bsonType: "object"
}
},
dictionaryVersion: {
bsonType: "long",
description: "The Dictionary Version"
},
dossierDictionaryVersion: {
bsonType: "long",
description: "The Dossier Dictionary Version"
},
rulesVersion: {
bsonType: "long",
description: "The Rules Version"
},
legalBasisVersion: {
bsonType: "long",
description: "The Legal Basis Version"
}
}
}
},
validationAction: "warn",
validationLevel: "strict"
}
</ext:options>
</ext:createCollection>
</changeSet>
</databaseChangeLog>

View File

@ -1,17 +0,0 @@
<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="createEntityLogEntryCollection" author="maverick">
<ext:createCollection collectionName="entity-log-entries"/>
<ext:createCollection collectionName="entity-logs"/>
</changeSet>
</databaseChangeLog>

View File

@ -1,48 +0,0 @@
<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,
"containingNodeId": 1
}
</ext:keys>
<ext:options>
{name: "entityLogId_containingNodeId_index"}
</ext:options>
</ext:createIndex>
</changeSet>
</databaseChangeLog>

View File

@ -1,25 +0,0 @@
<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="3" author="aisvoran">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $set: { "paragraphPageIdx": -1 } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -1,104 +0,0 @@
<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="createComponentCollection" author="ali">
<ext:createCollection collectionName="component-logs">
<ext:options>
{
"validator": {
"$jsonSchema": {
"bsonType": "object",
"required": ["id", "dossierId", "fileId", "analysisNumber", "componentRulesVersion", "components"],
"properties": {
"id": {
"bsonType": "string",
"description": "must be a string and is required"
},
"dossierId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"fileId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"analysisNumber": {
"bsonType": "int",
"description": "must be an integer and is required"
},
"componentRulesVersion": {
"bsonType": "long",
"description": "must be a long and is required"
},
"components": {
"bsonType": "array",
"items": {
"bsonType": "objectId",
"description": "must be an array of objectIds"
},
"description": "must be an array and is required"
}
}
}
},
"validationLevel": "strict",
"validationAction": "error"
}
</ext:options>
</ext:createCollection>
<ext:createCollection collectionName="component-log-entries">
<ext:options>
{
"validator": {
"$jsonSchema": {
"bsonType": "object",
"required": ["id", "componentLogId", "name", "overrideValues", "values", "overridden"],
"properties": {
"id": {
"bsonType": "string",
"description": "must be a string and is required"
},
"componentLogId": {
"bsonType": "string",
"description": "must be a string and is required"
},
"name": {
"bsonType": "string",
"description": "must be a string and is required"
},
"overrideValues": {
"bsonType": "array",
"items": {
"bsonType": "object"
},
"description": "must be an array of objects and is required"
},
"values": {
"bsonType": "array",
"items": {
"bsonType": "object"
},
"description": "must be an array of objects and is required"
},
"overridden": {
"bsonType": "bool",
"description": "must be a boolean and is required"
}
}
}
},
"validationLevel": "strict",
"validationAction": "warn"
}
</ext:options>
</ext:createCollection>
</changeSet>
</databaseChangeLog>

View File

@ -1,25 +0,0 @@
<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="add-duplicate-text-ranges" author="aisvoran">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $set: { "duplicatedTextRanges": [] } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -1,30 +0,0 @@
<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="renameComponentCollections" author="maverick">
<ext:adminCommand>
<ext:command>
{
"renameCollection": "${databaseName}.component-logs",
"to": "${databaseName}.old-component-logs"
}
</ext:command>
</ext:adminCommand>
<ext:adminCommand>
<ext:command>
{
"renameCollection": "${databaseName}.component-log-entries",
"to": "${databaseName}.old-component-log-entries"
}
</ext:command>
</ext:adminCommand>
</changeSet>
</databaseChangeLog>

View File

@ -1,84 +0,0 @@
<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>

View File

@ -1,26 +0,0 @@
<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="1" author="maverick">
<ext:runCommand>
<ext:command>
{
update: "entity-log-entries",
updates: [
{
q: {},
u: { $unset: { "numberOfComments": "" } },
multi: true
}
]
}
</ext:command>
</ext:runCommand>
</changeSet>
</databaseChangeLog>

View File

@ -8,7 +8,7 @@ import org.springframework.core.io.ClassPathResource;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
import com.iqser.red.service.persistence.management.v1.processor.migration.migrations.ReduceTextFileSizeMigration10;
import com.iqser.red.service.persistence.management.v1.processor.migration.migrations.V10ReduceTextFileSizeMigration;
import com.iqser.red.service.persistence.management.v1.processor.utils.FileUtils;
import com.iqser.red.service.persistence.management.v1.processor.utils.StorageIdUtils;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.FileType;
@ -19,7 +19,7 @@ import lombok.SneakyThrows;
public class ReduceFileSizeMigrationTest extends AbstractPersistenceServerServiceTest {
@Autowired
private ReduceTextFileSizeMigration10 reduceTextFileSizeMigration10;
private V10ReduceTextFileSizeMigration v10ReduceTextFileSizeMigration;
@Autowired
private ObjectMapper objectMapper;
@ -33,7 +33,7 @@ public class ReduceFileSizeMigrationTest extends AbstractPersistenceServerServic
storageService.storeObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId("dossierId", "fileId", FileType.TEXT), responseJson.getInputStream());
reduceTextFileSizeMigration10.migrateFile("dossierId", "fileId");
v10ReduceTextFileSizeMigration.migrateFile("dossierId", "fileId");
// readJSONObject will not work here.
var text = fileManagementStorageService.getObject(TenantContext.getTenantId(), StorageIdUtils.getStorageId("dossierId", "fileId", FileType.TEXT));

View File

@ -20,7 +20,7 @@ import org.springframework.test.context.TestPropertySource;
import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPersistenceServerServiceTest;
import com.iqser.red.service.persistence.management.v1.processor.dataexchange.service.DossierTemplateImportService;
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DateFormatsEntity;
import com.iqser.red.service.persistence.management.v1.processor.migration.migrations.AddDateFormatsToTemplatesMigration25;
import com.iqser.red.service.persistence.management.v1.processor.migration.migrations.V25AddDateFormatsToTemplatesMigration;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DateFormatsPersistenceService;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.importexport.ImportDossierTemplateRequest;
import com.knecon.fforesight.tenantcommons.TenantApplicationType;
@ -28,12 +28,12 @@ import com.knecon.fforesight.tenantcommons.TenantApplicationType;
import lombok.SneakyThrows;
@TestPropertySource(properties = {"application.type=DocuMine"})
public class AddDateFormatsToTemplatesMigration25Test extends AbstractPersistenceServerServiceTest {
public class V25AddDateFormatsToTemplatesMigrationTest extends AbstractPersistenceServerServiceTest {
private static final String USER_ID = "TestUserId";
@Autowired
private AddDateFormatsToTemplatesMigration25 migration;
private V25AddDateFormatsToTemplatesMigration migration;
@Autowired
private DossierTemplateImportService dossierTemplateImportService;

View File

@ -11,6 +11,7 @@ dependencies {
api("com.google.guava:guava:31.1-jre")
api("com.knecon.fforesight:mongo-database-commons:0.16.0") {
exclude(group = "com.knecon.fforesight", module = "tenant-commons")
exclude(group = "org.liquibase.ext", module = "liquibase-mongodb")
}
api("com.knecon.fforesight:tenant-commons:0.31.0-RED10196.0")
api("org.springframework.boot:spring-boot-starter-data-mongodb:${springBootStarterVersion}")