diff --git a/persistence-service-v1/persistence-service-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/resources/DictionaryResource.java b/persistence-service-v1/persistence-service-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/resources/DictionaryResource.java index 6e95c51c2..12fbecce0 100644 --- a/persistence-service-v1/persistence-service-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/resources/DictionaryResource.java +++ b/persistence-service-v1/persistence-service-api-v1/src/main/java/com/iqser/red/service/persistence/service/v1/api/resources/DictionaryResource.java @@ -26,6 +26,8 @@ public interface DictionaryResource { String DOSSIER_PATH = "/dossier"; String DOSSIER_ID_PATH_VARIABLE = "/{" + DOSSIER_ID_PARAMETER_NAME + "}"; + String FROM_VERSION_PARAM = "fromVersion"; + String COLOR_PATH = "/color"; String VERSION_PATH = "/version"; String ENTRIES_PATH = "/entries"; @@ -69,12 +71,12 @@ public interface DictionaryResource { @GetMapping(value = TYPE_PATH + DOSSIER_PATH + DOSSIER_ID_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE) List getAllTypesForDossier(@PathVariable(DOSSIER_ID_PARAMETER_NAME) String dossierId); - @GetMapping(value = DICTIONARY_PATH + TYPE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE) - Type getDictionaryForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId); + Type getDictionaryForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId, @RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion); @GetMapping(value = DICTIONARY_PATH + TYPE_PATH_VARIABLE + ENTRIES_PATH, produces = MediaType.APPLICATION_JSON_VALUE) List getEntriesForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId, + @RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion, @RequestParam(value = "dictionaryEntryType", required = false, defaultValue = "ENTRY") DictionaryEntryType dictionaryEntryType); diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/EntryPersistenceService.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/EntryPersistenceService.java index cde51066e..2732de9d7 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/EntryPersistenceService.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/EntryPersistenceService.java @@ -1,12 +1,5 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persistence; -import java.util.List; -import java.util.stream.Collectors; - -import javax.transaction.Transactional; - -import org.springframework.stereotype.Service; - import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.BaseDictionaryEntry; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryEntryEntity; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryFalsePositiveEntryEntity; @@ -16,9 +9,13 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.FalseRecommendationEntryRepository; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.TypeRepository; import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.DictionaryEntryType; - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; +import java.util.stream.Collectors; @Service @Slf4j @@ -105,15 +102,15 @@ public class EntryPersistenceService { } - public List getEntries(String typeId, DictionaryEntryType dictionaryEntryType) { + public List getEntries(String typeId, DictionaryEntryType dictionaryEntryType, Long fromVersion) { switch (dictionaryEntryType) { case ENTRY: - return entryRepository.findByTypeId(typeId); + return entryRepository.findByTypeIdAndVersionGreaterThan(typeId, fromVersion != null ? fromVersion : -1); case FALSE_POSITIVE: - return falsePositiveEntryRepository.findByTypeId(typeId); + return falsePositiveEntryRepository.findByTypeIdAndVersionGreaterThan(typeId, fromVersion != null ? fromVersion : -1); case FALSE_RECOMMENDATION: - return falseRecommendationEntryRepository.findByTypeId(typeId); + return falseRecommendationEntryRepository.findByTypeIdAndVersionGreaterThan(typeId, fromVersion != null ? fromVersion : -1); } return null; } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/EntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/EntryRepository.java index 2345d884a..631f3b13b 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/EntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/EntryRepository.java @@ -24,7 +24,6 @@ public interface EntryRepository extends JpaRepository findByTypeId(String typeId); + List findByTypeIdAndVersionGreaterThan(String typeId, long version); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalsePositiveEntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalsePositiveEntryRepository.java index 57c535742..a985fc44e 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalsePositiveEntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalsePositiveEntryRepository.java @@ -25,6 +25,6 @@ public interface FalsePositiveEntryRepository extends JpaRepository findByTypeId(String typeId); + List findByTypeIdAndVersionGreaterThan(String typeId, long version); } diff --git a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalseRecommendationEntryRepository.java b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalseRecommendationEntryRepository.java index 7e583a6dc..28d8f3549 100644 --- a/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalseRecommendationEntryRepository.java +++ b/persistence-service-v1/persistence-service-processor-v1/src/main/java/com/iqser/red/service/persistence/management/v1/processor/service/persistence/repository/FalseRecommendationEntryRepository.java @@ -26,6 +26,6 @@ public interface FalseRecommendationEntryRepository extends JpaRepository findByTypeId(String typeId); + List findByTypeIdAndVersionGreaterThan(String typeId, long version); } diff --git a/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/controller/DictionaryController.java b/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/controller/DictionaryController.java index 7b0c06980..da3e0f75d 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/controller/DictionaryController.java +++ b/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/controller/DictionaryController.java @@ -5,7 +5,6 @@ import com.iqser.red.service.peristence.v1.server.service.StopwordService; import com.iqser.red.service.peristence.v1.server.validation.DictionaryValidator; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.BaseDictionaryEntry; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ColorsEntity; -import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.DictionaryEntryEntity; import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.TypeEntity; import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException; import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException; @@ -17,10 +16,8 @@ import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.ty import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.DictionaryEntryType; import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.type.Type; import com.iqser.red.service.persistence.service.v1.api.resources.DictionaryResource; - import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.CollectionUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; @@ -28,17 +25,13 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.transaction.Transactional; - import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert; import static java.util.stream.Collectors.toList; @@ -80,7 +73,7 @@ public class DictionaryController implements DictionaryResource { var currentVersion = getCurrentVersion(typeResult); - List existing = entryPersistenceService.getEntries(typeId, dictionaryEntryType) + List existing = entryPersistenceService.getEntries(typeId, dictionaryEntryType, null) .stream() .filter(e -> !e.isDeleted()) .map(BaseDictionaryEntry::getValue) @@ -120,7 +113,7 @@ public class DictionaryController implements DictionaryResource { var currentVersion = getCurrentVersion(typeResult); if (typeResult.isCaseInsensitive()) { - List existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY) + List existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, null) .stream() .map(BaseDictionaryEntry::getValue) .collect(toList()); @@ -158,19 +151,19 @@ public class DictionaryController implements DictionaryResource { .getRank() != typeValueRequest.getRank()) { var currentVersion = getCurrentVersion(typeResult); - var entries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY), DictionaryEntry.class); + var entries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, null), DictionaryEntry.class); entryPersistenceService.setVersion(typeId, entries.stream() .filter(entry -> !entry.isDeleted()) .map(DictionaryEntry::getValue) .collect(toList()), currentVersion + 1, DictionaryEntryType.ENTRY); - var falsePositiveEntries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE), DictionaryEntry.class); + var falsePositiveEntries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, null), DictionaryEntry.class); entryPersistenceService.setVersion(typeId, falsePositiveEntries.stream() .filter(entry -> !entry.isDeleted()) .map(DictionaryEntry::getValue) .collect(toList()), currentVersion + 1, DictionaryEntryType.FALSE_POSITIVE); - var falseRecommendationEntries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION), DictionaryEntry.class); + var falseRecommendationEntries = convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, null), DictionaryEntry.class); entryPersistenceService.setVersion(typeId, falseRecommendationEntries.stream() .filter(entry -> !entry.isDeleted()) .map(DictionaryEntry::getValue) @@ -209,7 +202,7 @@ public class DictionaryController implements DictionaryResource { } String color = typeRequest.getHexColor(); validateColor(color); - return convert(dictionaryPersistenceService.addType(typeRequest.getType(), typeRequest.getDossierTemplateId(), color,typeRequest.getRecommendationHexColor(), typeRequest + return convert(dictionaryPersistenceService.addType(typeRequest.getType(), typeRequest.getDossierTemplateId(), color, typeRequest.getRecommendationHexColor(), typeRequest .getRank(), typeRequest.isHint(), typeRequest.isCaseInsensitive(), typeRequest.isRecommendation(), typeRequest .getDescription(), typeRequest.isAddToDictionaryAction(), typeRequest.getLabel(), typeRequest.getDossierId()), Type.class); } @@ -224,7 +217,7 @@ public class DictionaryController implements DictionaryResource { var currentVersion = getCurrentVersion(typeResult); dictionaryPersistenceService.deleteType(typeId); - List existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY) + List existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, null) .stream() .map(BaseDictionaryEntry::getValue) .collect(toList()); @@ -250,13 +243,13 @@ public class DictionaryController implements DictionaryResource { @Override - public Type getDictionaryForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId) { + public Type getDictionaryForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId, @RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion) { var entity = dictionaryPersistenceService.getType(typeId); var target = convert(entity, Type.class); - target.setEntries(convert(entity.getEntries(), DictionaryEntry.class)); - target.setFalsePositiveEntries(convert(entity.getFalsePositiveEntries(), DictionaryEntry.class)); - target.setFalseRecommendationEntries(convert(entity.getFalseRecommendationEntries(), DictionaryEntry.class)); + target.setEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, fromVersion), DictionaryEntry.class)); + target.setFalsePositiveEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_POSITIVE, fromVersion), DictionaryEntry.class)); + target.setFalseRecommendationEntries(convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.FALSE_RECOMMENDATION, fromVersion), DictionaryEntry.class)); return target; } @@ -264,20 +257,12 @@ public class DictionaryController implements DictionaryResource { @Override @Transactional public List getEntriesForType(@PathVariable(TYPE_PARAMETER_NAME) String typeId, + @RequestParam(value = FROM_VERSION_PARAM, required = false) Long fromVersion, @RequestParam(value = "dictionaryEntryType", required = false, defaultValue = "ENTRY") DictionaryEntryType dictionaryEntryType) { - - switch (dictionaryEntryType) { - case ENTRY: - return convert(dictionaryPersistenceService.getType(typeId).getEntries(), DictionaryEntry.class); - case FALSE_POSITIVE: - return convert(dictionaryPersistenceService.getType(typeId).getFalsePositiveEntries(), DictionaryEntry.class); - case FALSE_RECOMMENDATION: - return convert(dictionaryPersistenceService.getType(typeId).getFalseRecommendationEntries(), DictionaryEntry.class); - } - return null; + var entries = entryPersistenceService.getEntries(typeId, dictionaryEntryType, fromVersion); + return convert(entries, DictionaryEntry.class); } - private Set getInvalidEntries(Set entries) { Predicate isDictionaryEntryNotValid = entry -> DictionaryValidator.validateDictionaryEntry(entry).isPresent(); diff --git a/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/service/ManualRedactionService.java b/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/service/ManualRedactionService.java index 594ec7d94..f22216670 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/service/ManualRedactionService.java +++ b/persistence-service-v1/persistence-service-server-v1/src/main/java/com/iqser/red/service/peristence/v1/server/service/ManualRedactionService.java @@ -13,6 +13,7 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.dossier. import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException; import com.iqser.red.service.persistence.management.v1.processor.exception.ConflictException; import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException; +import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DictionaryPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierTemplatePersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService; @@ -55,6 +56,7 @@ public class ManualRedactionService { private final CommentPersistenceService commentPersistenceService; private final FileStatusPersistenceService fileStatusPersistenceService; private final DictionaryController dictionaryController; + private final DictionaryPersistenceService dictionaryPersistenceService; private final FileManagementStorageService fileManagementStorageService; private final ImageRecategorizationPersistenceService recategorizationPersistenceService; private final LegalBasisChangePersistenceService legalBasisChangePersistenceService; @@ -118,7 +120,7 @@ public class ManualRedactionService { if (!addRedactionRequest.isForceAddToDictionary() && stopwordService.isStopword(addRedactionRequest.getValue())) { throw new ConflictException("The entry you are trying to add is a stopword"); } - dictionaryController.getDictionaryForType(addRedactionRequest.getTypeId()); + dictionaryPersistenceService.getType(addRedactionRequest.getTypeId()); } catch (NotFoundException e) { throw new BadRequestException("Invalid type: " + addRedactionRequest.getTypeId()); } @@ -684,8 +686,7 @@ public class ManualRedactionService { } - private void addToDictionary(String typeId, String value, String dossierId, String fileId, - DictionaryEntryType dictionaryEntryType) { + private void addToDictionary(String typeId, String value, String dossierId, String fileId, DictionaryEntryType dictionaryEntryType) { try { log.debug("Adding entry: {} to {} for {} / {}", value, typeId, dossierId, fileId); diff --git a/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/db.changelog-master.yaml b/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/db.changelog-master.yaml index 8d1934348..61b60d191 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/db.changelog-master.yaml @@ -29,5 +29,7 @@ databaseChangeLog: file: db/changelog/12-dossier-visibility.changelog.yaml - include: file: db/changelog/13-file-manual-change-date.changelog.yaml + - include: + file: db/changelog/release-3.2.0/1-add-index-on-dictionary-entry.changelog.yaml - include: file: db/changelog/14-add-redaction-source-id.changelog.yaml diff --git a/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/release-3.2.0/1-add-index-on-dictionary-entry.changelog.yaml b/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/release-3.2.0/1-add-index-on-dictionary-entry.changelog.yaml new file mode 100644 index 000000000..c99e98985 --- /dev/null +++ b/persistence-service-v1/persistence-service-server-v1/src/main/resources/db/changelog/release-3.2.0/1-add-index-on-dictionary-entry.changelog.yaml @@ -0,0 +1,17 @@ +databaseChangeLog: + - changeSet: + id: 1-add-index-on-dictionary-entry + author: timo + changes: + - createIndex: + columns: + - column: + name: version + indexName: dictionary_entry_version_idx + tableName: dictionary_entry + - createIndex: + columns: + - column: + name: type_id + indexName: dictionary_entry_type_id_idx + tableName: dictionary_entry diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/service/TypeProvider.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/service/TypeProvider.java index 36281065a..c967d1356 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/service/TypeProvider.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/service/TypeProvider.java @@ -34,7 +34,7 @@ public class TypeProvider { var createdType = dictionaryClient.addType(type); - var loadedType = dictionaryClient.getDictionaryForType(createdType.getId()); + var loadedType = dictionaryClient.getDictionaryForType(createdType.getId(),null); assertThat(loadedType).isNotNull(); diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DictionaryTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DictionaryTest.java index c4c9ce440..2ac1926b1 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DictionaryTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DictionaryTest.java @@ -49,11 +49,11 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { dictionaryClient.addEntries(type.getTypeId(), List.of("false_positive1", "false_positive"), false, false, DictionaryEntryType.FALSE_POSITIVE); dictionaryClient.addEntries(type.getTypeId(), List.of("false_recommendation1", "false_recommendation2"), false, false, DictionaryEntryType.FALSE_RECOMMENDATION); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(2); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.FALSE_POSITIVE)).hasSize(2); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.FALSE_RECOMMENDATION)).hasSize(2); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(2); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.FALSE_POSITIVE)).hasSize(2); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.FALSE_RECOMMENDATION)).hasSize(2); - var loadedType = dictionaryClient.getDictionaryForType(type.getTypeId()); + var loadedType = dictionaryClient.getDictionaryForType(type.getTypeId(), null); assertThat(loadedType.getEntries()).hasSize(2); assertThat(loadedType.getFalsePositiveEntries()).hasSize(2); assertThat(loadedType.getFalseRecommendationEntries()).hasSize(2); @@ -89,16 +89,16 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Add same word again; Only one should exist entries = new ArrayList<>(); entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Add same word multiple times again; Only one should exist entries = new ArrayList<>(); @@ -108,17 +108,17 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Delete word; Should have 'deleted' flag entries = new ArrayList<>(); entries.add(word); dictionaryClient.deleteEntries(type.getTypeId(), entries, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).isDeleted()).isTrue(); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).isDeleted()).isTrue(); } @@ -136,16 +136,16 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, true, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Add same word again; Only one should exist entries = new ArrayList<>(); entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, true, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Add same word multiple times again; Only one should exist entries = new ArrayList<>(); @@ -155,17 +155,17 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word); dictionaryClient.addEntries(type.getTypeId(), entries, true, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); // Act & Assert: Delete word; Should have 'deleted' flag entries = new ArrayList<>(); entries.add(word); dictionaryClient.deleteEntries(type.getTypeId(), entries, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(1); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY).get(0).isDeleted()).isTrue(); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(1); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).getValue()).isEqualTo(word); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY).get(0).isDeleted()).isTrue(); } @@ -186,8 +186,8 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word3); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(3); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY) + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(3); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY) .stream() .map(e -> e.getValue()) .collect(Collectors.toList())).contains(word1, word2, word3); @@ -197,8 +197,8 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word1); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(3); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY) + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(3); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY) .stream() .map(e -> e.getValue()) .collect(Collectors.toList())).contains(word1, word2, word3); @@ -213,8 +213,8 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest { entries.add(word3); dictionaryClient.addEntries(type.getTypeId(), entries, false, false, DictionaryEntryType.ENTRY); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY)).hasSize(3); - assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), DictionaryEntryType.ENTRY) + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY)).hasSize(3); + assertThat(dictionaryClient.getEntriesForType(type.getTypeId(), null, DictionaryEntryType.ENTRY) .stream() .map(e -> e.getValue()) .collect(Collectors.toList())).contains(word1, word2, word3); diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateStatsTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateStatsTest.java index fd4aa6927..2cf1cb100 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateStatsTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/DossierTemplateStatsTest.java @@ -81,7 +81,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe entries1.add("entry2"); dictionaryClient.addEntries(addedType.getTypeId(), entries1, false, false, DictionaryEntryType.ENTRY); - List entryList = dictionaryClient.getEntriesForType(addedType.getTypeId(), DictionaryEntryType.ENTRY); + List entryList = dictionaryClient.getEntriesForType(addedType.getTypeId(), null, DictionaryEntryType.ENTRY); assertThat(entryList.size()).isEqualTo(entries1.size()); var addedType2 = dictionaryClient.addType(Type.builder() @@ -100,7 +100,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe entries2.add("entry3"); dictionaryClient.addEntries(addedType2.getTypeId(), entries2, false, false, DictionaryEntryType.ENTRY); - entryList = dictionaryClient.getEntriesForType(addedType2.getTypeId(), DictionaryEntryType.ENTRY); + entryList = dictionaryClient.getEntriesForType(addedType2.getTypeId(), null, DictionaryEntryType.ENTRY); assertThat(entryList.size()).isEqualTo(entries2.size()); var dossierTemplate3 = provideTestTemplate("dossierTemp3"); @@ -121,7 +121,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe entries3.add("entry2"); dictionaryClient.addEntries(addedType3.getTypeId(), entries3, false, false, DictionaryEntryType.ENTRY); - entryList = dictionaryClient.getEntriesForType(addedType3.getTypeId(), DictionaryEntryType.ENTRY); + entryList = dictionaryClient.getEntriesForType(addedType3.getTypeId(), null, DictionaryEntryType.ENTRY); assertThat(entryList.size()).isEqualTo(entries3.size()); var dossierTemplate4 = provideTestTemplate("dossierTemp4"); @@ -180,7 +180,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe entries23.add(entries2.get(1)); dictionaryClient.deleteEntries(addedType2.getTypeId(), entries23, DictionaryEntryType.ENTRY); - var entries23loaded = dictionaryClient.getEntriesForType(addedType2.getTypeId(), DictionaryEntryType.ENTRY); + var entries23loaded = dictionaryClient.getEntriesForType(addedType2.getTypeId(), null, DictionaryEntryType.ENTRY); assertThat(entries23loaded.stream().filter(e -> !e.isDeleted()).collect(Collectors.toList())).isEmpty(); dossierTemplateStatsList = dossierTemplateStatsClient.getDossierTemplateStats(dossierTemplateIds); diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java index 32c03b0e5..ddf057c36 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/ManualRedactionTest.java @@ -161,7 +161,7 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest { .annotationStatus(AnnotationStatus.REQUESTED).build()); var loadedRemoveRedaction2 = manualRedactionClient.getRemoveRedaction(file.getId(), removeRedaction2.getAnnotationId()); assertThat(loadedRemoveRedaction2.getStatus()).isEqualTo(AnnotationStatus.REQUESTED); - assertThat(dictionaryClient.getDictionaryForType(type.getId()).getEntries().isEmpty()); + assertThat(dictionaryClient.getDictionaryForType(type.getId(),null).getEntries().isEmpty()); assertThat(loadedRemoveRedaction2.isRemoveFromDictionary()).isEqualTo(true); manualRedactionClient.updateRemoveRedactionStatus(dossier.getId(), file.getId(), diff --git a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/TypeTest.java b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/TypeTest.java index 9de762e07..828faa704 100644 --- a/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/TypeTest.java +++ b/persistence-service-v1/persistence-service-server-v1/src/test/java/com/iqser/red/service/peristence/v1/server/integration/tests/TypeTest.java @@ -38,23 +38,23 @@ public class TypeTest extends AbstractPersistenceServerServiceTest { dictionaryClient.addEntries(type.getId(), Lists.newArrayList("aaa", "bbb", "ccc"), true, false, DictionaryEntryType.ENTRY); - var loadedType = dictionaryClient.getDictionaryForType(type.getId()); + var loadedType = dictionaryClient.getDictionaryForType(type.getId(), null); assertThat(loadedType.getEntries().size()).isEqualTo(3); assertThat(loadedType.getVersion()).isGreaterThan(type.getVersion()); - var dict = dictionaryClient.getEntriesForType(type.getId(), DictionaryEntryType.ENTRY); + var dict = dictionaryClient.getEntriesForType(type.getId(), null, DictionaryEntryType.ENTRY); assertThat(dict.size()).isEqualTo(3); dictionaryClient.deleteEntries(type.getId(), Lists.newArrayList("aaa", "bbb", "ccc"), DictionaryEntryType.ENTRY); - loadedType = dictionaryClient.getDictionaryForType(type.getId()); + loadedType = dictionaryClient.getDictionaryForType(type.getId(), null); assertThat(loadedType.getVersion()).isGreaterThan(type.getVersion() + 1); - dict = dictionaryClient.getEntriesForType(type.getId(), DictionaryEntryType.ENTRY); + dict = dictionaryClient.getEntriesForType(type.getId(), null, DictionaryEntryType.ENTRY); assertThat(dict.size()).isEqualTo(3); for (var entry : dict) { @@ -67,7 +67,7 @@ public class TypeTest extends AbstractPersistenceServerServiceTest { request.setRank(99); dictionaryClient.updateTypeValue(type.getId(), request); - loadedType = dictionaryClient.getDictionaryForType(type.getId()); + loadedType = dictionaryClient.getDictionaryForType(type.getId(), null); assertThat(loadedType.getVersion()).isGreaterThan(type.getVersion() + 2); assertThat(loadedType.getRank()).isEqualTo(99);