Merge branch 'RED-6485_RED-6743' into 'master'
RED-6485 - Dossier-only entity setting in the dossier template, RED-6743 -... Closes RED-6485 See merge request redactmanager/persistence-service!2
This commit is contained in:
commit
a11c22112c
@ -129,14 +129,9 @@ public class DictionaryController implements DictionaryResource {
|
||||
@Override
|
||||
public void updateType(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestBody UpdateTypeValue typeValue,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId) {
|
||||
@RequestBody UpdateTypeValue typeValue) {
|
||||
|
||||
if (dossierId == null) {
|
||||
dictionaryService.updateGlobalType(type, dossierTemplateId, typeValue);
|
||||
} else {
|
||||
dictionaryService.updateDossierType(type, dossierTemplateId, typeValue, dossierId);
|
||||
}
|
||||
dictionaryService.updateGlobalType(type, dossierTemplateId, typeValue);
|
||||
|
||||
auditClient.insertRecord(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
@ -149,15 +144,9 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
|
||||
@Override
|
||||
public TypeValue addType(@Valid @RequestBody CreateTypeValue typeValue, @RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId) {
|
||||
public TypeValue addType(@Valid @RequestBody CreateTypeValue typeValue) {
|
||||
|
||||
Type result;
|
||||
|
||||
if (dossierId == null) {
|
||||
result = dictionaryService.addGlobalType(typeValue);
|
||||
} else {
|
||||
result = dictionaryService.addDossierType(typeValue, dossierId);
|
||||
}
|
||||
Type result = dictionaryService.addGlobalType(typeValue);
|
||||
|
||||
auditClient.insertRecord(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
@ -167,21 +156,15 @@ public class DictionaryController implements DictionaryResource {
|
||||
.details(Map.of("Type", typeValue.getType()))
|
||||
.build());
|
||||
|
||||
var converted = MagicConverter.convert(result, TypeValue.class, new TypeValueMapper());
|
||||
return converted;
|
||||
return MagicConverter.convert(result, TypeValue.class, new TypeValueMapper());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteType(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId) {
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId) {
|
||||
|
||||
if (dossierId == null) {
|
||||
dictionaryService.deleteGlobalType(type, dossierTemplateId);
|
||||
} else {
|
||||
dictionaryService.deleteDossierType(type, dossierTemplateId, dossierId);
|
||||
}
|
||||
dictionaryService.deleteGlobalType(type, dossierTemplateId);
|
||||
|
||||
auditClient.insertRecord(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
@ -195,18 +178,13 @@ public class DictionaryController implements DictionaryResource {
|
||||
|
||||
@Override
|
||||
public void deleteTypes(@RequestBody List<String> types,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId) {
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId) {
|
||||
|
||||
List<String> errorIds = new ArrayList<>();
|
||||
|
||||
for (var type : types) {
|
||||
try {
|
||||
if (dossierId == null) {
|
||||
dictionaryService.deleteGlobalType(type, dossierTemplateId);
|
||||
} else {
|
||||
dictionaryService.deleteDossierType(type, dossierTemplateId, dossierId);
|
||||
}
|
||||
dictionaryService.deleteGlobalType(type, dossierTemplateId);
|
||||
|
||||
auditClient.insertRecord(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
|
||||
@ -99,15 +99,14 @@ public interface DictionaryResource {
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Successfully updated the colors, hint and caseInsensitive of entry type"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entry type is not found.")})
|
||||
void updateType(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestBody UpdateTypeValue typeValue,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId);
|
||||
@RequestBody UpdateTypeValue typeValue);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@PostMapping(value = TYPE_PATH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Creates entry type with colors, hint and caseInsensitive", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Successfully created the entry type with colors, hint " + "and caseInsensitive"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "409", description = "The entry type already exists, could not be added again.")})
|
||||
TypeValue addType(@RequestBody CreateTypeValue typeValue, @RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId);
|
||||
TypeValue addType(@RequestBody CreateTypeValue typeValue);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
@ -115,8 +114,7 @@ public interface DictionaryResource {
|
||||
@Operation(summary = "Deletes entry type", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Successfully deleted the entry type with value and all its entries"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entry type is not found.")})
|
||||
void deleteType(@PathVariable(TYPE_PARAMETER_NAME) String type,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId);
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);
|
||||
|
||||
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
@ -124,8 +122,7 @@ public interface DictionaryResource {
|
||||
@Operation(summary = "Deletes entry types", description = "None")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Successfully deleted the entry types with value and all their entries"), @ApiResponse(responseCode = "400", description = "Request contains error."), @ApiResponse(responseCode = "404", description = "The entry type is not found.")})
|
||||
void deleteTypes(@RequestBody List<String> types,
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId,
|
||||
@RequestParam(value = DOSSIER_ID_PARAMETER_NAME, required = false) String dossierId);
|
||||
@PathVariable(DOSSIER_TEMPLATE_PARAMETER_NAME) String dossierTemplateId);
|
||||
|
||||
|
||||
@GetMapping(value = TYPE_PATH + DOSSIER_TEMPLATE_PATH_VARIABLE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.getDossierIdFromTypeId;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.getDosssierTemplateTypeIdFromTypeId;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.isDossierTypeId;
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -10,8 +13,6 @@ import java.util.function.Predicate;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -20,6 +21,7 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.configur
|
||||
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;
|
||||
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.EntryPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter;
|
||||
@ -49,7 +51,6 @@ public class DictionaryManagementService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public Type addType(Type typeRequest) {
|
||||
|
||||
if (typeRequest.getDossierTemplateId() == null) {
|
||||
@ -224,6 +225,8 @@ public class DictionaryManagementService {
|
||||
|
||||
public void addEntries(String typeId, List<String> entries, boolean removeCurrent, boolean ignoreInvalidEntries, DictionaryEntryType dictionaryEntryType) {
|
||||
|
||||
checkForDossierTypeExistenceAndCreate(typeId);
|
||||
|
||||
Set<String> cleanEntries = entries.stream().map(this::cleanDictionaryEntry).collect(toSet());
|
||||
|
||||
if (CollectionUtils.isEmpty(entries)) {
|
||||
@ -257,6 +260,24 @@ public class DictionaryManagementService {
|
||||
}
|
||||
|
||||
|
||||
public void checkForDossierTypeExistenceAndCreate(String typeId) {
|
||||
// check for the existence of dossier type and create in case it does not exist
|
||||
if (isDossierTypeId(typeId)) {
|
||||
try {
|
||||
dictionaryPersistenceService.getType(typeId);
|
||||
} catch (NotFoundException e) {
|
||||
// type not found, it should be created based on the info from the dossier template type and if flag dossierDictionaryOnly is also true
|
||||
var dossierTemplateType = dictionaryPersistenceService.getType(getDosssierTemplateTypeIdFromTypeId(typeId));
|
||||
Type dossierDictionaryType = MagicConverter.convert(dossierTemplateType, Type.class);
|
||||
dossierDictionaryType.setVersion(0);
|
||||
dossierDictionaryType.setDossierId(getDossierIdFromTypeId(typeId));
|
||||
var returnedType = this.addType(dossierDictionaryType);
|
||||
log.info("Type added: " + returnedType.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String cleanDictionaryEntry(String entry) {
|
||||
|
||||
return TextNormalizationUtilities.removeHyphenLineBreaks(entry).replaceAll("\\n", " ");
|
||||
@ -273,6 +294,7 @@ public class DictionaryManagementService {
|
||||
|
||||
|
||||
public void deleteEntries(String typeId, List<String> entries, DictionaryEntryType dictionaryEntryType) {
|
||||
checkForDossierTypeExistenceAndCreate(typeId);
|
||||
|
||||
// To check whether the type exists
|
||||
Type typeResult = MagicConverter.convert(dictionaryPersistenceService.getType(typeId), Type.class);
|
||||
|
||||
@ -68,7 +68,6 @@ public class DictionaryService {
|
||||
@PreAuthorize("hasAuthority('" + ADD_DOSSIER_DICTIONARY_ENTRY + "')")
|
||||
public void addDossierEntries(String type, String dossierTemplateId, List<String> entries, boolean removeCurrent, String dossierId, DictionaryEntryType dictionaryEntryType) {
|
||||
|
||||
accessControlService.verifyUserIsDossierOwner(dossierId);
|
||||
addEntries(toTypeId(type, dossierTemplateId, dossierId), entries, removeCurrent, dictionaryEntryType);
|
||||
}
|
||||
|
||||
@ -81,9 +80,9 @@ public class DictionaryService {
|
||||
}
|
||||
|
||||
|
||||
public void deleteEntries(String type, List<String> entries, DictionaryEntryType dictionaryEntryType) {
|
||||
public void deleteEntries(String typeId, List<String> entries, DictionaryEntryType dictionaryEntryType) {
|
||||
|
||||
dictionaryManagementService.deleteEntries(type, entries, dictionaryEntryType);
|
||||
dictionaryManagementService.deleteEntries(typeId, entries, dictionaryEntryType);
|
||||
}
|
||||
|
||||
|
||||
@ -101,6 +100,8 @@ public class DictionaryService {
|
||||
public void updateGlobalType(String type, String dossierTemplateId, UpdateTypeValue typeValue) {
|
||||
|
||||
updateType(dossierTemplateId, toTypeId(type, dossierTemplateId), typeValue);
|
||||
var dossierTypes = dictionaryPersistenceService.getAllDossierTypesForDossierTemplateAndType(dossierTemplateId, type, false);
|
||||
dossierTypes.forEach(t -> this.updateDossierType(t.getType(), dossierTemplateId, typeValue, t.getDossierId()));
|
||||
}
|
||||
|
||||
|
||||
@ -159,7 +160,7 @@ public class DictionaryService {
|
||||
.hasDictionary(typeValue.isHasDictionary())
|
||||
.systemManaged(false)
|
||||
.autoHideSkipped(typeValue.isAutoHideSkipped())
|
||||
.dossierDictionaryOnly(dossierId != null && typeValue.isDossierDictionaryOnly())
|
||||
.dossierDictionaryOnly(typeValue.isDossierDictionaryOnly())
|
||||
.build());
|
||||
}
|
||||
|
||||
@ -176,6 +177,9 @@ public class DictionaryService {
|
||||
public void deleteGlobalType(String type, String dossierTemplateId) {
|
||||
|
||||
deleteType(toTypeId(type, dossierTemplateId));
|
||||
// delete the dossier types with the same type
|
||||
var dossierTypes = dictionaryPersistenceService.getAllDossierTypesForDossierTemplateAndType(dossierTemplateId, type, false);
|
||||
dossierTypes.forEach(t -> this.deleteDossierType(t.getType(), dossierTemplateId, t.getDossierId()));
|
||||
}
|
||||
|
||||
|
||||
@ -201,6 +205,8 @@ public class DictionaryService {
|
||||
if (dossierId != null) {
|
||||
try {
|
||||
accessControlService.verifyUserHasViewPermissions(dossierId);
|
||||
// for every dossier template type check if a dossier type exists
|
||||
types.forEach(t -> dictionaryManagementService.checkForDossierTypeExistenceAndCreate(toTypeId(t.getType(), t.getDossierTemplateId(), dossierId)));
|
||||
types.addAll(MagicConverter.convert(dictionaryPersistenceService.getAllTypesForDossier(dossierId, includeDeleted), Type.class));
|
||||
} catch (AccessDeniedException e) {
|
||||
log.debug(" Don't include the types for the dossier id");
|
||||
@ -240,6 +246,8 @@ public class DictionaryService {
|
||||
accessControlService.verifyUserHasViewPermissions(dossierId);
|
||||
}
|
||||
var typeId = toTypeId(type, dossierTemplateId, dossierId);
|
||||
// create dossier level type if it does not exist
|
||||
dictionaryManagementService.checkForDossierTypeExistenceAndCreate(typeId);
|
||||
var entity = dictionaryPersistenceService.getType(typeId);
|
||||
var dictionaryForType = MagicConverter.convert(entity, Type.class);
|
||||
dictionaryForType.setEntries(MagicConverter.convert(entryPersistenceService.getEntries(typeId, DictionaryEntryType.ENTRY, null), DictionaryEntry.class));
|
||||
|
||||
@ -96,7 +96,6 @@ public class ManualRedactionService {
|
||||
private final HashFunction hashFunction = Hashing.murmur3_128();
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<ManualAddResponse> addAddRedaction(String dossierId, String fileId, List<AddRedactionRequest> addRedactionRequests) {
|
||||
|
||||
var response = new ArrayList<ManualAddResponse>();
|
||||
@ -238,7 +237,6 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public ManualRedactionEntryEntity getAddRedaction(String fileId, String annotationId) {
|
||||
|
||||
return addRedactionPersistenceService.findAddRedaction(fileId, annotationId);
|
||||
@ -285,7 +283,6 @@ public class ManualRedactionService {
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public List<ManualAddResponse> addRemoveRedaction(String dossierId, String fileId, List<RemoveRedactionRequest> removeRedactionRequests) {
|
||||
|
||||
RedactionLog redactionLog = null;
|
||||
|
||||
@ -36,6 +36,7 @@ public class DictionaryPersistenceService {
|
||||
private final EntryRepository entryRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
public TypeEntity addType(String type,
|
||||
String dossierTemplateId,
|
||||
String hexColor,
|
||||
@ -167,6 +168,12 @@ public class DictionaryPersistenceService {
|
||||
return filterDeleted(types, includeDeleted);
|
||||
}
|
||||
|
||||
public List<TypeEntity> getAllDossierTypesForDossierTemplateAndType(String dossierTemplateId, String type, boolean includeDeleted) {
|
||||
|
||||
var types = typeRepository.getAllDossierTypesForDossierTemplateAndType(dossierTemplateId, type);
|
||||
return filterDeleted(types, includeDeleted);
|
||||
}
|
||||
|
||||
|
||||
public List<TypeEntity> getAllTypes(boolean includeDeleted) {
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ public class RemoveRedactionPersistenceService {
|
||||
private final RemoveRedactionRepository removeRedactionRepository;
|
||||
|
||||
|
||||
@Transactional
|
||||
public IdRemovalEntity insert(String fileId, RemoveRedactionRequest removeRedactionRequest) {
|
||||
|
||||
IdRemovalEntity idRemoval = new IdRemovalEntity();
|
||||
|
||||
@ -28,6 +28,8 @@ public interface TypeRepository extends JpaRepository<TypeEntity, String> {
|
||||
@Query("update TypeEntity t set t.version = t.version +1 where t.id = :typeId")
|
||||
void updateByIdSetIncrementVersionByOne(String typeId);
|
||||
|
||||
@Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.type = :type and t.dossierId is not null")
|
||||
List<TypeEntity> getAllDossierTypesForDossierTemplateAndType(String dossierTemplateId, String type);
|
||||
|
||||
@Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.dossierId is null")
|
||||
List<TypeEntity> getAllTypesForDossierTemplate(String dossierTemplateId);
|
||||
|
||||
@ -13,4 +13,21 @@ public class TypeIdUtils {
|
||||
return type + ":" + dossierTemplateId + (dossierId != null ? ":" + dossierId : "");
|
||||
}
|
||||
|
||||
|
||||
public static boolean isDossierTypeId(String typeId) {
|
||||
long count = typeId.chars().filter(ch -> ch == ':').count();
|
||||
return count == 2;
|
||||
|
||||
}
|
||||
|
||||
public static String getDossierIdFromTypeId(String typeId) {
|
||||
var index = typeId.lastIndexOf(":");
|
||||
return typeId.substring(index + 1);
|
||||
}
|
||||
|
||||
public static String getDosssierTemplateTypeIdFromTypeId(String typeId) {
|
||||
var index = typeId.lastIndexOf(":");
|
||||
return typeId.substring(0, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -8,4 +8,5 @@ databaseChangeLog:
|
||||
- column:
|
||||
name: dossier_dictionary_only
|
||||
type: BOOLEAN
|
||||
defaultValueBoolean: false
|
||||
tableName: entity
|
||||
@ -42,8 +42,9 @@ public class TypeProvider {
|
||||
type.setCaseInsensitive(true);
|
||||
type.setDossierTemplateId(dossierTemplate.getId());
|
||||
type.setHasDictionary(true);
|
||||
type.setDossierDictionaryOnly(true);
|
||||
|
||||
dictionaryClient.addType(type,dossier != null ? dossier.getId() : null);
|
||||
dictionaryClient.addType(type);
|
||||
var allTypes = dictionaryClient.getAllTypes(dossierTemplate.getDossierTemplateId(),dossier != null ? dossier.getId() : null,false);
|
||||
|
||||
var foundType =allTypes.getTypes().stream().filter(t -> t.getType().equalsIgnoreCase(typeName)).findAny();
|
||||
|
||||
@ -48,7 +48,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
assertThat(type.getRecommendationHexColor()).isEqualTo("#aaaaaa");
|
||||
assertThat(type.getSkippedHexColor()).isEqualTo("#aaaaaa");
|
||||
assertThat(type.isDossierDictionaryOnly()).isFalse();
|
||||
assertThat(type.isDossierDictionaryOnly()).isTrue();
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("word1", "word2"), false, null, DictionaryEntryType.ENTRY);
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("false_positive1", "false_positive"), false, null, DictionaryEntryType.FALSE_POSITIVE);
|
||||
@ -79,7 +79,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
var request = new UpdateTypeValue();
|
||||
BeanUtils.copyProperties(type, request);
|
||||
type.setSkippedHexColor(null);
|
||||
dictionaryClient.updateType(type.getType(), type.getDossierTemplateId(), request, null);
|
||||
dictionaryClient.updateType(type.getType(), type.getDossierTemplateId(), request);
|
||||
|
||||
var loadedType = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(loadedType.getSkippedHexColor()).isNotNull();
|
||||
@ -182,7 +182,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(dictionary.getEntries()).hasSize(1);
|
||||
assertThat(dictionary.getEntries().iterator().next()).isEqualTo(word);
|
||||
assertThat((dictionary.isDossierDictionaryOnly())).isFalse();
|
||||
assertThat((dictionary.isDossierDictionaryOnly())).isTrue();
|
||||
|
||||
// Act & Assert: Delete word; Should have 'deleted' flag
|
||||
entries = new ArrayList<>();
|
||||
@ -248,8 +248,11 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var dossier = dossierTesterAndProvider.provideTestDossier();
|
||||
|
||||
var dossierTemplate = dossierTemplateClient.getDossierTemplate(dossier.getDossierTemplateId());
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "dossier2");
|
||||
|
||||
var returnedtype1 = dictionaryClient.addType(CreateTypeValue.builder()
|
||||
.type("dossier_redaction_2")
|
||||
.type("dossier_redaction_1")
|
||||
.label("Dossier Redactions")
|
||||
.hexColor("#fcba03")
|
||||
.rank(100)
|
||||
@ -260,30 +263,14 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossier.getDossierTemplateId())
|
||||
.dossierDictionaryOnly(true)
|
||||
.build(), dossier.getId());
|
||||
.build());
|
||||
assertThat(returnedtype1.isDossierDictionaryOnly()).isTrue();
|
||||
|
||||
var dossierTemplate = dossierTemplateClient.getDossierTemplate(dossier.getDossierTemplateId());
|
||||
|
||||
var dossier2 = dossierTesterAndProvider.provideTestDossier(dossierTemplate, "dossier2");
|
||||
|
||||
var returnedType2 = dictionaryClient.addType(CreateTypeValue.builder()
|
||||
.type("dossier_redaction_2")
|
||||
.label("Dossier Redactions 2")
|
||||
.hexColor("#fcba03")
|
||||
.rank(100)
|
||||
.hint(false)
|
||||
.recommendation(false)
|
||||
.description("Something")
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossier2.getDossierTemplateId())
|
||||
.dossierDictionaryOnly(true)
|
||||
.build(), dossier2.getId());
|
||||
assertThat(returnedType2.isDossierDictionaryOnly()).isTrue();
|
||||
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), null, false).getTypes()).isEmpty();
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), dossier.getId(), false).getTypes().size()).isEqualTo(2);
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), dossier2.getId(), false).getTypes().size()).isEqualTo(2);
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), null, false).getTypes().size()).isEqualTo(1);
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), dossier.getId(), false).getTypes().size()).isEqualTo(3);
|
||||
var dictionary = dictionaryClient.getDictionaryForType(returnedtype1.getType(), dossier.getDossierTemplateId(), dossier2.getId());
|
||||
assertThat(dictionaryClient.getAllTypes(dossier.getDossierTemplateId(), dossier2.getId(), false).getTypes().size()).isEqualTo(3);
|
||||
}
|
||||
|
||||
|
||||
@ -303,7 +290,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
.dossierTemplateId(dossierTemplate.getId())
|
||||
.build();
|
||||
|
||||
var createdType = dictionaryClient.addType(type, null);
|
||||
var createdType = dictionaryClient.addType(type);
|
||||
|
||||
var word1 = "Luke Skywalker";
|
||||
var word2 = "Anakin Skywalker";
|
||||
@ -322,10 +309,10 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(actualEntries.size()).isEqualTo(3);
|
||||
assertThat(actualEntries).usingComparator(new ListContentWithoutOrderAndWithoutDuplicatesComparator<>()).isEqualTo(entries);
|
||||
|
||||
dictionaryClient.deleteType(createdType.getType(), createdType.getDossierTemplateId(), null);
|
||||
dictionaryClient.deleteType(createdType.getType(), createdType.getDossierTemplateId());
|
||||
assertThat(dictionaryClient.getAllTypes(createdType.getDossierTemplateId(), null, false).getTypes().size()).isEqualTo(0);
|
||||
|
||||
dictionaryClient.addType(type, null);
|
||||
dictionaryClient.addType(type);
|
||||
|
||||
dictionary = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
|
||||
@ -351,7 +338,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
.dossierTemplateId(dossierTemplate.getId())
|
||||
.build();
|
||||
|
||||
var createdType = dictionaryClient.addType(type, null);
|
||||
var createdType = dictionaryClient.addType(type);
|
||||
|
||||
var word1 = "Luke Skywalker";
|
||||
var word2 = "Anakin Skywalker";
|
||||
@ -398,7 +385,7 @@ public class DictionaryTest extends AbstractPersistenceServerServiceTest {
|
||||
.dossierTemplateId(dossierTemplate.getId())
|
||||
.build();
|
||||
|
||||
var createdType = dictionaryClient.addType(type, null);
|
||||
var createdType = dictionaryClient.addType(type);
|
||||
|
||||
var entries = createDummyEntries(40_000);
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.description("Something")
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossier.getDossierTemplateId())
|
||||
.build(), null);
|
||||
.build());
|
||||
|
||||
assertThat(addedType1).isNotNull();
|
||||
|
||||
@ -115,7 +115,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate2.getId())
|
||||
.hasDictionary(true)
|
||||
.build(), null);
|
||||
.build());
|
||||
|
||||
assertThat(addedType).isNotNull();
|
||||
var entries1 = new ArrayList<String>();
|
||||
@ -135,7 +135,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate2.getId())
|
||||
.hasDictionary(true)
|
||||
.build(), null);
|
||||
.build());
|
||||
var entries2 = new ArrayList<String>();
|
||||
entries2.add("entry1");
|
||||
entries2.add("entry2");
|
||||
@ -155,7 +155,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate3.getId())
|
||||
.hasDictionary(true)
|
||||
.build(), null);
|
||||
.build());
|
||||
|
||||
assertThat(addedType3).isNotNull();
|
||||
var entries3 = new ArrayList<String>();
|
||||
@ -179,7 +179,7 @@ public class DossierTemplateStatsTest extends AbstractPersistenceServerServiceTe
|
||||
.addToDictionaryAction(false)
|
||||
.dossierTemplateId(dossierTemplate5.getId())
|
||||
.hasDictionary(true)
|
||||
.build(), null);
|
||||
.build());
|
||||
assertThat(addedType5).isNotNull();
|
||||
|
||||
Set<String> dossierTemplateIds = new HashSet<>();
|
||||
|
||||
@ -211,8 +211,8 @@ public class DossierTemplateTest extends AbstractPersistenceServerServiceTest {
|
||||
.hasDictionary(true)
|
||||
.build();
|
||||
|
||||
var createdType1 = dictionaryClient.addType(type, null);
|
||||
var createdType2 = dictionaryClient.addType(type2, null);
|
||||
var createdType1 = dictionaryClient.addType(type);
|
||||
var createdType2 = dictionaryClient.addType(type2);
|
||||
|
||||
var loadedType1 = dictionaryClient.getDictionaryForType(createdType1.getType(), createdType1.getDossierTemplateId(), null);
|
||||
var loadedType2 = dictionaryClient.getDictionaryForType(createdType2.getType(), createdType2.getDossierTemplateId(), null);
|
||||
@ -386,8 +386,8 @@ public class DossierTemplateTest extends AbstractPersistenceServerServiceTest {
|
||||
.hasDictionary(true)
|
||||
.build();
|
||||
|
||||
var createdType1 = dictionaryClient.addType(type, null);
|
||||
var createdType2 = dictionaryClient.addType(type2, null);
|
||||
var createdType1 = dictionaryClient.addType(type);
|
||||
var createdType2 = dictionaryClient.addType(type2);
|
||||
|
||||
var loadedType1 = dictionaryClient.getDictionaryForType(createdType1.getType(), createdType1.getDossierTemplateId(), null);
|
||||
var loadedType2 = dictionaryClient.getDictionaryForType(createdType2.getType(), createdType2.getDossierTemplateId(), null);
|
||||
|
||||
@ -27,9 +27,7 @@ import com.iqser.red.service.peristence.v1.server.integration.utils.AbstractPers
|
||||
import com.iqser.red.service.peristence.v1.server.integration.utils.MetricValidationUtils;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.utils.multitenancy.TenantContext;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.CreateTypeValue;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.ManualRedactions;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.Rectangle;
|
||||
@ -101,12 +99,12 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
|
||||
//FIXME should be created on the fly.
|
||||
CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
// CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
|
||||
dictionaryClient.deleteEntries(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
assertThat(dossierDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierDictionary.getEntries().get(0).isDeleted()).isTrue();
|
||||
|
||||
@ -124,11 +122,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.sourceId("SourceId")
|
||||
.build()));
|
||||
|
||||
dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
assertThat(dossierDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierDictionary.getEntries().get(0).isDeleted()).isFalse();
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierTemplateDictionary.getEntries().get(0).isDeleted()).isFalse();
|
||||
|
||||
@ -144,8 +142,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
|
||||
//FIXME should be created on the fly.
|
||||
CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
// CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
|
||||
manualRedactionClient.addRedactionBulk(dossier.getId(),
|
||||
file.getId(),
|
||||
@ -161,11 +159,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
.sourceId("SourceId")
|
||||
.build()));
|
||||
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
assertThat(dossierDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierDictionary.getEntries().get(0).isDeleted()).isFalse();
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().isEmpty()).isTrue();
|
||||
}
|
||||
|
||||
@ -183,8 +181,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), entries, false, null, DictionaryEntryType.ENTRY);
|
||||
|
||||
//FIXME should be created on the fly.
|
||||
CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
// CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
@ -238,8 +236,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), entries, false, null, DictionaryEntryType.ENTRY);
|
||||
|
||||
//FIXME should be created on the fly.
|
||||
CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
// CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
|
||||
var redactionLog = new RedactionLog(1,
|
||||
1,
|
||||
@ -257,10 +255,10 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequest.builder().annotationId("AnnotationId").removeFromDictionary(true).build())).get(0);
|
||||
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(2);
|
||||
assertThat(dossierTemplateDictionary.getEntries().stream().filter(e -> e.getValue().equals("Luke Skywalker")).findFirst().get().isDeleted()).isFalse();
|
||||
|
||||
@ -278,8 +276,8 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
var type = typeProvider.testAndProvideType(dossierTemplate);
|
||||
|
||||
//FIXME should be created on the fly.
|
||||
CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
// CreateTypeValue dossierDictionaryType = MagicConverter.convert(type, CreateTypeValue.class);
|
||||
// dictionaryClient.addType(dossierDictionaryType, dossier.getDossierId());
|
||||
dictionaryClient.addEntry(type.getType(), type.getDossierTemplateId(), List.of("Luke Skywalker"), false, dossier.getDossierId(), DictionaryEntryType.ENTRY);
|
||||
|
||||
|
||||
@ -299,11 +297,11 @@ public class ManualRedactionTest extends AbstractPersistenceServerServiceTest {
|
||||
file.getId(),
|
||||
Set.of(RemoveRedactionRequest.builder().annotationId("AnnotationId").removeFromDictionary(true).removeFromAllDossiers(true).build())).get(0);
|
||||
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
var dossierDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId(), dossier.getDossierId()), null);
|
||||
assertThat(dossierDictionary.getEntries().size()).isEqualTo(1);
|
||||
assertThat(dossierDictionary.getEntries().get(0).isDeleted()).isTrue();
|
||||
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(dossierDictionaryType.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
var dossierTemplateDictionary = internalDictionaryClient.getDictionaryForType(toTypeId(type.getType(), dossierTemplate.getDossierTemplateId()), null);
|
||||
assertThat(dossierTemplateDictionary.getEntries().size()).isEqualTo(0);
|
||||
}
|
||||
|
||||
|
||||
@ -60,12 +60,12 @@ public class TypeTest extends AbstractPersistenceServerServiceTest {
|
||||
var request = new UpdateTypeValue();
|
||||
BeanUtils.copyProperties(type, request);
|
||||
request.setRank(99);
|
||||
dictionaryClient.updateType(type.getType(), type.getDossierTemplateId(), request, null);
|
||||
dictionaryClient.updateType(type.getType(), type.getDossierTemplateId(), request);
|
||||
|
||||
loadedType = dictionaryClient.getDictionaryForType(type.getType(), type.getDossierTemplateId(), null);
|
||||
assertThat(loadedType.getRank()).isEqualTo(99);
|
||||
|
||||
dictionaryClient.deleteType(type.getType(), type.getDossierTemplateId(), null);
|
||||
dictionaryClient.deleteType(type.getType(), type.getDossierTemplateId());
|
||||
|
||||
var typesForTemplate = dictionaryClient.getAllTypes(loadedType.getDossierTemplateId(), null, false).getTypes();
|
||||
assertThat(typesForTemplate).isEmpty();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user