1 // $Id: TaxonListController.java 5584 2009-04-09 10:04:18Z a.kohlbecker $
3 * Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.controller
;
12 import java
.util
.UUID
;
14 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
15 import org
.springframework
.stereotype
.Controller
;
16 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
17 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
18 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
20 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
22 import eu
.etaxonomy
.cdm
.api
.service
.config
.ITaxonServiceConfigurator
;
23 import eu
.etaxonomy
.cdm
.api
.service
.config
.impl
.TaxonServiceConfiguratorImpl
;
24 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
25 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
26 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
28 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonomicTree
;
29 import eu
.etaxonomy
.cdm
.persistence
.query
.MatchMode
;
32 * @author a.kohlbecker
36 @RequestMapping(value
= {"/*/portal/taxon/"})
37 public class TaxonPortalListController
extends BaseListController
<TaxonBase
, ITaxonService
> {
40 private IReferenceService referenceService
;
43 * @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService)
47 public void setService(ITaxonService service
) {
48 this.service
= service
;
51 public Pager
<TaxonBase
> doGet() {
55 @RequestMapping(method
= RequestMethod
.GET
)
56 public Pager
<IdentifiableEntity
> doFind( //FIXME duplicate method see TaxonPortalController.doFind()
57 @RequestParam(value
= "page", required
= false) Integer page
,
58 @RequestParam(value
= "pageSize", required
= false) Integer pageSize
,
59 @RequestParam(value
= "q", required
= false) String query
,
60 @RequestParam(value
= "doTaxa", required
= false) Boolean doTaxa
,
61 @RequestParam(value
= "doSynonyms", required
= false) Boolean doSynonyms
,
62 @RequestParam(value
= "doNamesWithoutTaxa", required
= false) Boolean doNamesWithoutTaxa
,
63 @RequestParam(value
= "treeUuid", required
= false) UUID treeUuid
) {
65 if(page
== null){ page
= DEFAULT_PAGE
;}
66 if(pageSize
== null){ pageSize
= DEFAULT_PAGESIZE
;}
68 ITaxonServiceConfigurator config
= new TaxonServiceConfiguratorImpl();
69 config
.setPageNumber(page
);
70 config
.setPageSize(pageSize
);
71 config
.setSearchString(query
);
72 config
.setDoTaxa(doTaxa
);
73 config
.setDoSynonyms(doSynonyms
);
74 config
.setDoNamesWithoutTaxa(doNamesWithoutTaxa
);
75 config
.setMatchMode(MatchMode
.BEGINNING
);
77 TaxonomicTree taxonomicTree
= service
.getTaxonomicTreeByUuid(treeUuid
);
78 config
.setTaxonomicTree(taxonomicTree
);
81 return (Pager
<IdentifiableEntity
>) service
.findTaxaAndNames(config
);