From Version parameter for dictionary controller

This commit is contained in:
Timo Bejan 2022-03-14 13:20:57 +02:00
parent bc4298b83e
commit ec00322167
14 changed files with 91 additions and 88 deletions

View File

@ -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<Type> 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<DictionaryEntry> 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);

View File

@ -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<? extends BaseDictionaryEntry> getEntries(String typeId, DictionaryEntryType dictionaryEntryType) {
public List<? extends BaseDictionaryEntry> 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;
}

View File

@ -24,7 +24,6 @@ public interface EntryRepository extends JpaRepository<DictionaryEntryEntity, Lo
@Query("update DictionaryEntryEntity e set e.type.id = :newTypeId, e.version = e.version + 1 where e.type.id =:typeId")
void updateTypeIdAndIncrementVersionByOne(String typeId, String newTypeId);
List<DictionaryEntryEntity> findByTypeId(String typeId);
List<DictionaryEntryEntity> findByTypeIdAndVersionGreaterThan(String typeId, long version);
}

View File

@ -25,6 +25,6 @@ public interface FalsePositiveEntryRepository extends JpaRepository<DictionaryFa
void updateTypeIdAndIncrementVersionByOne(String typeId, String newTypeId);
List<DictionaryFalsePositiveEntryEntity> findByTypeId(String typeId);
List<DictionaryFalsePositiveEntryEntity> findByTypeIdAndVersionGreaterThan(String typeId, long version);
}

View File

@ -26,6 +26,6 @@ public interface FalseRecommendationEntryRepository extends JpaRepository<Dictio
void updateTypeIdAndIncrementVersionByOne(String typeId, String newTypeId);
List<DictionaryFalsePositiveEntryEntity> findByTypeId(String typeId);
List<DictionaryFalsePositiveEntryEntity> findByTypeIdAndVersionGreaterThan(String typeId, long version);
}

View File

@ -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<String> existing = entryPersistenceService.getEntries(typeId, dictionaryEntryType)
List<String> 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<String> existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY)
List<String> 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<String> existing = entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY)
List<String> 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<DictionaryEntry> 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;
return convert(entryPersistenceService.getEntries(typeId, dictionaryEntryType, fromVersion), DictionaryEntry.class);
}
private Set<String> getInvalidEntries(Set<String> entries) {
Predicate<String> isDictionaryEntryNotValid = entry -> DictionaryValidator.validateDictionaryEntry(entry).isPresent();

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -81,7 +81,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
entries1.add("entry2");
dictionaryClient.addEntries(addedType.getTypeId(), entries1, false, false, DictionaryEntryType.ENTRY);
List<DictionaryEntry> entryList = dictionaryClient.getEntriesForType(addedType.getTypeId(), DictionaryEntryType.ENTRY);
List<DictionaryEntry> 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);

View File

@ -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(),

View File

@ -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);