3 * Copyright (C) 2007 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.
11 package eu
.etaxonomy
.cdm
.remote
.controller
;
13 import java
.io
.IOException
;
14 import java
.util
.Arrays
;
15 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import javax
.servlet
.http
.HttpServletRequest
;
19 import javax
.servlet
.http
.HttpServletResponse
;
21 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
22 import org
.springframework
.stereotype
.Controller
;
23 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
24 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
25 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
26 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
27 import org
.springframework
.web
.servlet
.ModelAndView
;
29 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
30 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
31 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
32 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
34 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
35 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
38 * TODO write controller documentation
40 * @author a.kohlbecker
44 @RequestMapping(value
= {"/occurrence/{uuid}"})
45 public class OccurrenceController
extends BaseController
<SpecimenOrObservationBase
, IOccurrenceService
>
48 private static final List
<String
> DERIVED_UNIT_INIT_STRATEGY
= Arrays
.asList(new String
[]{
49 "derivedFrom.derivatives",
50 "derivedFrom.originals",
54 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
58 public void setService(IOccurrenceService service
) {
59 this.service
= service
;
62 @RequestMapping(value
= { "derivedFrom" }, method
= RequestMethod
.GET
)
63 public ModelAndView
doGetDerivedFrom(
64 @PathVariable("uuid") UUID uuid
, HttpServletRequest request
,
65 HttpServletResponse response
) throws IOException
{
67 logger
.info("doGetDerivedFrom()" + request
.getServletPath());
69 ModelAndView mv
= new ModelAndView();
70 SpecimenOrObservationBase sob
= getCdmBaseInstance(uuid
, response
, DERIVED_UNIT_INIT_STRATEGY
);
71 if(sob
instanceof DerivedUnitBase
){
72 DerivationEvent derivationEvent
= ((DerivedUnitBase
)sob
).getDerivedFrom();
73 mv
.addObject(derivationEvent
);