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
.servlet
.ModelAndView
;
28 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
29 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
30 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
31 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
34 * TODO write controller documentation
36 * @author a.kohlbecker
40 @RequestMapping(value
= {"/portal/occurrence/{uuid}"})
41 public class OccurrencePortalController
extends BaseController
<SpecimenOrObservationBase
, IOccurrenceService
>
44 private static final List
<String
> DEFAULT_INIT_STRATEGY
= Arrays
.asList(new String
[]{
49 "derivedFrom.originals.*",
50 "derivedFrom.originals.determinations.taxon",
51 "derivedFrom.gatheringEvent.exactLocation.$",
52 "specimenTypeDesignations.*",
53 "specimenTypeDesignations.citation.*",
54 "specimenTypeDesignations.homotypicalGroup.*"
61 public OccurrencePortalController() {
63 setInitializationStrategy(DEFAULT_INIT_STRATEGY
);
67 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
71 public void setService(IOccurrenceService service
) {
72 this.service
= service
;
75 @RequestMapping(value
= { "derivedFrom" }, method
= RequestMethod
.GET
)
76 public ModelAndView
doGetDerivedFrom(
77 @PathVariable("uuid") UUID uuid
,
78 HttpServletRequest request
,
79 HttpServletResponse response
) throws IOException
{
81 logger
.info("doGetDerivedFrom() " + request
.getRequestURI());
83 ModelAndView mv
= new ModelAndView();
85 List
<String
> initStrategy
= DEFAULT_INIT_STRATEGY
;
87 SpecimenOrObservationBase sob
= getCdmBaseInstance(uuid
, response
, initStrategy
);
88 if(sob
instanceof DerivedUnitBase
){
89 DerivationEvent derivationEvent
= ((DerivedUnitBase
)sob
).getDerivedFrom();
90 mv
.addObject(derivationEvent
);