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
.io
.IOException
;
13 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
.beans
.factory
.annotation
.Autowired
;
21 import org
.springframework
.stereotype
.Controller
;
22 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
23 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
24 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
25 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
27 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
28 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
29 import eu
.etaxonomy
.cdm
.api
.service
.util
.TaxonRelationshipEdge
;
30 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
31 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
32 import eu
.etaxonomy
.cdm
.persistence
.query
.OrderHint
;
33 import eu
.etaxonomy
.cdm
.remote
.controller
.util
.PagerParameters
;
36 * TODO write controller documentation
38 * @author a.kohlbecker
42 @RequestMapping(value
= {"/occurrence"})
43 public class OccurrenceListController
extends IdentifiableListController
<SpecimenOrObservationBase
, IOccurrenceService
> {
46 * @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService)
50 public void setService(IOccurrenceService service
) {
51 this.service
= service
;
55 private ITaxonService taxonService
;
57 //listByAnyAssociation
59 value
= {"byAssociatedTaxon"},
60 method
= RequestMethod
.GET
)
61 public List
<SpecimenOrObservationBase
> doListByAssociatedTaxon(
62 @RequestParam(value
= "taxonUuid", required
= true) UUID taxonUuid
,
63 @RequestParam(value
= "maxDepth", required
= false) Integer maxDepth
,
64 @RequestParam(value
= "pageNumber", required
= false) Integer pageNumber
,
65 @RequestParam(value
= "pageSize", required
= false) Integer pageSize
,
66 HttpServletRequest request
,
67 HttpServletResponse response
) throws IOException
{
69 Set
<TaxonRelationshipEdge
> includeRelationships
= null;
70 Taxon associatedTaxon
= (Taxon
) taxonService
.find(taxonUuid
);
71 PagerParameters pagerParams
= new PagerParameters(pageSize
, pageNumber
);
72 pagerParams
.normalizeAndValidate(response
);
74 List
<OrderHint
> orderHints
= null;
75 return service
.listByAssociatedTaxon(null, includeRelationships
, associatedTaxon
, maxDepth
, pagerParams
.getPageSize(), pagerParams
.getPageIndex(), orderHints
, DEFAULT_INIT_STRATEGY
);