diff --git a/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java b/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java index 803bb37..43b28f0 100644 --- a/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java +++ b/platine-management-db/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningRepository.java @@ -17,52 +17,24 @@ public interface QuestioningRepository extends JpaRepository 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 @@ -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 findQuestioningByParam(String searchParam); diff --git a/platine-management-service/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningServiceImpl.java b/platine-management-service/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningServiceImpl.java index 2cc6612..a3c8469 100644 --- a/platine-management-service/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningServiceImpl.java +++ b/platine-management-service/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningServiceImpl.java @@ -161,6 +161,7 @@ public Page searchQuestioning(String param, Pageable pagea } + @Override public QuestioningDetailsDto getQuestioningDetails(@PathVariable("id") Long id) { Questioning questioning = findbyId(id); @@ -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 lastQuestioningEvent = questioningEventService.getLastQuestioningEvent(questioning, TypeQuestioningEvent.STATE_EVENTS);