1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT 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
|
7
|
* 1.1 See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.remote.controller;
|
11
|
|
12
|
import java.io.IOException;
|
13
|
|
14
|
import javax.servlet.http.HttpServletRequest;
|
15
|
import javax.servlet.http.HttpServletResponse;
|
16
|
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
import org.springframework.stereotype.Controller;
|
19
|
import org.springframework.web.bind.annotation.RequestMapping;
|
20
|
import org.springframework.web.bind.annotation.RequestMethod;
|
21
|
import org.springframework.web.bind.annotation.RequestParam;
|
22
|
|
23
|
import eu.etaxonomy.cdm.api.service.INameService;
|
24
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
25
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
26
|
import eu.etaxonomy.cdm.persistence.query.MatchMode;
|
27
|
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
|
28
|
|
29
|
/**
|
30
|
* TODO write controller documentation
|
31
|
*
|
32
|
* @author a.kohlbecker
|
33
|
* @date 24.03.2009
|
34
|
*/
|
35
|
@Controller
|
36
|
@RequestMapping(value = {"/name"})
|
37
|
public class NameListController extends IdentifiableListController<TaxonNameBase, INameService> {
|
38
|
|
39
|
/* (non-Javadoc)
|
40
|
* @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService)
|
41
|
*/
|
42
|
@Override
|
43
|
@Autowired
|
44
|
public void setService(INameService service) {
|
45
|
this.service = service;
|
46
|
}
|
47
|
|
48
|
@RequestMapping(method = RequestMethod.GET, value={"findTitleCache"})
|
49
|
public Pager<TaxonNameBase> doFindTitleCache(
|
50
|
@RequestParam(value = "query", required = true) String query,
|
51
|
@RequestParam(value = "pageNumber", required = false) Integer pageNumber,
|
52
|
@RequestParam(value = "pageSize", required = false) Integer pageSize,
|
53
|
@RequestParam(value = "matchMode", required = false) MatchMode matchMode,
|
54
|
HttpServletRequest request,
|
55
|
HttpServletResponse response
|
56
|
)
|
57
|
throws IOException {
|
58
|
|
59
|
logger.info("doFind : " + request.getRequestURI() + "?" + request.getQueryString() );
|
60
|
|
61
|
PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);
|
62
|
pagerParams.normalizeAndValidate(response);
|
63
|
|
64
|
return service.findTitleCache(null, query, pagerParams.getPageSize(), pagerParams.getPageIndex(), null, matchMode);
|
65
|
|
66
|
}
|
67
|
|
68
|
@RequestMapping(value = "findByName", method = RequestMethod.GET)
|
69
|
public Pager<TaxonNameBase> doFindByName(
|
70
|
@RequestParam(value = "query", required = true) String query,
|
71
|
@RequestParam(value = "pageNumber", required = false) Integer pageNumber,
|
72
|
@RequestParam(value = "pageSize", required = false) Integer pageSize,
|
73
|
@RequestParam(value = "matchMode", required = false) MatchMode matchMode, HttpServletRequest request, HttpServletResponse response)
|
74
|
throws IOException {
|
75
|
|
76
|
PagerParameters pagerParameters = new PagerParameters(pageSize, pageNumber);
|
77
|
pagerParameters.normalizeAndValidate(response);
|
78
|
|
79
|
return service.findByTitle(TaxonNameBase.class, query, matchMode, null, pageSize, pageNumber, null, getInitializationStrategy());
|
80
|
}
|
81
|
|
82
|
}
|