Skip to content

Commit

Permalink
feat: add search by identificationCode
Browse files Browse the repository at this point in the history
  • Loading branch information
BettyB979 committed Dec 11, 2024
1 parent d84a8f1 commit 5243c3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,52 +17,24 @@ public interface QuestioningRepository extends JpaRepository<Questioning, Long>
Questioning findByIdPartitioningAndSurveyUnitIdSu(String idPartitioning,
String surveyUnitIdSu);

/*@Query(value = """
(select
q1_0.*
from
questioning q1_0
where
q1_0.survey_unit_id_su=:searchParam
union
select
q2_0.*
from
questioning q2_0
join
survey_unit su2_0
on su2_0.id_su=q2_0.survey_unit_id_su
where
su2_0.identification_name=:searchParam
union
select
q3_0.*
from
questioning q3_0
left join
questioning_accreditation qa3_0
on q3_0.id=qa3_0.questioning_id
where
exists(select
1
from
questioning_accreditation qa4_0
where
qa4_0.questioning_id=q3_0.id)
and qa3_0.id_contact=:searchParam)
""", nativeQuery = true)*/
@Query("""
SELECT q FROM Questioning q
LEFT JOIN FETCH q.questioningAccreditations acc
LEFT JOIN FETCH q.questioningEvents evt
LEFT JOIN FETCH q.questioningCommunications comm
WHERE q.surveyUnit.idSu = :searchParam
WHERE UPPER(q.surveyUnit.idSu) = :searchParam
UNION
SELECT q FROM Questioning q
LEFT JOIN FETCH q.questioningAccreditations acc
LEFT JOIN FETCH q.questioningEvents evt
LEFT JOIN FETCH q.questioningCommunications comm
WHERE q.surveyUnit.identificationName = :searchParam
WHERE UPPER(q.surveyUnit.identificationName) = :searchParam
UNION
SELECT q FROM Questioning q
LEFT JOIN FETCH q.questioningAccreditations acc
LEFT JOIN FETCH q.questioningEvents evt
LEFT JOIN FETCH q.questioningCommunications comm
WHERE UPPER(q.surveyUnit.identificationCode) = :searchParam
UNION
SELECT q FROM Questioning q
LEFT JOIN FETCH q.questioningAccreditations acc
Expand All @@ -71,7 +43,7 @@ Questioning findByIdPartitioningAndSurveyUnitIdSu(String idPartitioning,
WHERE EXISTS (
SELECT 1 FROM QuestioningAccreditation qa
WHERE qa.questioning = q
AND qa.idContact = :searchParam)
AND UPPER(qa.idContact) = :searchParam)
""")
List<Questioning> findQuestioningByParam(String searchParam);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public Page<SearchQuestioningDto> searchQuestioning(String param, Pageable pagea

}


@Override
public QuestioningDetailsDto getQuestioningDetails(@PathVariable("id") Long id) {
Questioning questioning = findbyId(id);
Expand Down Expand Up @@ -231,7 +232,7 @@ protected String buildV3Url(String baseUrl, String role, String modelName, Strin


private SearchQuestioningDto convertToSearchDto(Questioning questioning) {
SearchQuestioningDtoImpl searchQuestioningDto = modelMapper.map(questioning, SearchQuestioningDtoImpl.class);
SearchQuestioningDtoImpl searchQuestioningDto = new SearchQuestioningDtoImpl();
searchQuestioningDto.setCampaignId(partitioningService.findById(questioning.getIdPartitioning()).getCampaign().getId());
searchQuestioningDto.setListContactIdentifiers(questioning.getQuestioningAccreditations().stream().map(QuestioningAccreditation::getIdContact).toList());
Optional<QuestioningEvent> lastQuestioningEvent = questioningEventService.getLastQuestioningEvent(questioning, TypeQuestioningEvent.STATE_EVENTS);
Expand Down

0 comments on commit 5243c3a

Please sign in to comment.