Fixed various efsa readyness issues
This commit is contained in:
parent
db85b2415c
commit
df7091110f
@ -1,19 +1,13 @@
|
||||
package com.iqser.red.service.persistence.service.v1.api.resources;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.CreateOrUpdateDossierRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.Dossier;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public interface DossierResource {
|
||||
@ -26,6 +20,8 @@ public interface DossierResource {
|
||||
String DOSSIER_ID_PARAM = "dossierId";
|
||||
String DOSSIER_ID_PATH_PARAM = "/{" + DOSSIER_ID_PARAM + "}";
|
||||
|
||||
String INCLUDE_DELETED_PARAM = "includeDeleted";
|
||||
|
||||
@PostMapping(value = REST_PATH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
Dossier addDossier(@RequestBody CreateOrUpdateDossierRequest dossierRequest);
|
||||
|
||||
@ -39,7 +35,8 @@ public interface DossierResource {
|
||||
List<Dossier> getAllDossiers();
|
||||
|
||||
@GetMapping(value = REST_PATH + DOSSIER_ID_PATH_PARAM, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
Dossier getDossierById(@PathVariable(DOSSIER_ID_PARAM) String dossierId);
|
||||
Dossier getDossierById(@PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted);
|
||||
|
||||
@GetMapping(value = DELETED_DOSSIERS_PATH, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
List<Dossier> getSoftDeletedDossiers();
|
||||
|
||||
@ -5,7 +5,7 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
|
||||
@ -26,6 +26,10 @@ public class ViewedPageEntity {
|
||||
@MapsId("fileId")
|
||||
private FileEntity file;
|
||||
|
||||
public int getPage() {
|
||||
return this.id.page;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@Embeddable
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.configuration.ColorsEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.ColorsRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -15,12 +14,25 @@ public class ColorsService {
|
||||
private final ColorsRepository colorsRepository;
|
||||
|
||||
public void deleteColors(String dossierTemplateId) {
|
||||
|
||||
colorsRepository.deleteById(dossierTemplateId);
|
||||
}
|
||||
|
||||
public ColorsEntity getColors(String dossierTemplateId) {
|
||||
return colorsRepository.findById(dossierTemplateId).orElseThrow(() -> new NotFoundException("Colors Configuration not found"));
|
||||
return colorsRepository.findById(dossierTemplateId).orElseGet(() -> {
|
||||
var entity = new ColorsEntity();
|
||||
entity.setDossierTemplateId(dossierTemplateId);
|
||||
entity.setAnalysisColor("#aaaaaa");
|
||||
entity.setDefaultColor("#aaaaaa");
|
||||
entity.setDictionaryRequestColor("#aaaaaa");
|
||||
entity.setPreviewColor("#aaaaaa");
|
||||
entity.setNotRedacted("#aaaaaa");
|
||||
entity.setManualRedactionColor("#aaaaaa");
|
||||
entity.setRequestAdd("#aaaaaa");
|
||||
entity.setRequestRemove("#aaaaaa");
|
||||
entity.setUpdatedColor("#aaaaaa");
|
||||
return colorsRepository.save(entity);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public ColorsEntity saveColors(ColorsEntity colors) {
|
||||
|
||||
@ -8,10 +8,9 @@ import com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryMode
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.domain.ExampleMatcher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
@ -19,6 +18,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.AuditRepository.*;
|
||||
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -47,23 +48,29 @@ public class AuditPersistenceService {
|
||||
|
||||
public Page<AuditEntity> search(AuditSearchRequest auditRequest) {
|
||||
|
||||
if (auditRequest.getPageSize() == 0) {
|
||||
auditRequest.setPageSize(50);
|
||||
}
|
||||
|
||||
AuditEntity example = new AuditEntity();
|
||||
example.setCategory(auditRequest.getCategory());
|
||||
example.setUserId(auditRequest.getUserId());
|
||||
example.setObjectId(auditRequest.getObjectId());
|
||||
if (auditRequest.getFrom() == null) {
|
||||
auditRequest.setFrom(OffsetDateTime.now().minusYears(30));
|
||||
}
|
||||
if (auditRequest.getTo() == null) {
|
||||
auditRequest.setTo(OffsetDateTime.now());
|
||||
}
|
||||
|
||||
var result = auditRepository.findAll(Example.of(example, ExampleMatcher.matchingAny().withIgnorePaths("recordId")),
|
||||
PageRequest.of(auditRequest.getPage(), auditRequest.getPageSize()));
|
||||
var spec = Specification.where(dateBetween(auditRequest.getFrom(), auditRequest.getTo()));
|
||||
if (auditRequest.getCategory() != null) {
|
||||
spec = spec.and(categoryMatches(auditRequest.getCategory()));
|
||||
}
|
||||
if (auditRequest.getUserId() != null) {
|
||||
spec = spec.and(userMatches(auditRequest.getUserId()));
|
||||
}
|
||||
if (auditRequest.getObjectId() != null) {
|
||||
spec = spec.and(objectIdMatches(auditRequest.getObjectId()));
|
||||
}
|
||||
|
||||
// after search, insert a record logging the search
|
||||
this.insertRecord(AuditRequest.builder()
|
||||
.category(AUDIT_LOG_CATEGORY)
|
||||
.message("Audit Log Accessed")
|
||||
.userId(auditRequest.getRequestingUserId())
|
||||
.details(searchRequestToMap(auditRequest))
|
||||
.build());
|
||||
return result;
|
||||
return auditRepository.findAll(spec, PageRequest.of(auditRequest.getPage(), auditRequest.getPageSize()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,6 @@ import com.iqser.red.service.persistence.management.v1.processor.service.persist
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.DossierTemplateRepository;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.TypeRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -36,7 +35,7 @@ public class DictionaryPersistenceService {
|
||||
checkRankAlreadyExists(type, dossierTemplateId, rank, dossierId);
|
||||
|
||||
TypeEntity t = new TypeEntity();
|
||||
t.setId(toTypeId(type,dossierTemplateId,dossierId));
|
||||
t.setId(toTypeId(type, dossierTemplateId, dossierId));
|
||||
t.setType(type);
|
||||
t.setDossier(dossierId == null ? null : dossierRepository.getOne(dossierId));
|
||||
t.setDossierTemplate(dossierTemplateRepository.getOne(dossierTemplateId));
|
||||
@ -55,7 +54,6 @@ public class DictionaryPersistenceService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateType(String typeId, TypeEntity typeValueRequest) {
|
||||
|
||||
@ -84,7 +82,7 @@ public class DictionaryPersistenceService {
|
||||
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossierTemplate(String dossierTemplateId) {
|
||||
return typeRepository.findByDossierTemplateId(dossierTemplateId).stream().filter( d -> d.getDossierId() == null).collect(Collectors.toList());
|
||||
return typeRepository.findByDossierTemplateId(dossierTemplateId).stream().filter(d -> d.getDossierId() == null).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossier(String dossierId) {
|
||||
|
||||
@ -36,6 +36,7 @@ public class DossierPersistenceService {
|
||||
BeanUtils.copyProperties(createOrUpdateDossierRequest, dossier);
|
||||
dossier.setId(UUID.randomUUID().toString());
|
||||
dossier.setStatus(DossierStatus.ACTIVE);
|
||||
dossier.setDate(OffsetDateTime.now());
|
||||
|
||||
dossier.setDossierTemplate(dossierTemplateRepository.getOne(createOrUpdateDossierRequest.getDossierTemplateId()));
|
||||
dossier.setReportTemplates(reportTemplateRepository.findAllById(createOrUpdateDossierRequest.getReportTemplateIds()));
|
||||
|
||||
@ -41,8 +41,7 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateStatusSuccessful(String fileId, int numberOfPages, FileStatus status,
|
||||
boolean hasUpdates, long dictionaryVersion, long rulesVersion,
|
||||
public void updateStatusSuccessful(String fileId, int numberOfPages, FileStatus status, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion) {
|
||||
|
||||
@ -50,7 +49,6 @@ public class FileStatusPersistenceService {
|
||||
file.setNumberOfPages(numberOfPages);
|
||||
file.setStatus(status);
|
||||
file.setLastSuccessfulStatus(status);
|
||||
file.setHasUpdates(hasUpdates);
|
||||
file.setDictionaryVersion(dictionaryVersion);
|
||||
file.setRulesVersion(rulesVersion);
|
||||
file.setLegalBasisVersion(legalBasisVersion);
|
||||
@ -67,10 +65,11 @@ public class FileStatusPersistenceService {
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateFlags(String fileId,boolean hasRedactions,boolean hasHints,boolean hasImages,boolean hasSuggestions,boolean hasComments){
|
||||
public void updateFlags(String fileId, boolean hasRedactions, boolean hasHints, boolean hasImages, boolean hasSuggestions, boolean hasComments, boolean hasUpdates) {
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setHasRedactions(hasRedactions);
|
||||
file.setHasHints(hasHints);
|
||||
file.setHasUpdates(hasUpdates);
|
||||
file.setHasImages(hasImages);
|
||||
file.setHasSuggestions(hasSuggestions);
|
||||
file.setHasAnnotationComments(hasComments);
|
||||
|
||||
@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
||||
@ -2,14 +2,34 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.audit.AuditEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryModel;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public interface AuditRepository extends JpaRepository<AuditEntity, Long> {
|
||||
public interface AuditRepository extends JpaRepository<AuditEntity, Long>, JpaSpecificationExecutor<AuditEntity> {
|
||||
|
||||
static Specification<AuditEntity> categoryMatches(String category) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("category"), category);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> userMatches(String user) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("userId"), user);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> objectIdMatches(String objectId) {
|
||||
return (audit, cq, cb) -> cb.equal(audit.get("objectId"), objectId);
|
||||
}
|
||||
|
||||
static Specification<AuditEntity> dateBetween(OffsetDateTime start, OffsetDateTime end) {
|
||||
return (audit, cq, cb) -> cb.between(audit.get("recordDate"), start, end);
|
||||
}
|
||||
|
||||
@Query("SELECT new com.iqser.red.service.persistence.service.v1.api.model.audit.CategoryModel(a.category, count(a)) FROM AuditEntity a GROUP BY a.category")
|
||||
List<CategoryModel> findCategories();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Converter
|
||||
public class JSONConverter implements AttributeConverter<Map<String, Object>, String> {
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ import feign.Param;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
@ -23,8 +24,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.exception.DossierNotFoundException.DOSSIER_NOT_FOUND_MESSAGE;
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@ -85,10 +86,11 @@ public class DossierController implements DossierResource {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Dossier getDossierById(@Param(DOSSIER_ID_PARAM) @PathVariable(DOSSIER_ID_PARAM) String dossierId) {
|
||||
public Dossier getDossierById(@Param(DOSSIER_ID_PARAM) @PathVariable(DOSSIER_ID_PARAM) String dossierId,
|
||||
@RequestParam(name = INCLUDE_DELETED_PARAM, defaultValue = "false", required = false) boolean includeDeleted) {
|
||||
|
||||
DossierEntity dossier = dossierService.getDossierById(dossierId);
|
||||
if (dossier.getStatus().equals(DossierStatus.DELETED)) {
|
||||
if (dossier.getStatus().equals(DossierStatus.DELETED) && !includeDeleted) {
|
||||
throw new DossierNotFoundException(String.format(DOSSIER_NOT_FOUND_MESSAGE, dossierId));
|
||||
}
|
||||
return convert(dossier, Dossier.class, new DossierMapper());
|
||||
|
||||
@ -75,6 +75,7 @@ public class FileStatusController implements StatusResource {
|
||||
|
||||
fileStatusService.setCurrentReviewer(dossierId, fileId, currentFileReviewerRequest.getValue());
|
||||
fileStatusService.setStatusSuccessful(fileId, FileStatus.UNDER_REVIEW);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
@ -86,6 +87,7 @@ public class FileStatusController implements StatusResource {
|
||||
String lastReviewer = fileStatus.getLastReviewer();
|
||||
fileStatusService.setCurrentReviewer(dossierId, fileId, lastReviewer);
|
||||
fileStatusService.setStatusSuccessful(fileId, FileStatus.UNDER_REVIEW);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
@ -100,6 +102,7 @@ public class FileStatusController implements StatusResource {
|
||||
|
||||
fileStatusService.setCurrentReviewer(dossierId, fileId, approverId != null ? approverId : dossierOwner);
|
||||
fileStatusService.setStatusSuccessful(fileId, FileStatus.UNDER_APPROVAL);
|
||||
analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ public class ManualRedactionController implements ManualRedactionResource {
|
||||
public void deleteComment(@PathVariable(FILE_ID) String fileId, @PathVariable(COMMENT_ID) long commentId) {
|
||||
|
||||
manualRedactionService.deleteComment(fileId, commentId);
|
||||
// TODO analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
// TODO analysisFlagsCalculationService.calculateFlags(dossierId, fileId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ViewedPageEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.ViewedPagesPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLogEntry;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -15,19 +19,29 @@ public class AnalysisFlagsCalculationService {
|
||||
|
||||
private final FileStatusPersistenceService fileStatusPersistenceService;
|
||||
private final RedactionLogService redactionLogService;
|
||||
private final ViewedPagesPersistenceService viewedPagesPersistenceService;
|
||||
|
||||
|
||||
@Async
|
||||
public void calculateFlags(String dossierId, String fileId) {
|
||||
|
||||
var file = fileStatusPersistenceService.getStatus(fileId);
|
||||
var redactionLog = redactionLogService.getRedactionLog(dossierId, fileId, true);
|
||||
|
||||
var viewedPagesForCurrentReviewer = viewedPagesPersistenceService.findViewedPages(fileId, file.getCurrentReviewer());
|
||||
|
||||
Map<Integer, OffsetDateTime> viewedPages = viewedPagesForCurrentReviewer.stream().collect(Collectors.toMap(ViewedPageEntity::getPage, ViewedPageEntity::getViewedTime));
|
||||
|
||||
boolean hasRedactions = false;
|
||||
boolean hasHints = false;
|
||||
boolean hasSuggestions = false;
|
||||
boolean hasImages = false;
|
||||
boolean hasUpdates = false;
|
||||
boolean hasComments = false;
|
||||
|
||||
|
||||
viewedPagesPersistenceService.findViewedPages(fileId, file.getCurrentReviewer());
|
||||
|
||||
for (RedactionLogEntry entry : redactionLog.getRedactionLogEntry()) {
|
||||
if (entry.isExcluded()) {
|
||||
continue;
|
||||
@ -57,16 +71,23 @@ public class AnalysisFlagsCalculationService {
|
||||
hasComments = true;
|
||||
}
|
||||
|
||||
if (hasRedactions && hasHints && hasSuggestions && hasImages && hasComments) {
|
||||
var lastChange = entry.getChanges().isEmpty() ? null : entry.getChanges().get(entry.getChanges().size() - 1);
|
||||
if (lastChange != null && lastChange.getDateTime() != null &&
|
||||
!entry.getPositions().isEmpty() && viewedPages.get(entry.getPositions().get(0).getPage()).isBefore(lastChange.getDateTime())) {
|
||||
hasUpdates = true;
|
||||
}
|
||||
|
||||
|
||||
if (hasRedactions && hasHints && hasSuggestions && hasImages && hasComments && hasUpdates) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fileStatusPersistenceService.updateFlags(fileId, hasRedactions, hasHints, hasImages, hasSuggestions, hasComments);
|
||||
fileStatusPersistenceService.updateFlags(fileId, hasRedactions, hasHints, hasImages, hasSuggestions, hasComments, hasUpdates);
|
||||
}
|
||||
|
||||
|
||||
private String getType(String typeId){
|
||||
private String getType(String typeId) {
|
||||
return typeId.split(":")[0];
|
||||
}
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ import com.iqser.red.service.persistence.management.v1.processor.exception.Confl
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.CreateOrUpdateDossierRequest;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.DossierStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -31,7 +30,7 @@ public class DossierService {
|
||||
|
||||
if (dossierPersistenceService.findAllDossiers()
|
||||
.stream()
|
||||
.anyMatch(p -> !p.getStatus().equals(DossierStatus.DELETED) && p.getDossierName()
|
||||
.anyMatch(p -> p.getHardDeletedTime() == null && p.getDossierName()
|
||||
.equals(createOrUpdateDossierRequest.getDossierName()))) {
|
||||
throw new ConflictException("Dossier with this name already exists");
|
||||
}
|
||||
@ -48,7 +47,7 @@ public class DossierService {
|
||||
if (dossier.getDossierName()
|
||||
.equals(dossierRequest.getDossierName()) || dossierPersistenceService.findAllDossiers()
|
||||
.stream()
|
||||
.filter(p -> !p.getStatus().equals(DossierStatus.DELETED) && p.getDossierName()
|
||||
.filter(p -> p.getHardDeletedTime() == null && p.getDossierName()
|
||||
.equals(dossierRequest.getDossierName()))
|
||||
.findAny()
|
||||
.isEmpty()) {
|
||||
|
||||
@ -65,7 +65,7 @@ public class FileStatusService {
|
||||
|
||||
public void setStatusSuccessful(String dossierId, String fileId, FileStatus status, AnalyzeResult analyzeResult) {
|
||||
|
||||
fileStatusPersistenceService.updateStatusSuccessful(fileId, analyzeResult.getNumberOfPages(), status, analyzeResult.isHasUpdates(), analyzeResult.getDictionaryVersion(), analyzeResult.getRulesVersion(), analyzeResult.getLegalBasisVersion(), analyzeResult.getDuration(), analyzeResult.getDossierDictionaryVersion(), analyzeResult.getAnalysisVersion());
|
||||
fileStatusPersistenceService.updateStatusSuccessful(fileId, analyzeResult.getNumberOfPages(), status, analyzeResult.getDictionaryVersion(), analyzeResult.getRulesVersion(), analyzeResult.getLegalBasisVersion(), analyzeResult.getDuration(), analyzeResult.getDossierDictionaryVersion(), analyzeResult.getAnalysisVersion());
|
||||
}
|
||||
|
||||
|
||||
@ -225,13 +225,9 @@ public class FileStatusService {
|
||||
.fileAttributes(convert(fileAttributes))
|
||||
.build();
|
||||
|
||||
if (!fileStatus.getStatus().equals(FileStatus.UNPROCESSED) && !fileStatus.getStatus()
|
||||
analyseRequest.setReanalyseOnlyIfPossible(!fileStatus.getStatus().equals(FileStatus.UNPROCESSED) && !fileStatus.getStatus()
|
||||
.equals(FileStatus.FULLREPROCESS) && fileStatus.getRulesVersion() == rulesController.getVersion(dossier.getDossierTemplateId()) && (fileStatus.getLastFileAttributeChange() == null || fileStatus.getLastProcessed()
|
||||
.isAfter(fileStatus.getLastFileAttributeChange()))) {
|
||||
analyseRequest.setReanalyseOnlyIfPossible(true);
|
||||
} else {
|
||||
analyseRequest.setReanalyseOnlyIfPossible(false);
|
||||
}
|
||||
.isAfter(fileStatus.getLastFileAttributeChange())));
|
||||
|
||||
analyseRequest.setExcludedPages(fileStatus.getExcludedPages());
|
||||
|
||||
|
||||
@ -9,19 +9,12 @@ import com.iqser.red.service.persistence.service.v1.api.model.annotations.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ManualRedactionProviderService {
|
||||
@ -59,14 +52,12 @@ public class ManualRedactionProviderService {
|
||||
}
|
||||
|
||||
|
||||
private Set<ManualRedactionEntry> convertEntriesToAdd(Set<ManualRedactionEntryEntity> source){
|
||||
private Set<ManualRedactionEntry> convertEntriesToAdd(Set<ManualRedactionEntryEntity> source) {
|
||||
|
||||
return source.stream().map(entry ->
|
||||
convert(entry, ManualRedactionEntry.class, new ManualRedactionMapper())
|
||||
convert(entry, ManualRedactionEntry.class, new ManualRedactionMapper())
|
||||
).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ public class ManualRedactionService {
|
||||
|
||||
// if it was previously approved, revert the delete
|
||||
if (idRemoval.getStatus() == AnnotationStatus.APPROVED) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,6 @@ public class ManualRedactionService {
|
||||
boolean removeFromDictionary, boolean revert) {
|
||||
|
||||
|
||||
|
||||
if (status == AnnotationStatus.APPROVED) {
|
||||
|
||||
if (removeFromDictionary) {
|
||||
@ -495,9 +494,9 @@ public class ManualRedactionService {
|
||||
var redactionLogEntry = redactionLogEntryOptional.get();
|
||||
|
||||
if (revert) {
|
||||
addToDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
addToDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
} else {
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry,dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
removeFromDictionary(buildTypeId(redactionLogEntry, dossier), redactionLogEntry.getValue(), dossierId, fileId);
|
||||
}
|
||||
}
|
||||
removeRedactionPersistenceService.updateStatus(fileId, annotationId, status, removeFromDictionary);
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.iqser.red.service.peristence.v1.server.client.RedactionClient;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionLog;
|
||||
import com.iqser.red.service.redaction.v1.model.RedactionRequest;
|
||||
import com.iqser.red.service.redaction.v1.model.SectionGrid;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@ -4,24 +4,12 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.configuration.MessagingConfiguration;
|
||||
import com.iqser.red.service.peristence.v1.server.model.DownloadJob;
|
||||
import com.iqser.red.service.peristence.v1.server.service.DossierService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.ReportTemplateEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.download.DownloadStatusEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DownloadStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.download.DownloadStatusValue;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -42,7 +30,4 @@ public class DownloadMessageReceiver {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ public class DownloadPreparationService {
|
||||
private void addReports(ReportResultMessage reportResultMessage, FileSystemBackedArchiver fileSystemBackedArchiver) {
|
||||
|
||||
long addReportsStart = System.currentTimeMillis();
|
||||
|
||||
|
||||
for (StoredFileInformation storedFileInformation : reportResultMessage.getStoredFileInformation()) {
|
||||
|
||||
|
||||
|
||||
@ -1,14 +1,5 @@
|
||||
package com.iqser.red.service.peristence.v1.server.service.download;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.configuration.MessagingConfiguration;
|
||||
@ -20,8 +11,14 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.download
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DownloadStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.download.DownloadStatusValue;
|
||||
import com.iqser.red.service.redaction.report.v1.api.model.ReportRequestMessage;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@ -20,9 +20,9 @@ import java.util.zip.ZipOutputStream;
|
||||
@Slf4j
|
||||
public class FileSystemBackedArchiver implements AutoCloseable {
|
||||
|
||||
private Set<String> createdFolders = new HashSet<>();
|
||||
private File tempFile;
|
||||
private ZipOutputStream zipOutputStream;
|
||||
private final Set<String> createdFolders = new HashSet<>();
|
||||
private final File tempFile;
|
||||
private final ZipOutputStream zipOutputStream;
|
||||
|
||||
@SneakyThrows
|
||||
public FileSystemBackedArchiver() {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
package com.iqser.red.service.peristence.v1.server.utils;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.ManualRedactionEntry;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.Rectangle;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static com.iqser.red.service.persistence.management.v1.processor.utils.MagicConverter.convert;
|
||||
|
||||
public class ManualRedactionMapper implements BiConsumer<ManualRedactionEntryEntity, ManualRedactionEntry> {
|
||||
|
||||
@Override
|
||||
|
||||
@ -40,7 +40,7 @@ public class DossierTesterAndProvider {
|
||||
|
||||
assertThat(result.getDossierName()).isEqualTo("Dossier 1");
|
||||
|
||||
Dossier loadedDossier = dossierClient.getDossierById(result.getId());
|
||||
Dossier loadedDossier = dossierClient.getDossierById(result.getId(),false);
|
||||
|
||||
assertThat(loadedDossier).isEqualTo(result);
|
||||
|
||||
|
||||
@ -39,5 +39,8 @@ public class AuditTest extends AbstractPersistenceServerServiceTest {
|
||||
var result = auditClient.search(AuditSearchRequest.builder().category("c1").page(0).pageSize(10).build());
|
||||
assertThat(result.getTotalHits()).isEqualTo(2);
|
||||
|
||||
result = auditClient.search(AuditSearchRequest.builder().build());
|
||||
assertThat(result.getTotalHits()).isEqualTo(3);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class DossierTest extends AbstractPersistenceServerServiceTest {
|
||||
assertThat(updated.getDossierName()).isEqualTo("Dossier 1 Update");
|
||||
|
||||
|
||||
var loadedTemplate = dossierClient.getDossierById(updated.getId());
|
||||
var loadedTemplate = dossierClient.getDossierById(updated.getId(),false);
|
||||
|
||||
assertThat(loadedTemplate).isEqualTo(updated);
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ public class DownloadPreparationTest extends AbstractPersistenceServerServiceTes
|
||||
.reportTemplateIds(availableTemplates.stream().map(a -> a.getTemplateId()).collect(Collectors.toList()))
|
||||
.build(), dossier.getId());
|
||||
|
||||
var updatedDossier = dossierClient.getDossierById(dossier.getId());
|
||||
var updatedDossier = dossierClient.getDossierById(dossier.getId(),false);
|
||||
assertThat(updatedDossier.getReportTemplateIds()).isNotEmpty();
|
||||
|
||||
downloadClient.prepareDownload(DownloadRequest.builder()
|
||||
|
||||
@ -174,7 +174,6 @@ public class FileTest extends AbstractPersistenceServerServiceTest {
|
||||
|
||||
var loadedFile = fileClient.getFileStatus(dossierId, fileId);
|
||||
|
||||
assertThat(loadedFile.isHasAnnotationComments()).isEqualTo(true);
|
||||
assertThat(manualRedactionClient.getAddRedaction(fileId, addRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
|
||||
assertThat(manualRedactionClient.getRemoveRedaction(fileId, removeRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
|
||||
assertThat(manualRedactionClient.getForceRedaction(fileId, forceRedaction.getAnnotationId()).getFileId()).isEqualTo(loadedFile.getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user