Pull request #79: RED-2489: Fixed racecondition on update flags
Merge in RED/persistence-service from RED-2489 to master * commit '6e7e8ecdd8720833913c6d37522a15bd569b859b': RED-2489: Fixed racecondition on update flags
This commit is contained in:
commit
4ead936655
@ -78,16 +78,7 @@ public class FileStatusPersistenceService {
|
||||
|
||||
@Transactional
|
||||
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);
|
||||
}, () -> {
|
||||
throw new NotFoundException("Unknown file=" + fileId);
|
||||
});
|
||||
fileRepository.updateFlags(fileId, hasRedactions, hasHints, hasImages, hasSuggestions, hasComments, hasUpdates);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,9 +3,20 @@ package com.iqser.red.service.persistence.management.v1.processor.service.persis
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.dossier.FileEntity;
|
||||
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 javax.persistence.Column;
|
||||
|
||||
public interface FileRepository extends JpaRepository<FileEntity, String> {
|
||||
List<FileEntity> findByDossierId(String dossierId);
|
||||
|
||||
@Modifying
|
||||
@Query("update FileEntity e set e.hasRedactions = :hasRedactions , e.hasHints = :hasHints, e.hasSuggestions = :hasSuggestions, e.hasImages = :hasImages, e.hasUpdates = :hasUpdates, e.hasAnnotationComments = :hasComments where e.id =:fileId")
|
||||
void updateFlags(String fileId, boolean hasRedactions, boolean hasHints, boolean hasImages, boolean hasSuggestions, boolean hasComments, boolean hasUpdates);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user