1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
package eu.etaxonomy.cdm.remote.controller;
|
11
|
|
12
|
import io.swagger.annotations.Api;
|
13
|
|
14
|
import java.io.IOException;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import javax.servlet.http.HttpServletRequest;
|
18
|
import javax.servlet.http.HttpServletResponse;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
import org.springframework.beans.factory.annotation.Autowired;
|
22
|
import org.springframework.stereotype.Controller;
|
23
|
import org.springframework.web.bind.annotation.RequestMapping;
|
24
|
import org.springframework.web.bind.annotation.RequestMethod;
|
25
|
import org.springframework.web.bind.annotation.RequestParam;
|
26
|
|
27
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
28
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
29
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
30
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
31
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
32
|
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
|
33
|
|
34
|
/**
|
35
|
* @author a.kohlbecker
|
36
|
* @date 24.03.2011
|
37
|
*
|
38
|
*/
|
39
|
@Controller
|
40
|
@Api("polytomousKey")
|
41
|
@RequestMapping(value = {"/polytomousKey"})
|
42
|
public class PolytomousKeyListController extends IdentifiableListController<PolytomousKey, IPolytomousKeyService> {
|
43
|
|
44
|
public static final Logger logger = Logger.getLogger(PolytomousKeyListController.class);
|
45
|
|
46
|
private ITaxonService taxonService;
|
47
|
|
48
|
@Override
|
49
|
@Autowired
|
50
|
public void setService(IPolytomousKeyService service) {
|
51
|
this.service = service;
|
52
|
}
|
53
|
|
54
|
@Autowired
|
55
|
public void setService(ITaxonService taxonService) {
|
56
|
this.taxonService = taxonService;
|
57
|
}
|
58
|
|
59
|
@RequestMapping(
|
60
|
params = {"findByTaxonomicScope"},
|
61
|
method = RequestMethod.GET)
|
62
|
public Pager<PolytomousKey> doFindByTaxonomicScope(
|
63
|
@RequestParam(value = "findByTaxonomicScope") UUID taxonUuid,
|
64
|
@RequestParam(value = "pageNumber", required = false) Integer pageNumber,
|
65
|
@RequestParam(value = "pageSize", required = false) Integer pageSize,
|
66
|
HttpServletRequest request,
|
67
|
HttpServletResponse response)throws IOException {
|
68
|
|
69
|
logger.info("doFindByTaxonomicScope: " + request.getRequestURI() + request.getQueryString());
|
70
|
|
71
|
PagerParameters pagerParameters = new PagerParameters(pageSize, pageNumber);
|
72
|
pagerParameters.normalizeAndValidate(response);
|
73
|
|
74
|
|
75
|
TaxonBase taxon = taxonService.find(taxonUuid);
|
76
|
Pager<PolytomousKey> pager = service.findByTaxonomicScope(taxon, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null, null);
|
77
|
return pager;
|
78
|
}
|
79
|
|
80
|
}
|
81
|
|