revert of typeid
This commit is contained in:
parent
6eaf00fed1
commit
c6e22ae3a2
@ -16,6 +16,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -34,7 +36,7 @@ public class DictionaryPersistenceService {
|
||||
checkRankAlreadyExists(type, dossierTemplateId, rank, dossierId);
|
||||
|
||||
TypeEntity t = new TypeEntity();
|
||||
t.setId(type + ":" + getTypeIdSuffix(dossierTemplateId, dossierId));
|
||||
t.setId(toTypeId(type,dossierTemplateId,dossierId));
|
||||
t.setType(type);
|
||||
t.setDossier(dossierId == null ? null : dossierRepository.getOne(dossierId));
|
||||
t.setDossierTemplate(dossierTemplateRepository.getOne(dossierTemplateId));
|
||||
@ -52,12 +54,7 @@ public class DictionaryPersistenceService {
|
||||
|
||||
}
|
||||
|
||||
private String getTypeIdSuffix(String dossierTemplateId, String dossierId) {
|
||||
if (StringUtils.isBlank(dossierTemplateId) && StringUtils.isBlank(dossierId)) {
|
||||
throw new BadRequestException("Either DossierId or DossierTemplateId is required");
|
||||
}
|
||||
return dossierTemplateId != null ? dossierTemplateId + (dossierId != null ? ":" + dossierId : "") : dossierId;
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateType(String typeId, TypeEntity typeValueRequest) {
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.utils;
|
||||
|
||||
public class TypeIdUtils {
|
||||
|
||||
public static String toTypeId(String type, String dossierTemplateId) {
|
||||
return toTypeId(type, dossierTemplateId, null);
|
||||
}
|
||||
|
||||
public static String toTypeId(String type, String dossierTemplateId, String dossierId) {
|
||||
return type + ":" + dossierTemplateId + (dossierId != null ? ":" + dossierId : "");
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class AnalysisFlagsCalculationService {
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = getType(entry.getTypeId());
|
||||
String type = getType(entry.getType());
|
||||
|
||||
if (entry.isRedacted() && !entry.isManual() || entry.isManual() && entry.getStatus()
|
||||
.equals(AnnotationStatus.APPROVED)) {
|
||||
|
||||
@ -4,6 +4,7 @@ import com.google.common.hash.HashFunction;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.iqser.red.service.peristence.v1.server.controller.DictionaryController;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.*;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.*;
|
||||
@ -20,6 +21,8 @@ import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -336,7 +339,7 @@ public class ManualRedactionService {
|
||||
@SuppressWarnings("PMD")
|
||||
public void updateRemoveRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
IdRemovalEntity idRemoval = removeRedactionPersistenceService.findRemoveRedaction(fileId, annotationId);
|
||||
if (idRemoval.isRemoveFromDictionary()) {
|
||||
@ -355,12 +358,12 @@ public class ManualRedactionService {
|
||||
|
||||
|
||||
if (annotationStatus == AnnotationStatus.APPROVED) {
|
||||
removeFromDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
} else if (annotationStatus == AnnotationStatus.DECLINED) {
|
||||
|
||||
// if it was previously approved, revert the delete
|
||||
if (idRemoval.getStatus() == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
addToDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,6 +374,14 @@ public class ManualRedactionService {
|
||||
fileStatusPersistenceService.setUpdateLastManualRedactionAndHasSuggestions(fileId, OffsetDateTime.now(), hasSuggestions);
|
||||
}
|
||||
|
||||
private String buildTypeId(RedactionLogEntry redactionLogEntry, DossierEntity dossier) {
|
||||
if (redactionLogEntry.isDossierDictionaryEntry()) {
|
||||
return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId(), dossier.getId());
|
||||
} else {
|
||||
return toTypeId(redactionLogEntry.getType(), dossier.getDossierTemplateId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void updateForceRedactionStatus(String dossierId, String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
@ -463,9 +474,14 @@ public class ManualRedactionService {
|
||||
private void handleRemoveFromDictionary(String dossierId, String fileId, String annotationId, AnnotationStatus status,
|
||||
boolean removeFromDictionary, boolean revert) {
|
||||
|
||||
|
||||
|
||||
if (status == AnnotationStatus.APPROVED) {
|
||||
|
||||
if (removeFromDictionary) {
|
||||
|
||||
var dossier = dossierPersistenceService.getAndValidateDossier(dossierId);
|
||||
|
||||
RedactionLog redactionLog = fileManagementStorageService.getRedactionLog(dossierId, fileId);
|
||||
Optional<RedactionLogEntry> redactionLogEntryOptional = redactionLog.getRedactionLogEntry()
|
||||
.stream()
|
||||
@ -479,9 +495,9 @@ public class ManualRedactionService {
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (revert) {
|
||||
addToDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
addToDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
} else {
|
||||
removeFromDictionary(redactionLogEntry.getTypeId(), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, status, removeFromDictionary);
|
||||
|
||||
@ -52,7 +52,7 @@ public class FileTesterAndProvider {
|
||||
|
||||
assertThat(fileClient.getDossierStatus(dossier.getId()).size()).isEqualTo(1);
|
||||
|
||||
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(new RedactionLog(1, List.of(RedactionLogEntry.builder().id("annotationId").typeId("manual:" + dossier.getDossierTemplateId()).value("value").build()),
|
||||
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(new RedactionLog(1, List.of(RedactionLogEntry.builder().id("annotationId").type("manual").value("value").build()),
|
||||
null, 0, 0, 0, 0)));
|
||||
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.SECTION_GRID, objectMapper.writeValueAsBytes(new SectionGrid()));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user