Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.megatim.fdxconsultation.service.impl.searchs;
 
import com.megatim.fdxcommons.model.dtos.referentiel.ParticipantSlimDto;
import com.megatim.fdxconsultation.model.mappers.MapStructMapper;
import com.megatim.fdxconsultation.core.ifaces.referentiel.ParticipantManager;
import com.megatim.fdxconsultation.model.searchentities.ParticipantSearch;
import com.megatim.fdxconsultation.service.ifaces.searchs.ParticipantSearchRS;
import java.util.List;
import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.ws.rs.Path;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
 
/**
 *
 * @author Gabuntu
 */
@Path("participant-search")
public class ParticipantSearchRSImpl implements ParticipantSearchRS {
 
    @Inject
    private ParticipantManager manager;
 
    @Inject
    private MapStructMapper mapper;
 
    @Override
    public Response formData(HttpHeaders headers) {
        List<ParticipantSlimDto> dtos = manager
                .findAll(null)
                .stream()
                .map(p -> mapper.partcipantToPartcipantSlimDto(p))
                .collect(Collectors.toList());
        return Response.ok(dtos).build();
    }
 
    @Override
    public Response formDataWithPagination(HttpHeaders headers, Integer pageNumber, Integer pagesize, ParticipantSearch searchEntity) {
        List<ParticipantSlimDto> dtos = manager
                .findWithPagination(pageNumber, pagesize, searchEntity)
                .stream()
                .map(p -> mapper.partcipantToPartcipantSlimDto(p))
                .collect(Collectors.toList());
        return Response.ok(dtos).build();
    }
 
    @Override
    public Long countFormData(HttpHeaders headers, ParticipantSearch searchEntity) {
        return manager.count(searchEntity);
    }
}