3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.controller
;
12 import java
.io
.IOException
;
13 import java
.util
.Arrays
;
14 import java
.util
.List
;
15 import java
.util
.UUID
;
17 import javax
.servlet
.http
.HttpServletRequest
;
18 import javax
.servlet
.http
.HttpServletResponse
;
20 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
21 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
22 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
24 import eu
.etaxonomy
.cdm
.api
.service
.IIdentifiableEntityService
;
25 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
26 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
27 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
31 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
32 import eu
.etaxonomy
.cdm
.remote
.controller
.util
.PagerParameters
;
39 public abstract class IdentifiableListController
<T
extends IdentifiableEntity
, SERVICE
extends IIdentifiableEntityService
<T
>> extends BaseListController
<T
,SERVICE
> {
43 * Find IdentifiableEntity objects by name
47 * the string to query for. Since the wildcard character '*'
48 * internally always is appended to the query string, a search
49 * always compares the query string with the beginning of a name.
50 * - <i>required parameter</i>
52 * the number of the page to be returned, the first page has the
53 * pageNumber = 1 - <i>optional parameter</i>
55 * the maximum number of entities returned per page (can be -1
56 * to return all entities in a single page) - <i>optional parameter</i>
58 * valid values are "EXACT", "BEGINNING", "ANYWHERE", "END" (case sensitive !!!)
59 * @return a Pager on a list of {@link IdentifiableEntity}s
62 @RequestMapping(method
= RequestMethod
.GET
, value
={"findByTitle"})
63 public Pager
<T
> doFindByTitle(
64 @RequestParam(value
= "query", required
= true) String query
,
65 @RequestParam(value
= "pageNumber", required
= false) Integer pageNumber
,
66 @RequestParam(value
= "pageSize", required
= false) Integer pageSize
,
67 @RequestParam(value
= "matchMode", required
= false) MatchMode matchMode
,
68 HttpServletRequest request
,
69 HttpServletResponse response
75 logger
.info("doFind : " + request
.getRequestURI() + "?" + request
.getQueryString() );
77 PagerParameters pagerParams
= new PagerParameters(pageSize
, pageNumber
);
78 pagerParams
.normalizeAndValidate(response
);
80 matchMode
= matchMode
!= null ? matchMode
: MatchMode
.BEGINNING
;
82 return (Pager
<T
>) service
.findByTitle(null, query
, matchMode
, null, pagerParams
.getPageSize(), pagerParams
.getPageIndex(), null, initializationStrategy
);