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
;
14 import javax
.servlet
.http
.HttpServletRequest
;
15 import javax
.servlet
.http
.HttpServletResponse
;
17 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
18 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
19 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
21 import eu
.etaxonomy
.cdm
.api
.service
.IIdentifiableEntityService
;
22 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
23 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
24 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
25 import eu
.etaxonomy
.cdm
.remote
.controller
.util
.PagerParameters
;
32 public abstract class IdentifiableListController
<T
extends IdentifiableEntity
, SERVICE
extends IIdentifiableEntityService
<T
>> extends BaseListController
<T
,SERVICE
> {
36 * Find IdentifiableEntity objects by name
40 * the string to query for. Since the wildcard character '*'
41 * internally always is appended to the query string, a search
42 * always compares the query string with the beginning of a name.
43 * - <i>required parameter</i>
45 * the number of the page to be returned, the first page has the
46 * pageNumber = 1 - <i>optional parameter</i>
48 * the maximum number of entities returned per page (can be -1
49 * to return all entities in a single page) - <i>optional parameter</i>
51 * valid values are "EXACT", "BEGINNING", "ANYWHERE", "END" (case sensitive !!!)
52 * @return a Pager on a list of {@link IdentifiableEntity}s
55 @RequestMapping(method
= RequestMethod
.GET
, value
={"findByTitle"})
56 public Pager
<T
> doFindByTitle(
57 @RequestParam(value
= "query", required
= true) String query
,
58 @RequestParam(value
= "pageNumber", required
= false) Integer pageNumber
,
59 @RequestParam(value
= "pageSize", required
= false) Integer pageSize
,
60 @RequestParam(value
= "matchMode", required
= false) MatchMode matchMode
,
61 HttpServletRequest request
,
62 HttpServletResponse response
68 logger
.info("doFind : " + request
.getRequestURI() + "?" + request
.getQueryString() );
70 PagerParameters pagerParams
= new PagerParameters(pageSize
, pageNumber
);
71 pagerParams
.normalizeAndValidate(response
);
73 matchMode
= matchMode
!= null ? matchMode
: MatchMode
.BEGINNING
;
75 return service
.findByTitle(null, query
, matchMode
, null, pagerParams
.getPageSize(), pagerParams
.getPageIndex(), null, initializationStrategy
);