Project

General

Profile

Download (2.79 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 java.io.IOException;
12
import java.util.UUID;
13

    
14
import javax.servlet.http.HttpServletRequest;
15
import javax.servlet.http.HttpServletResponse;
16

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

    
24
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
25
import eu.etaxonomy.cdm.api.service.ITaxonService;
26
import eu.etaxonomy.cdm.api.service.pager.Pager;
27
import eu.etaxonomy.cdm.model.description.PolytomousKey;
28
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
29
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
30
import io.swagger.annotations.Api;
31

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

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

    
44
    private ITaxonService taxonService;
45

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

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

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

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

    
69
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageIndex);
70
        pagerParameters.normalizeAndValidate(response);
71

    
72

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

    
78
}
79

    
(45-45/76)