Project

General

Profile

Download (2.8 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.remote.controller;
10

    
11
import io.swagger.annotations.Api;
12

    
13
import java.io.IOException;
14
import java.util.UUID;
15

    
16
import javax.servlet.http.HttpServletRequest;
17
import javax.servlet.http.HttpServletResponse;
18

    
19
import org.apache.log4j.Logger;
20
import org.springframework.beans.factory.annotation.Autowired;
21
import org.springframework.stereotype.Controller;
22
import org.springframework.web.bind.annotation.RequestMapping;
23
import org.springframework.web.bind.annotation.RequestMethod;
24
import org.springframework.web.bind.annotation.RequestParam;
25

    
26
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
27
import eu.etaxonomy.cdm.api.service.ITaxonService;
28
import eu.etaxonomy.cdm.api.service.pager.Pager;
29
import eu.etaxonomy.cdm.model.description.PolytomousKey;
30
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
31
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
32

    
33
/**
34
 * @author a.kohlbecker
35
 * @since 24.03.2011
36
 *
37
 */
38
@Controller
39
@Api("polytomousKey")
40
@RequestMapping(value = {"/polytomousKey"})
41
public class PolytomousKeyListController extends AbstractIdentifiableListController<PolytomousKey, IPolytomousKeyService> {
42

    
43
    public static final Logger logger = Logger.getLogger(PolytomousKeyListController.class);
44

    
45
    private ITaxonService taxonService;
46

    
47
    @Override
48
    @Autowired
49
    public void setService(IPolytomousKeyService service) {
50
        this.service = service;
51
    }
52

    
53
    @Autowired
54
    public void setService(ITaxonService taxonService) {
55
        this.taxonService = taxonService;
56
    }
57

    
58
    @RequestMapping(
59
            params = {"findByTaxonomicScope"},
60
            method = RequestMethod.GET)
61
    public Pager<PolytomousKey> doFindByTaxonomicScope(
62
            @RequestParam(value = "findByTaxonomicScope") UUID taxonUuid,
63
            @RequestParam(value = "pageNumber", required = false) Integer pageNumber,
64
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
65
            HttpServletRequest request,
66
            HttpServletResponse response)throws IOException {
67

    
68
        logger.info("doFindByTaxonomicScope: " + request.getRequestURI() + request.getQueryString());
69

    
70
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageNumber);
71
        pagerParameters.normalizeAndValidate(response);
72

    
73

    
74
        TaxonBase taxon = taxonService.find(taxonUuid);
75
        Pager<PolytomousKey> pager = service.findByTaxonomicScope(taxon, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null, null);
76
        return pager;
77
    }
78

    
79
}
80

    
(45-45/75)