diff --git a/pom.xml b/pom.xml
index 4280ad98..834ee02d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
fr.insee.survey
platine-management
- 2.6.0
+ 2.6.1
platine-management
REST API for communication between DB and Platine-Management UI and Platine-My-Surveys UI
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/contact/controller/ContactController.java b/src/main/java/fr/insee/survey/datacollectionmanagement/contact/controller/ContactController.java
index b79d3fca..76516791 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/contact/controller/ContactController.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/contact/controller/ContactController.java
@@ -82,8 +82,9 @@ public ContactPage getContacts(
@GetMapping(value = Constants.API_CONTACTS_ID)
@PreAuthorize(AuthorityPrivileges.HAS_MANAGEMENT_PRIVILEGES + " || " + AuthorityPrivileges.HAS_REPONDENT_LIMITATED_PRIVILEGES)
public ContactDetailsDto getContact(@PathVariable("id") String id) {
- Contact contact = contactService.findByIdentifier(StringUtils.upperCase(id));
- List listCampaigns = questioningAccreditationService.findCampaignsForContactId(id);
+ String idContact = StringUtils.upperCase(id);
+ Contact contact = contactService.findByIdentifier(idContact);
+ List listCampaigns = viewService.findDistinctCampaignByIdentifier(idContact);
return convertToContactDetailsDto(contact, listCampaigns);
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningAccreditationRepository.java b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningAccreditationRepository.java
index d6c89e3b..5eeed936 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningAccreditationRepository.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/repository/QuestioningAccreditationRepository.java
@@ -2,59 +2,11 @@
import fr.insee.survey.datacollectionmanagement.questioning.domain.QuestioningAccreditation;
import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface QuestioningAccreditationRepository extends JpaRepository {
- String QUERY_FIND_IDCONTACT =
- "select id_contact from questioning_accreditation qa "
- + " join questioning q "
- + " on q.id =qa.questioning_id "
- + " where q.id_partitioning = ?1 ";
-
- String QUERY_FIND_IDPARTIONING =
- "select q.id_partitioning from questioning q "
- + "join questioning_accreditation qa "
- + "on q.id =qa.questioning_id "
- + "where qa.id_contact =?1 ";
-
- String FIND_METADATA_COPY =
- "select "
- + " id_contact "
- + "from "
- + " questioning_accreditation qa "
- + "join questioning q on q.id = qa.questioning_id "
- +" join metadata_copy mc on mc.id_partitioning = q.id_partitioning ";
-
-
- String QUERY_SOURCE_YEAR_PERIOD = FIND_METADATA_COPY + " where mc.id = ?1 and mc.year_value = ?2 and mc.period_value = ?3 ";
-
- String QUERY_SOURCE = FIND_METADATA_COPY + " where mc.id = ?1 ";
-
- String QUERY_YEAR = FIND_METADATA_COPY + " where mc.year_value = ?1 ";
-
- String QUERY_PERIOD = FIND_METADATA_COPY + " where mc.period_value = ?1 ";
-
List findByIdContact(String idContact);
- @Query(nativeQuery = true, value = QUERY_FIND_IDCONTACT)
- List findIdContactsByPartitionigAccredications(String idPartitioning);
-
- @Query(nativeQuery = true, value = QUERY_FIND_IDPARTIONING)
- List findIdPartitioningsByContactAccreditations(String idContact);
-
- @Query(nativeQuery = true, value = QUERY_SOURCE)
- List findIdContactsByIdSource(String idSource);
-
- @Query(nativeQuery = true, value = QUERY_YEAR)
- List findIdContactsByYear(Integer year);
-
- @Query(nativeQuery = true, value = QUERY_PERIOD)
- List findIdContactsByPeriod(String period);
-
- @Query(nativeQuery = true, value = QUERY_SOURCE_YEAR_PERIOD)
- List findIdContactsBySourceYearPeriod(String source, Integer year, String period);
-
}
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/QuestioningAccreditationService.java b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/QuestioningAccreditationService.java
index 358fe83c..cade3fd3 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/QuestioningAccreditationService.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/QuestioningAccreditationService.java
@@ -10,7 +10,6 @@ public interface QuestioningAccreditationService {
List findByContactIdentifier(String id);
-
Page findAll(Pageable pageable);
QuestioningAccreditation findById(Long id);
@@ -18,6 +17,4 @@ public interface QuestioningAccreditationService {
QuestioningAccreditation saveQuestioningAccreditation(QuestioningAccreditation questioningAccreditation);
void deleteAccreditation(QuestioningAccreditation c);
-
- List findCampaignsForContactId(String id);
}
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningAccreditationServiceImpl.java b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningAccreditationServiceImpl.java
index b2827241..fe8e862c 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningAccreditationServiceImpl.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/questioning/service/impl/QuestioningAccreditationServiceImpl.java
@@ -2,9 +2,7 @@
import fr.insee.survey.datacollectionmanagement.exception.NotFoundException;
import fr.insee.survey.datacollectionmanagement.metadata.service.PartitioningService;
-import fr.insee.survey.datacollectionmanagement.questioning.domain.Questioning;
import fr.insee.survey.datacollectionmanagement.questioning.domain.QuestioningAccreditation;
-import fr.insee.survey.datacollectionmanagement.questioning.domain.SurveyUnit;
import fr.insee.survey.datacollectionmanagement.questioning.repository.QuestioningAccreditationRepository;
import fr.insee.survey.datacollectionmanagement.questioning.service.QuestioningAccreditationService;
import lombok.RequiredArgsConstructor;
@@ -12,9 +10,7 @@
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
@Service
@RequiredArgsConstructor
@@ -27,13 +23,6 @@ public List findByContactIdentifier(String id) {
return questioningAccreditationRepository.findByIdContact(id);
}
- public Set findBySurveyUnit(SurveyUnit su) {
- Set setReturn = new HashSet<>();
- for (Questioning qu : su.getQuestionings()) {
- setReturn.addAll(qu.getQuestioningAccreditations());
- }
- return setReturn;
- }
@Override
public Page findAll(Pageable pageable) {
@@ -55,10 +44,4 @@ public void deleteAccreditation(QuestioningAccreditation acc) {
questioningAccreditationRepository.deleteById(acc.getId());
}
- @Override
- public List findCampaignsForContactId(String id) {
- List listContactAccreditations = findByContactIdentifier(id);
- return listContactAccreditations.stream().map(acc -> partitioningService.findById(acc.getQuestioning().getIdPartitioning()).getCampaign().getId()).distinct().toList();
- }
-
}
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/view/repository/ViewRepository.java b/src/main/java/fr/insee/survey/datacollectionmanagement/view/repository/ViewRepository.java
index e8d43b20..b4597733 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/view/repository/ViewRepository.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/view/repository/ViewRepository.java
@@ -11,29 +11,41 @@
@Repository
public interface ViewRepository extends PagingAndSortingRepository, JpaRepository {
- static final String FIND_DISTNCT_VIEW_BY_IDENTIFIER = "select "
- + " distinct on "
- + " (v.identifier) "
- + " v.id as id, "
- + " v.identifier as identifier, "
- + " v.campaign_id as campaign_id, "
- + " v.id_su as id_su "
- + "from "
- + " \"view\" v "
- + "where "
- + " campaign_id =?1 ";
+ String FIND_DISTNCT_VIEW_BY_IDENTIFIER = """
+ select
+ distinct on
+ (v.identifier)
+ v.id as id,
+ v.identifier as identifier,
+ v.campaign_id as campaign_id,
+ v.id_su as id_su
+ from
+ view v
+ where
+ campaign_id =?1""";
+
+ String FIND_DISTNCT_CAMPAIGN_BY_IDENTIFIER = """
+ select
+ distinct v.campaign_id
+ from
+ view v
+ where
+ v.identifier = ?1""";
View findFirstByIdentifier(String identifier);
List findByIdentifier(String identifier);
-
- @Query(nativeQuery = true, value=FIND_DISTNCT_VIEW_BY_IDENTIFIER)
+
+ @Query(nativeQuery = true, value = FIND_DISTNCT_VIEW_BY_IDENTIFIER)
List findDistinctViewByCampaignId(String campaignId);
+ @Query(nativeQuery = true, value = FIND_DISTNCT_CAMPAIGN_BY_IDENTIFIER)
+ List findDistinctCampaignByIdentifier(String campaignId);
+
List findByIdSu(String idSu);
List findByIdSuContaining(String field);
-
+
Long countViewByIdentifierAndIdSuAndCampaignId(String identifier, String idSu, String campaignId);
List findByIdentifierContainingAndIdSuNotNull(String identifier);
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/view/service/ViewService.java b/src/main/java/fr/insee/survey/datacollectionmanagement/view/service/ViewService.java
index 674e6ad5..91d7989c 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/view/service/ViewService.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/view/service/ViewService.java
@@ -1,11 +1,10 @@
package fr.insee.survey.datacollectionmanagement.view.service;
-import java.util.List;
-
-import org.springframework.stereotype.Service;
-
import fr.insee.survey.datacollectionmanagement.metadata.domain.Campaign;
import fr.insee.survey.datacollectionmanagement.view.domain.View;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
@Service
public interface ViewService {
@@ -18,6 +17,8 @@ public interface ViewService {
List findViewByCampaignId(String campaignId);
+ List findDistinctCampaignByIdentifier(String identifier);
+
List findViewByIdSu(String idSu);
Long countViewByIdentifierIdSuCampaignId(String identifier, String idSu, String campaignId);
diff --git a/src/main/java/fr/insee/survey/datacollectionmanagement/view/serviceImpl/ViewServiceImpl.java b/src/main/java/fr/insee/survey/datacollectionmanagement/view/serviceImpl/ViewServiceImpl.java
index 707e8539..768ff10c 100644
--- a/src/main/java/fr/insee/survey/datacollectionmanagement/view/serviceImpl/ViewServiceImpl.java
+++ b/src/main/java/fr/insee/survey/datacollectionmanagement/view/serviceImpl/ViewServiceImpl.java
@@ -35,6 +35,13 @@ public List findViewByCampaignId(String campaignId) {
return viewRepository.findDistinctViewByCampaignId(campaignId);
}
+ @Override
+ public List findDistinctCampaignByIdentifier(String identifier) {
+ return viewRepository.findDistinctCampaignByIdentifier(identifier);
+ }
+
+
+
@Override
public List findViewByIdSu(String idSu) {
return viewRepository.findByIdSu(idSu);
diff --git a/src/test/java/fr/insee/survey/datacollectionmanagement/questioning/service/dummy/QuestioningAccreditationServiceDummy.java b/src/test/java/fr/insee/survey/datacollectionmanagement/questioning/service/dummy/QuestioningAccreditationServiceDummy.java
index d956296c..f67d5670 100644
--- a/src/test/java/fr/insee/survey/datacollectionmanagement/questioning/service/dummy/QuestioningAccreditationServiceDummy.java
+++ b/src/test/java/fr/insee/survey/datacollectionmanagement/questioning/service/dummy/QuestioningAccreditationServiceDummy.java
@@ -32,8 +32,4 @@ public QuestioningAccreditation saveQuestioningAccreditation(QuestioningAccredit
public void deleteAccreditation(QuestioningAccreditation c) {
}
- @Override
- public List findCampaignsForContactId(String id) {
- return null;
- }
}