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
.dto
.DerivateHierarchyDTO
;
31 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivationEvent
;
32 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
34 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
37 * TODO write controller documentation
39 * @author a.kohlbecker
43 @RequestMapping(value
= {"/portal/occurrence/{uuid}"})
44 public class OccurrencePortalController
extends BaseController
<SpecimenOrObservationBase
, IOccurrenceService
>
47 private static final List
<String
> DEFAULT_INIT_STRATEGY
= Arrays
.asList(new String
[]{
52 "derivedFrom.originals.*",
53 "derivedFrom.originals.determinations.taxon",
54 "derivedFrom.gatheringEvent.exactLocation.$",
55 "specimenTypeDesignations.*",
56 "specimenTypeDesignations.citation.*",
57 "specimenTypeDesignations.homotypicalGroup.*",
59 "sequences.annotations",
69 public OccurrencePortalController() {
71 setInitializationStrategy(DEFAULT_INIT_STRATEGY
);
75 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
79 public void setService(IOccurrenceService service
) {
80 this.service
= service
;
83 @RequestMapping(value
= { "derivedFrom" }, method
= RequestMethod
.GET
)
84 public ModelAndView
doGetDerivedFrom(
85 @PathVariable("uuid") UUID uuid
,
86 HttpServletRequest request
,
87 HttpServletResponse response
) throws IOException
{
89 logger
.info("doGetDerivedFrom() " + request
.getRequestURI());
91 ModelAndView mv
= new ModelAndView();
93 List
<String
> initStrategy
= DEFAULT_INIT_STRATEGY
;
95 SpecimenOrObservationBase sob
= getCdmBaseInstance(uuid
, response
, initStrategy
);
96 if(sob
instanceof DerivedUnit
){
97 DerivationEvent derivationEvent
= ((DerivedUnit
)sob
).getDerivedFrom();
98 mv
.addObject(derivationEvent
);
103 @RequestMapping(value
= { "derivateHierarchy" }, method
= RequestMethod
.GET
)
104 public ModelAndView
doGetDerivateHierarchy(
105 @PathVariable("uuid") UUID uuid
,
106 @RequestParam(value
= "taxonUuid", required
= true) UUID taxonUuid
,
107 HttpServletRequest request
,
108 HttpServletResponse response
) throws IOException
{
110 logger
.info("doGetDerivateHierarchy() " + request
.getRequestURI());
112 ModelAndView mv
= new ModelAndView();
114 List
<String
> initStrategy
= DEFAULT_INIT_STRATEGY
;
116 SpecimenOrObservationBase sob
= service
.load(uuid
);
117 if(sob
instanceof FieldUnit
){
118 final DerivateHierarchyDTO assembleDerivateHierarchyDTO
= service
.assembleDerivateHierarchyDTO((FieldUnit
)sob
, taxonUuid
);
119 if(assembleDerivateHierarchyDTO
!=null){
120 mv
.addObject(assembleDerivateHierarchyDTO
);