Merge pull request #56 from Kitzanos/call-document-issue

Chhery-pick(Fixed Call Document issue)
This commit is contained in:
rbonazzo-KZ
2024-10-22 14:25:25 +02:00
committed by GitHub
2 changed files with 11 additions and 8 deletions

View File

@@ -239,7 +239,7 @@ public class CallDao {
} }
List<DocumentEntity> existingDocuments = documentRepository List<DocumentEntity> existingDocuments = documentRepository
.findBySourceIdAndTypeAndIsDeletedFalse(sourceId, documentType.getValue()); .findBySourceIdAndSourceAndTypeAndIsDeletedFalse(sourceId, DocumentSourceTypeEnum.CALL.getValue(), documentType.getValue());
List<Long> incomingIds = documentReqList.stream().map(DocumentReq::getId).filter(id -> id != null && id > 0) List<Long> incomingIds = documentReqList.stream().map(DocumentReq::getId).filter(id -> id != null && id > 0)
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -259,7 +259,7 @@ public class CallDao {
private DocumentEntity convertToDocumentEntity(DocumentReq documentReq,Long sourceId) { private DocumentEntity convertToDocumentEntity(DocumentReq documentReq,Long sourceId) {
validateDocumentEntity(documentReq.getId()); validateDocumentEntity(documentReq.getId());
DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndIsDeletedFalse(documentReq.getId(),sourceId) DocumentEntity documentEntity = documentRepository.findByIdAndSourceIdAndSourceAndIsDeletedFalse(documentReq.getId(),sourceId, DocumentSourceTypeEnum.CALL.getValue())
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, .orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND))); Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
return documentEntity; return documentEntity;
@@ -618,10 +618,10 @@ public class CallDao {
} }
private CallResponse getCallResponseBean(CallEntity callEntity) { private CallResponse getCallResponseBean(CallEntity callEntity) {
List<DocumentEntity> documentEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(), List<DocumentEntity> documentEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(),DocumentSourceTypeEnum.CALL.getValue()
DocumentTypeEnum.DOCUMENT.getValue()); , DocumentTypeEnum.DOCUMENT.getValue());
List<DocumentEntity> imageEntities = documentRepository.findBySourceIdAndTypeAndIsDeletedFalse(callEntity.getId(), List<DocumentEntity> imageEntities = documentRepository.findBySourceIdAndSourceAndTypeAndIsDeletedFalse(callEntity.getId(), DocumentSourceTypeEnum.CALL.getValue()
DocumentTypeEnum.IMAGES.getValue()); , DocumentTypeEnum.IMAGES.getValue());
List<LookUpDataResponse> amiedTo = callTargetAudienceChecklistRepository List<LookUpDataResponse> amiedTo = callTargetAudienceChecklistRepository
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream() .findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream()
.map(this::convertToLookUpDataResponseBean).toList(); .map(this::convertToLookUpDataResponseBean).toList();

View File

@@ -15,12 +15,15 @@ public interface DocumentRepository extends JpaRepository<DocumentEntity, Long>
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false") @Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
Optional<DocumentEntity> findById(@Param("id") Long id); Optional<DocumentEntity> findById(@Param("id") Long id);
List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type); // List<DocumentEntity> findBySourceIdAndTypeAndIsDeletedFalse(Long sourceId, String type);
Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId); // Optional<DocumentEntity> findByIdAndSourceIdAndIsDeletedFalse(Long id, Long sourceId);
List<DocumentEntity> findBySource(String source); List<DocumentEntity> findBySource(String source);
List<DocumentEntity> findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type); List<DocumentEntity> findBySourceIdAndSourceAndTypeAndIsDeletedFalse(Long sourceId, String source, String type);
Optional<DocumentEntity> findByIdAndSourceIdAndSourceAndIsDeletedFalse(Long id, Long sourceId, String source);
} }