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
53
54
55
56
57
package com.megatim.fdxconsultation.service.impl.searchs;
 
import com.megatim.fdxconsultation.model.mappers.MapStructMapper;
import com.megatim.fdxconsultation.core.ifaces.stats.TableauBordUserSpecificSearchManager;
import com.megatim.fdxconsultation.core.impl.stats.ConvertedTableauBordResponse;
import com.megatim.fdxconsultation.model.searchentities.TableauBordSpecificSearch;
import com.megatim.fdxconsultation.model.stats.dto.TableauBordFlatResponse;
import com.megatim.fdxconsultation.service.ifaces.searchs.TableauBordSearchRS;
import com.mgt.rs.security.core.common.AuthenticatedUser;
import com.mgt.rs.security.core.common.SecuredClass;
import java.util.List;
import java.util.stream.Collectors;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.ws.rs.Path;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.Response;
 
/**
 *
 * @author Gabuntu
 */
@SecuredClass(module = "", path = "", description = "")
@Path("tableau-bord-search")
public class TableauBordSearchRSImpl implements TableauBordSearchRS {
 
    @Inject
    private TableauBordUserSpecificSearchManager manager;
 
    private String username;
 
    public void handleAuthenticationEvent(@Observes @AuthenticatedUser String username) {
        this.username = username;
    }
 
    @Override
    public Response formData(HttpHeaders headers) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
 
    @Override
    public Response formDataWithPagination(HttpHeaders headers, Integer pageNumber, Integer pagesize, TableauBordSpecificSearch searchEntity) {
        searchEntity.setUserName(username);
        List<TableauBordFlatResponse> response
                = manager.findWithPagination(pageNumber, pagesize, searchEntity)
                        .stream()
                        .map(tableauBord -> new ConvertedTableauBordResponse(tableauBord).tableauBordFlatResponse())
                        .collect(Collectors.toList());
        return Response.ok(response).build();
    }
 
    @Override
    public Long countFormData(HttpHeaders headers, TableauBordSpecificSearch searchEntity) {
        searchEntity.setUserName(username);
        return manager.count(searchEntity);
    }
}