Skip to content

Commit

Permalink
Merge pull request #27 from InseeFr/fix_main_contact
Browse files Browse the repository at this point in the history
Fix main contact
  • Loading branch information
EricThuaud authored Sep 29, 2023
2 parents f4114a3 + 431abee commit 41b5253
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<groupId>fr.insee.survey</groupId>
<artifactId>platine-management</artifactId>
<version>1.0.22</version>
<version>1.0.23</version>
<name>platine-management</name>
<description>REST API for communication between DB and Platine-Management UI and Platine-My-Surveys UI</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,25 @@ public class CampaignServiceImpl implements CampaignService {
public Collection<CampaignMoogDto> getCampaigns() {

List<CampaignMoogDto> moogCampaigns = new ArrayList<>();
List<Campaign> campaigns = campaignRepository.findAll();
List<Campaign> campaigns = campaignRepository.findAll().stream().filter(c -> !c.getPartitionings().isEmpty()).toList();

for (Campaign campaign : campaigns) {
CampaignMoogDto campaignMoogDto = new CampaignMoogDto();
campaignMoogDto.setId(campaign.getId());
campaignMoogDto.setLabel(campaign.getCampaignWording());

Optional<Date> dateMin = campaign.getPartitionings().stream().map(Partitioning::getOpeningDate)
.collect(Collectors.toList()).stream()
.min(Comparator.comparing(Date::getTime));
Optional<Date> dateMax = campaign.getPartitionings().stream().map(Partitioning::getClosingDate)
.collect(Collectors.toList()).stream()
.max(Comparator.comparing(Date::getTime));

campaignMoogDto.setCollectionStartDate(dateMin.get().getTime());
campaignMoogDto.setCollectionEndDate(dateMax.get().getTime());

moogCampaigns.add(campaignMoogDto);
if (dateMin.isPresent() && dateMax.isPresent()) {
campaignMoogDto.setCollectionStartDate(dateMin.get().getTime());
campaignMoogDto.setCollectionEndDate(dateMax.get().getTime());
moogCampaigns.add(campaignMoogDto);
} else {
log.warn("No start date or end date found for campaign {}", campaign.getId());
}
}
return moogCampaigns;
}
Expand Down Expand Up @@ -146,7 +147,7 @@ public boolean isCampaignOngoing(String idCampaign) throws NotFoundException {
LOGGER.info("Partitiong {} of campaign {} is closed", part.getId(), idCampaign);
}
}
return camp.get().getPartitionings().size() != 0 && nbOnGoingParts == camp.get().getPartitionings().size();
return !camp.get().getPartitionings().isEmpty() && nbOnGoingParts == camp.get().getPartitionings().size();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,9 @@ private SupportDto convertToDto(Support support) {
}

private ContactDto convertToDto(Contact contact) {
return modelMapper.map(contact, ContactDto.class);
ContactDto contactDto = modelMapper.map(contact, ContactDto.class);
contactDto.setCivility(contact.getGender());
return contactDto;
}

private SurveyUnitDto convertToDto(SurveyUnit surveyUnit) {
Expand Down

0 comments on commit 41b5253

Please sign in to comment.