Pull request #93: RED-2494 Replace all updates (find-if-present-write) with atomic operations
Merge in RED/persistence-service from feature/RED-2494 to master * commit 'e7fe2e352f51c859dc84cd73cc15b300ea5c5180': RED-2494 Replace all updates (find-if-present-write) with atomic operations
This commit is contained in:
commit
dd8eb8b20c
@ -55,8 +55,7 @@ public class AddRedactionPersistenceService {
|
||||
|
||||
public ManualRedactionEntryEntity findAddRedaction(String fileId, String annotationId) {
|
||||
|
||||
return manualRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return manualRedactionRepository.findAddRedaction(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() ->
|
||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
@ -64,7 +63,7 @@ public class AddRedactionPersistenceService {
|
||||
|
||||
public Set<ManualRedactionEntryEntity> findAddRedactions(String fileId, boolean includeDeletions) {
|
||||
|
||||
return manualRedactionRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
||||
return manualRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -33,12 +33,12 @@ public class CommentPersistenceService {
|
||||
|
||||
|
||||
public List<CommentEntity> findCommentsByAnnotationId(String fileId, String annotationId, boolean includeDeletions) {
|
||||
return commentRepository.findByFileIdAndAnnotationId(fileId, annotationId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toList());
|
||||
return commentRepository.findByFileIdAndAnnotationId(fileId, annotationId, includeDeletions);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, List<CommentEntity>> findCommentsByFileID(String fileId, boolean includeDeletions) {
|
||||
List<CommentEntity> comments = commentRepository.findByFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toList());
|
||||
List<CommentEntity> comments = commentRepository.findByFileId(fileId, includeDeletions);
|
||||
|
||||
return comments.stream().collect(Collectors.groupingBy(CommentEntity::getAnnotationId));
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.transaction.Transactional;
|
||||
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;
|
||||
|
||||
@ -67,22 +66,18 @@ public class DictionaryPersistenceService {
|
||||
|
||||
public Optional<TypeEntity> getTypeForRank(String dossierTemplateId, int rank, String dossierId) {
|
||||
|
||||
return typeRepository.findOneByDossierTemplateAndDossierAndRank(
|
||||
dossierTemplateRepository.getOne(dossierTemplateId), dossierId == null ? null : dossierRepository.getOne(dossierId), rank);
|
||||
return typeRepository.findOneByDossierTemplateIdAndDossierIdAndRank(dossierTemplateId, dossierId, rank);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<TypeEntity> getCumulatedTypes(String dossierTemplateId, String dossierId) {
|
||||
|
||||
var templateTypes = getAllTypesForDossierTemplate(dossierTemplateId);
|
||||
templateTypes.addAll(getAllTypesForDossier(dossierId));
|
||||
return templateTypes;
|
||||
return typeRepository.findAllTypesByDossierTemplateIdOrDossierId(dossierTemplateId, dossierId);
|
||||
}
|
||||
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossierTemplate(String dossierTemplateId) {
|
||||
return typeRepository.findByDossierTemplateId(dossierTemplateId).stream().filter(d -> d.getDossierId() == null).collect(Collectors.toList());
|
||||
return typeRepository.getAllTypesForDossierTemplate(dossierTemplateId);
|
||||
}
|
||||
|
||||
public List<TypeEntity> getAllTypesForDossier(String dossierId) {
|
||||
@ -117,11 +112,11 @@ public class DictionaryPersistenceService {
|
||||
}
|
||||
|
||||
public long getVersion(String dossierTemplateId) {
|
||||
return getAllTypesForDossierTemplate(dossierTemplateId).stream().map(TypeEntity::getVersion).reduce(0L, Long::sum);
|
||||
return typeRepository.getVersionForDossierTemplateId(dossierTemplateId);
|
||||
}
|
||||
|
||||
public long getVersionForDossier(String dossierId) {
|
||||
return getAllTypesForDossier(dossierId).stream().map(TypeEntity::getVersion).reduce(0L, Long::sum);
|
||||
return typeRepository.getVersionForDossierId(dossierId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ public class DossierAttributeConfigPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void deleteDossierAttributes(List<String> dossierAttributeIds) {
|
||||
dossierAttributeIds.forEach(dossierAttributeConfigRepository::deleteById);
|
||||
dossierAttributeConfigRepository.deleteByDossierAtributeIds(dossierAttributeIds);
|
||||
}
|
||||
|
||||
public List<DossierAttributeConfigEntity> getDossierAttributes(String dossierTemplateId) {
|
||||
|
||||
@ -57,7 +57,7 @@ public class DossierTemplatePersistenceService {
|
||||
}
|
||||
|
||||
public DossierTemplateEntity getDossierTemplate(String dossierTemplateId) {
|
||||
return dossierTemplateRepository.findById(dossierTemplateId).filter(d -> !d.isDeleted()).orElseThrow(() -> new NotFoundException(String.format(DOSSIER_TEMPLATE_NOT_FOUND_MESSAGE, dossierTemplateId)));
|
||||
return dossierTemplateRepository.findByIdAndDeleted(dossierTemplateId, false).orElseThrow(() -> new NotFoundException(String.format(DOSSIER_TEMPLATE_NOT_FOUND_MESSAGE, dossierTemplateId)));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@ -55,26 +55,13 @@ public class FileStatusPersistenceService {
|
||||
public void updateWorkflowStatus(String fileId, int numberOfPages, long dictionaryVersion, long rulesVersion,
|
||||
long legalBasisVersion, long duration, long dossierDictionaryVersion,
|
||||
int analysisVersion) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setNumberOfPages(numberOfPages);
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setDictionaryVersion(dictionaryVersion);
|
||||
file.setRulesVersion(rulesVersion);
|
||||
file.setLegalBasisVersion(legalBasisVersion);
|
||||
file.setAnalysisDuration(duration);
|
||||
file.setDossierDictionaryVersion(dossierDictionaryVersion);
|
||||
file.setAnalysisVersion(analysisVersion);
|
||||
file.setNumberOfAnalyses(file.getNumberOfAnalyses() + 1);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastProcessed(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateWorkflowStatus(fileId, numberOfPages, ProcessingStatus.PROCESSED,
|
||||
dictionaryVersion, rulesVersion, legalBasisVersion, duration, dossierDictionaryVersion,
|
||||
analysisVersion, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@ -92,16 +79,12 @@ public class FileStatusPersistenceService {
|
||||
@Transactional
|
||||
public void updateWorkflowStatus(String fileId, WorkflowStatus workflowStatus, boolean approval) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setWorkflowStatus(workflowStatus);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setApprovalDate(approval ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateWorkflowStatus(fileId, workflowStatus,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
approval ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : null);
|
||||
|
||||
}
|
||||
|
||||
@ -109,79 +92,52 @@ public class FileStatusPersistenceService {
|
||||
@Transactional
|
||||
public void updateProcessingStatus(String fileId, ProcessingStatus processingStatus) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setProcessingStatus(processingStatus);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateProcessingStatus(fileId, processingStatus, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setUpdateStatusIndexingSuccessful(String fileId) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastIndexed(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.setUpdateStatusIndexingSuccessful(fileId, ProcessingStatus.PROCESSED,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastOCRTime(String fileId, OffsetDateTime time) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastOCRTime(time);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateLastOCRTime(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), time);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateHasComments(String fileId, boolean hasComments) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setHasAnnotationComments(hasComments);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateHasComments(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), hasComments);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void updateLastManualRedaction(String fileId, OffsetDateTime date) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastManualRedaction(date);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.updateLastManualRedaction(fileId, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), date);
|
||||
}
|
||||
|
||||
|
||||
@ -189,17 +145,11 @@ public class FileStatusPersistenceService {
|
||||
public void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime date,
|
||||
boolean hasSuggestions) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastManualRedaction(date);
|
||||
file.setHasSuggestions(hasSuggestions);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
fileRepository.setUpdateLastManualRedactionAndHasSuggestions(fileId,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), date, hasSuggestions);
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +175,6 @@ public class FileStatusPersistenceService {
|
||||
|
||||
@Transactional
|
||||
public void setExcludedPages(String fileId, Set<Integer> excludedPages) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
@ -237,6 +186,12 @@ public class FileStatusPersistenceService {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
// if (isFileDeleted(fileId)) {
|
||||
// return;
|
||||
// }
|
||||
// fileRepository.setExcludedPages(fileId,
|
||||
// OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
// OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), excludedPages);
|
||||
}
|
||||
|
||||
|
||||
@ -262,33 +217,25 @@ public class FileStatusPersistenceService {
|
||||
@Transactional
|
||||
public void softDelete(String fileId, OffsetDateTime softDeletedTime) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setProcessingStatus(ProcessingStatus.DELETED);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setDeleted(softDeletedTime);
|
||||
}, () -> {
|
||||
int countUpdate = fileRepository.setSoftDelete(fileId, ProcessingStatus.DELETED,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), softDeletedTime);
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void hardDelete(String fileId) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setProcessingStatus(ProcessingStatus.DELETED);
|
||||
file.setDeleted(file.getDeleted() == null ? OffsetDateTime.now()
|
||||
.truncatedTo(ChronoUnit.MILLIS) : file.getDeleted());
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setDeleted(file.getDeleted() == null ? OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS) : file.getDeleted());
|
||||
file.setHardDeletedTime(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
|
||||
fileAttributesRepository.deleteByFileId(fileId);
|
||||
}, () -> {
|
||||
int countUpdate = fileRepository.setHardDelete(fileId, ProcessingStatus.DELETED,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
fileAttributesRepository.deleteByFileId(fileId);
|
||||
}
|
||||
|
||||
|
||||
@ -299,94 +246,51 @@ public class FileStatusPersistenceService {
|
||||
if (file.getHardDeletedTime() != null) {
|
||||
throw new BadRequestException("Cannot undelete a hard-deleted dossier file!");
|
||||
}
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setProcessingStatus(ProcessingStatus.PROCESSED);
|
||||
file.setDeleted(null);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
fileRepository.setSoftDelete(fileId, ProcessingStatus.PROCESSED,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS), null);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void setCurrentReviewer(String fileId, String currentReviewer, String lastReviewer) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setCurrentReviewer(currentReviewer);
|
||||
file.setLastReviewer(lastReviewer);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setWorkflowStatus(currentReviewer == null ? WorkflowStatus.UNASSIGNED : WorkflowStatus.UNDER_REVIEW);
|
||||
file.setWorkflowStatus(currentReviewer == null ? WorkflowStatus.UNASSIGNED : WorkflowStatus.UNDER_REVIEW);
|
||||
}, () -> {
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
int updateCount = fileRepository.setCurrentReviewer(fileId, currentReviewer, lastReviewer,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
currentReviewer == null ? WorkflowStatus.UNASSIGNED : WorkflowStatus.UNDER_REVIEW);
|
||||
if (updateCount == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void toggleExclusion(String fileId, boolean excluded) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
if (isFileDeleted(file)) {
|
||||
return;
|
||||
}
|
||||
file.setExcluded(excluded);
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastProcessed(null);
|
||||
file.setLastReviewer(null);
|
||||
file.setCurrentReviewer(null);
|
||||
file.setApprovalDate(null);
|
||||
file.setLastManualRedaction(null);
|
||||
file.setDictionaryVersion(0);
|
||||
file.setDossierDictionaryVersion(0);
|
||||
file.setRulesVersion(0);
|
||||
file.setHasImages(false);
|
||||
file.setHasHints(false);
|
||||
file.setHasRedactions(false);
|
||||
file.setHasSuggestions(false);
|
||||
file.setHasUpdates(false);
|
||||
}, () -> {
|
||||
if (isFileDeleted(fileId)) {
|
||||
return;
|
||||
}
|
||||
int countUpdate = fileRepository.toggleExclusion(fileId, excluded, OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void overwriteFile(String fileId, String uploader, String filename) {
|
||||
|
||||
fileRepository.findById(fileId).ifPresentOrElse((file) -> {
|
||||
file.setFilename(filename);
|
||||
file.setUploader(uploader);
|
||||
file.setProcessingStatus(ProcessingStatus.FULLREPROCESS);
|
||||
file.setWorkflowStatus(WorkflowStatus.UNASSIGNED);
|
||||
file.setLastUploaded(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastUpdated(OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
file.setLastOCRTime(null);
|
||||
file.setExcluded(false);
|
||||
file.setLastProcessed(null);
|
||||
file.setLastReviewer(null);
|
||||
file.setCurrentReviewer(null);
|
||||
file.setApprovalDate(null);
|
||||
file.setLastManualRedaction(null);
|
||||
file.setDictionaryVersion(0);
|
||||
file.setDossierDictionaryVersion(0);
|
||||
file.setRulesVersion(0);
|
||||
file.setHasImages(false);
|
||||
file.setHasHints(false);
|
||||
file.setHasRedactions(false);
|
||||
file.setHasSuggestions(false);
|
||||
file.setHasUpdates(false);
|
||||
file.setExcludedPages(new HashSet<>());
|
||||
file.setDeleted(null);
|
||||
file.setHardDeletedTime(null);
|
||||
}, () -> {
|
||||
int countUpdate = fileRepository.overwriteFile(fileId, filename, uploader, ProcessingStatus.FULLREPROCESS,
|
||||
WorkflowStatus.UNASSIGNED,
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS),
|
||||
OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS));
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -60,8 +60,7 @@ public class ForceRedactionPersistenceService {
|
||||
|
||||
public ManualForceRedactionEntity findForceRedaction(String fileId, String annotationId) {
|
||||
|
||||
return forceRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return forceRedactionRepository.findByIdAndNotSoftDeleted(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() ->
|
||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
@ -69,9 +68,7 @@ public class ForceRedactionPersistenceService {
|
||||
|
||||
public Set<ManualForceRedactionEntity> findForceRedactions(String fileId, boolean includeDeletions) {
|
||||
|
||||
return forceRedactionRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
||||
|
||||
return forceRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@ -57,8 +56,7 @@ public class ImageRecategorizationPersistenceService {
|
||||
|
||||
public ManualImageRecategorizationEntity findRecategorization(String fileId, String annotationId) {
|
||||
|
||||
return imageRecategorizationRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return imageRecategorizationRepository.findByIdAndNotSoftDeleted(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() ->
|
||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
@ -66,7 +64,7 @@ public class ImageRecategorizationPersistenceService {
|
||||
|
||||
public List<ManualImageRecategorizationEntity> findRecategorizations(String fileId, boolean includeDeletions) {
|
||||
|
||||
return imageRecategorizationRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toList());
|
||||
return imageRecategorizationRepository.findByFileIdIncludeDeletions(fileId, includeDeletions);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -58,8 +58,7 @@ public class LegalBasisChangePersistenceService {
|
||||
}
|
||||
|
||||
public ManualLegalBasisChangeEntity findLegalBasisChange(String fileId, String annotationId) {
|
||||
return legalBasisChangeRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return legalBasisChangeRepository.findByIdAndNotSoftDeleted(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() ->
|
||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
@ -67,7 +66,7 @@ public class LegalBasisChangePersistenceService {
|
||||
|
||||
public Set<ManualLegalBasisChangeEntity> findLegalBasisChanges(String fileId, boolean includeDeletions) {
|
||||
|
||||
return legalBasisChangeRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
||||
return legalBasisChangeRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -39,9 +39,10 @@ public class NotificationPersistenceService {
|
||||
@Transactional
|
||||
public void setSeenDate(String userId, long notificationId, OffsetDateTime seenDate) {
|
||||
|
||||
notificationRepository.findByIdAndUserId(notificationId, userId).ifPresentOrElse(notification -> notification.setSeenDate(seenDate), () -> {
|
||||
int countUpdate = notificationRepository.setSeenDate(userId, notificationId, seenDate);
|
||||
if (countUpdate == 0) {
|
||||
throw new NotFoundException("Notification not found");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,15 +37,14 @@ public class RemoveRedactionPersistenceService {
|
||||
|
||||
public IdRemovalEntity findRemoveRedaction(String fileId, String annotationId) {
|
||||
|
||||
return removeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return removeRedactionRepository.findByIdAndNotSoftDeleted(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() ->
|
||||
new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
|
||||
|
||||
public Set<IdRemovalEntity> findRemoveRedactions(String fileId, boolean includeDeletions) {
|
||||
return removeRedactionRepository.findByIdFileId(fileId).stream().filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null).collect(Collectors.toSet());
|
||||
return removeRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions).stream().collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@ -4,8 +4,6 @@ import static com.iqser.red.service.persistence.management.v1.processor.utils.Ma
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@ -48,10 +46,7 @@ public class ResizeRedactionPersistenceService {
|
||||
@Transactional
|
||||
public void updateStatus(String fileId, String annotationId, AnnotationStatus annotationStatus) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId)).ifPresent(mre -> {
|
||||
mre.setProcessedDate(OffsetDateTime.now());
|
||||
mre.setStatus(annotationStatus);
|
||||
});
|
||||
resizeRedactionRepository.updateStatus(new AnnotationEntityId(annotationId, fileId), annotationStatus, OffsetDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
@ -65,34 +60,27 @@ public class ResizeRedactionPersistenceService {
|
||||
@Transactional
|
||||
public void softDelete(String fileId, String annotationId, OffsetDateTime softDeleteTime) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.ifPresent(mre -> mre.setSoftDeletedTime(softDeleteTime));
|
||||
resizeRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), softDeleteTime);
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
public void undelete(String fileId, String annotationId) {
|
||||
|
||||
resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.ifPresent(mre -> mre.setSoftDeletedTime(null));
|
||||
resizeRedactionRepository.updateSoftDelete(new AnnotationEntityId(annotationId, fileId), null);
|
||||
}
|
||||
|
||||
|
||||
public ManualResizeRedactionEntity findResizeRedaction(String fileId, String annotationId) {
|
||||
|
||||
return resizeRedactionRepository.findById(new AnnotationEntityId(annotationId, fileId))
|
||||
.filter(mre -> mre.getSoftDeletedTime() == null)
|
||||
return resizeRedactionRepository.findByIdAndNotSoftDeleted(new AnnotationEntityId(annotationId, fileId))
|
||||
.orElseThrow(() -> new NotFoundException("Unknown file/annotation combination: " + fileId + "/" + annotationId));
|
||||
}
|
||||
|
||||
|
||||
public List<ManualResizeRedactionEntity> findResizeRedactions(String fileId, boolean includeDeletions) {
|
||||
|
||||
return resizeRedactionRepository.findByIdFileId(fileId)
|
||||
.stream()
|
||||
.filter(mre -> includeDeletions || mre.getSoftDeletedTime() == null)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return resizeRedactionRepository.findByFileIdIncludeDeletions(fileId, includeDeletions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,9 +10,12 @@ import java.util.List;
|
||||
|
||||
public interface CommentRepository extends JpaRepository<CommentEntity, Long> {
|
||||
|
||||
List<CommentEntity> findByFileIdAndAnnotationId(String fileId, String annotationId);
|
||||
@Query("select e from CommentEntity e where e.fileId = :fileId and e.annotationId = :annotationId " +
|
||||
"and (:includeDeletions = true or e.softDeletedTime is null)")
|
||||
List<CommentEntity> findByFileIdAndAnnotationId(String fileId, String annotationId, boolean includeDeletions);
|
||||
|
||||
List<CommentEntity> findByFileId(String fileId);
|
||||
@Query("select e from CommentEntity e where e.fileId = :fileId and (:includeDeletions = true or e.softDeletedTime is null)")
|
||||
List<CommentEntity> findByFileId(String fileId, boolean includeDeletions);
|
||||
|
||||
boolean existsByFileIdAndSoftDeletedTimeIsNull(String fileId);
|
||||
|
||||
|
||||
@ -2,6 +2,8 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.DossierAttributeConfigEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -10,4 +12,8 @@ public interface DossierAttributeConfigRepository extends JpaRepository<DossierA
|
||||
List<DossierAttributeConfigEntity> findAllByDossierTemplateId(String dossierTemplateId);
|
||||
|
||||
void deleteByDossierTemplateId(String dossierTemplateId);
|
||||
|
||||
@Modifying
|
||||
@Query("delete from DossierAttributeConfigEntity d where d.id in :dossierAttributeIds")
|
||||
void deleteByDossierAtributeIds(List<String> dossierAttributeIds);
|
||||
}
|
||||
|
||||
@ -5,9 +5,12 @@ import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface DossierTemplateRepository extends JpaRepository<DossierTemplateEntity, String> {
|
||||
|
||||
@Query("select d from DossierTemplateEntity d where d.deleted = false or d.deleted is null")
|
||||
List<DossierTemplateEntity> findAllWhereDeletedIsFalse();
|
||||
|
||||
Optional<DossierTemplateEntity> findByIdAndDeleted(String dossierTemplateId, boolean isDeleted);
|
||||
}
|
||||
|
||||
@ -2,14 +2,16 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.ProcessingStatus;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.WorkflowStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
||||
public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
|
||||
@ -31,6 +33,100 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
boolean hasSuggestions,
|
||||
boolean hasComments,
|
||||
boolean hasUpdates);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.numberOfPages = :numberOfPages, f.processingStatus = :processingStatus, " +
|
||||
"f.dictionaryVersion = :dictionaryVersion, f.rulesVersion = :rulesVersion, f.legalBasisVersion = :legalBasisVersion, " +
|
||||
"f.analysisDuration = :analysisDuration, f.dossierDictionaryVersion = :dossierDictionaryVersion, " +
|
||||
"f.analysisVersion = :analysisVersion, f.numberOfAnalyses = f.numberOfAnalyses + 1, f.lastUpdated = :lastUpdated, " +
|
||||
"f.lastProcessed = :lastProcessed " +
|
||||
"where f.id = :fileId")
|
||||
void updateWorkflowStatus(String fileId, int numberOfPages, ProcessingStatus processingStatus, long dictionaryVersion,
|
||||
long rulesVersion, long legalBasisVersion, long analysisDuration, long dossierDictionaryVersion,
|
||||
int analysisVersion, OffsetDateTime lastUpdated, OffsetDateTime lastProcessed);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.workflowStatus = :workflowStatus, f.lastUpdated = :lastUpdated, f.approvalDate = :approvalDate " +
|
||||
"where f.id = :fileId")
|
||||
void updateWorkflowStatus(String fileId, WorkflowStatus workflowStatus, OffsetDateTime lastUpdated, OffsetDateTime approvalDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated " +
|
||||
"where f.id = :fileId")
|
||||
void updateProcessingStatus(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," +
|
||||
"f.lastIndexed = :lastIndexed where f.id = :fileId")
|
||||
void setUpdateStatusIndexingSuccessful(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated,
|
||||
OffsetDateTime lastIndexed);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastOCRTime = :lastOCRTime where f.id = :fileId")
|
||||
void updateLastOCRTime(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastOCRTime);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.hasAnnotationComments = :hasAnnotationComments where f.id = :fileId")
|
||||
void updateHasComments(String fileId, OffsetDateTime lastUpdated, boolean hasAnnotationComments);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastManualRedaction = :lastManualRedaction where f.id = :fileId")
|
||||
void updateLastManualRedaction(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastManualRedaction);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastManualRedaction = :lastManualRedaction, " +
|
||||
"f.hasSuggestions = :hasSuggestions where f.id = :fileId")
|
||||
void setUpdateLastManualRedactionAndHasSuggestions(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastManualRedaction,
|
||||
boolean hasSuggestions);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.lastUpdated = :lastUpdated, f.lastManualRedaction = :lastManualRedaction, " +
|
||||
"f.excludedPages = :excludedPages where f.id = :fileId")
|
||||
void setExcludedPages(String fileId, OffsetDateTime lastUpdated, OffsetDateTime lastManualRedaction,
|
||||
Set<Integer> excludedPages);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated, " +
|
||||
"f.deleted = :softDeletedTime where f.id = :fileId")
|
||||
int setSoftDelete(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated,
|
||||
OffsetDateTime softDeletedTime);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.processingStatus = :processingStatus, f.lastUpdated = :lastUpdated," +
|
||||
"f.hardDeletedTime = :hardDeletedTime, " +
|
||||
"f.deleted = case " +
|
||||
"when f.deleted is null then :deleted " +
|
||||
"when f.deleted is not null then f.deleted " +
|
||||
"end " +
|
||||
"where f.id = :fileId")
|
||||
int setHardDelete(String fileId, ProcessingStatus processingStatus, OffsetDateTime lastUpdated,
|
||||
OffsetDateTime hardDeletedTime, OffsetDateTime deleted);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.currentReviewer = :currentReviewer, f.lastReviewer = :lastReviewer," +
|
||||
"f.lastUpdated = :lastUpdated, f.workflowStatus = :workflowStatus where f.id = :fileId")
|
||||
int setCurrentReviewer(String fileId, String currentReviewer, String lastReviewer, OffsetDateTime lastUpdated,
|
||||
WorkflowStatus workflowStatus);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.excluded = :excluded, f.lastUpdated = :lastUpdated, f.lastProcessed = null, " +
|
||||
"f.lastReviewer = null, f.currentReviewer = null, f.approvalDate = null, f.lastManualRedaction = null, " +
|
||||
"f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " +
|
||||
"f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false " +
|
||||
"where f.id = :fileId")
|
||||
int toggleExclusion(String fileId, boolean excluded, OffsetDateTime lastUpdated);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity f set f.filename = :filename, f.uploader = :uploader, f.processingStatus = :processingStatus, " +
|
||||
"f.workflowStatus = :workflowStatus, f.lastUploaded = :lastUploaded, f.lastUpdated = :lastUpdated, " +
|
||||
"f.lastOCRTime = null, f.excluded = false, f.lastProcessed = null, f.lastReviewer = null, " +
|
||||
"f.currentReviewer = null, f.approvalDate = null, f.lastManualRedaction = null, " +
|
||||
"f.dictionaryVersion = 0, f.dossierDictionaryVersion = 0, f.rulesVersion = 0, f.hasImages = false, " +
|
||||
"f.hasHints = false, f.hasRedactions = false, f.hasSuggestions = false, f.hasUpdates = false, " +
|
||||
"f.deleted = null, f.hardDeletedTime = null " +
|
||||
"where f.id = :fileId")
|
||||
int overwriteFile(String fileId, String uploader, String filename, ProcessingStatus processingStatus,
|
||||
WorkflowStatus workflowStatus, OffsetDateTime lastUploaded, OffsetDateTime lastUpdated);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ForceRedactionRepository extends JpaRepository<ManualForceRedactionEntity, AnnotationEntityId> {
|
||||
|
||||
@ -24,4 +25,10 @@ public interface ForceRedactionRepository extends JpaRepository<ManualForceRedac
|
||||
"where mfr.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
@Query("select mfr from ManualForceRedactionEntity mfr where mfr.id = :annotationEntityId and mfr.softDeletedTime is null")
|
||||
Optional<ManualForceRedactionEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
@Query("select mfr from ManualForceRedactionEntity mfr where mfr.id.fileId = :fileId and (:includeDeletions = true or mfr.softDeletedTime is null)")
|
||||
List<ManualForceRedactionEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ImageRecategorizationRepository extends JpaRepository<ManualImageRecategorizationEntity, AnnotationEntityId> {
|
||||
List<ManualImageRecategorizationEntity> findByIdFileId(String fileId);
|
||||
@ -23,4 +24,9 @@ public interface ImageRecategorizationRepository extends JpaRepository<ManualIma
|
||||
"where mir.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
@Query("select mir from ManualImageRecategorizationEntity mir where mir.id = :annotationEntityId and mir.softDeletedTime is null")
|
||||
Optional<ManualImageRecategorizationEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
@Query("select mir from ManualImageRecategorizationEntity mir where mir.id.fileId = :fileId and (:includeDeletions = true or mir.softDeletedTime is null)")
|
||||
List<ManualImageRecategorizationEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface LegalBasisChangeRepository extends JpaRepository<ManualLegalBasisChangeEntity, AnnotationEntityId> {
|
||||
|
||||
@ -23,4 +24,11 @@ public interface LegalBasisChangeRepository extends JpaRepository<ManualLegalBas
|
||||
@Query("update ManualLegalBasisChangeEntity mlbc set mlbc.softDeletedTime = :softDeletedTime " +
|
||||
"where mlbc.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
@Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id = :annotationEntityId and mlbc.softDeletedTime is null")
|
||||
Optional<ManualLegalBasisChangeEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
@Query("select mlbc from ManualLegalBasisChangeEntity mlbc where mlbc.id.fileId = :fileId and (:includeDeletions = true or mlbc.softDeletedTime is null)")
|
||||
List<ManualLegalBasisChangeEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ManualRedactionRepository extends JpaRepository<ManualRedactionEntryEntity, AnnotationEntityId> {
|
||||
|
||||
@ -27,4 +28,10 @@ public interface ManualRedactionRepository extends JpaRepository<ManualRedaction
|
||||
@Query("update ManualRedactionEntryEntity m set m.processedDate = :processedDate, m.status = :annotationStatus," +
|
||||
" m.addToDictionary = :isAddOrRemoveFromDictionary where m.id = :id")
|
||||
void updateStatus(AnnotationEntityId id, OffsetDateTime processedDate, AnnotationStatus annotationStatus, boolean isAddOrRemoveFromDictionary);
|
||||
|
||||
@Query("select m from ManualRedactionEntryEntity m where m.id = :id and m.softDeletedTime is null")
|
||||
Optional<ManualRedactionEntryEntity> findAddRedaction(AnnotationEntityId id);
|
||||
|
||||
@Query("select m from ManualRedactionEntryEntity m where m.id.fileId = :fileId and (:includeDeletions = true or m.softDeletedTime is null)")
|
||||
List<ManualRedactionEntryEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity, AnnotationEntityId> {
|
||||
|
||||
@ -30,4 +31,10 @@ public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity
|
||||
void updateStatusAndRemoveFromDictionary(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate,
|
||||
boolean removeFromDictionary);
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id = :annotationEntityId and idr.softDeletedTime is null")
|
||||
Optional<IdRemovalEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and (:includeDeletions = true or idr.softDeletedTime is null)")
|
||||
List<IdRemovalEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,35 @@
|
||||
package com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.annotations.AnnotationStatus;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualResizeRedactionEntity;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface ResizeRedactionRepository extends JpaRepository<ManualResizeRedactionEntity, AnnotationEntityId> {
|
||||
|
||||
List<ManualResizeRedactionEntity> findByIdFileId(String fileId);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualResizeRedactionEntity mrd set mrd.status = :annotationStatus, mrd.processedDate = :processedDate " +
|
||||
"where mrd.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus, OffsetDateTime processedDate);
|
||||
|
||||
@Modifying
|
||||
@Query("update ManualResizeRedactionEntity mrd set mrd.softDeletedTime = :softDeletedTime " +
|
||||
"where mrd.id = :annotationEntityId")
|
||||
void updateSoftDelete(AnnotationEntityId annotationEntityId, OffsetDateTime softDeletedTime);
|
||||
|
||||
@Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id = :annotationEntityId and mrd.softDeletedTime is null")
|
||||
Optional<ManualResizeRedactionEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
@Query("select mrd from ManualResizeRedactionEntity mrd where mrd.id.fileId = :fileId and (:includeDeletions = true or mrd.softDeletedTime is null)")
|
||||
List<ManualResizeRedactionEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
}
|
||||
|
||||
@ -14,6 +14,8 @@ public interface TypeRepository extends JpaRepository<TypeEntity, String> {
|
||||
|
||||
Optional<TypeEntity> findOneByDossierTemplateAndDossierAndRank(DossierTemplateEntity dossierTemplate, DossierEntity dossier, int rank);
|
||||
|
||||
Optional<TypeEntity> findOneByDossierTemplateIdAndDossierIdAndRank(String dossierTemplate, String dossier, int rank);
|
||||
|
||||
List<TypeEntity> findByDossierTemplateId(String dossierTemplateId);
|
||||
|
||||
List<TypeEntity> findByDossierId(String dossierId);
|
||||
@ -21,4 +23,16 @@ public interface TypeRepository extends JpaRepository<TypeEntity, String> {
|
||||
@Modifying
|
||||
@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.dossierId is null")
|
||||
List<TypeEntity> getAllTypesForDossierTemplate(String dossierTemplateId);
|
||||
|
||||
@Query("select t from TypeEntity t where t.dossierTemplateId = :dossierTemplateId or t.dossierId = :dossierId")
|
||||
List<TypeEntity> findAllTypesByDossierTemplateIdOrDossierId(String dossierTemplateId, String dossierId);
|
||||
|
||||
@Query("select coalesce(sum(t.version),0) from TypeEntity t where t.dossierId = :dossierId")
|
||||
long getVersionForDossierId(String dossierId);
|
||||
|
||||
@Query("select coalesce(sum(t.version),0) from TypeEntity t where t.dossierTemplateId = :dossierTemplateId and t.dossierId is null")
|
||||
long getVersionForDossierTemplateId(String dossierTemplateId);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user