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
.DerivateDTO
;
31 import eu
.etaxonomy
.cdm
.api
.service
.dto
.PreservedSpecimenDTO
;
32 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
33 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldUnit
;
34 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
35 import io
.swagger
.annotations
.Api
;
38 * TODO write controller documentation
40 * @author a.kohlbecker
44 @Api("portal_occurrence")
45 @RequestMapping(value
= {"/portal/occurrence/{uuid}"})
46 public class OccurrencePortalController
extends OccurrenceController
49 private static final List
<String
> DEFAULT_INIT_STRATEGY
= Arrays
.asList(new String
[]{
54 "derivedFrom.originals.*",
55 "derivedFrom.originals.determinations.taxon",
56 "derivedFrom.originals.gatheringEvent.exactLocation.$",
57 "derivedFrom.gatheringEvent.exactLocation.$",
58 "specimenTypeDesignations.*",
59 "specimenTypeDesignations.citation.*",
60 "specimenTypeDesignations.homotypicalGroup.*",
62 "sequences.annotations",
65 "gatheringEvent.exactLocation.referenceSystem", // TODO implement auto initializer?
66 "gatheringEvent.collectingAreas",
74 public OccurrencePortalController() {
76 setInitializationStrategy(DEFAULT_INIT_STRATEGY
);
80 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
84 public void setService(IOccurrenceService service
) {
85 this.service
= service
;
88 @RequestMapping(value
= { "derivateHierarchy" }, method
= RequestMethod
.GET
)
89 public ModelAndView
doGetDerivateHierarchy(
90 @PathVariable("uuid") UUID uuid
,
91 @RequestParam(value
= "taxonUuid", required
= true) UUID taxonUuid
,
92 HttpServletRequest request
,
93 HttpServletResponse response
) throws IOException
{
95 logger
.info("doGetDerivateHierarchy() " + request
.getRequestURI());
97 ModelAndView mv
= new ModelAndView();
99 SpecimenOrObservationBase sob
= service
.load(uuid
);
100 if(sob
instanceof FieldUnit
){
101 FieldUnit fieldUnit
= (FieldUnit
)sob
;
102 if(fieldUnit
.isPublish()){
103 final DerivateDTO fieldUnitDTO
= service
.assembleFieldUnitDTO(fieldUnit
, taxonUuid
);
104 if(fieldUnitDTO
!=null){
105 mv
.addObject(fieldUnitDTO
);
112 @RequestMapping(value
= { "specimenDerivates" }, method
= RequestMethod
.GET
)
113 public ModelAndView
doGetSpecimenDerivates(
114 @PathVariable("uuid") UUID uuid
,
115 HttpServletRequest request
,
116 HttpServletResponse response
) throws IOException
{
118 logger
.info("doGetSpecimenDerivates() " + request
.getRequestURI());
120 ModelAndView mv
= new ModelAndView();
122 SpecimenOrObservationBase sob
= service
.load(uuid
);
123 if(sob
instanceof DerivedUnit
){
124 DerivedUnit derivedUnit
= (DerivedUnit
) sob
;
125 if(derivedUnit
.isPublish()){
126 PreservedSpecimenDTO specimenDTO
= service
.assemblePreservedSpecimenDTO(derivedUnit
);
127 if(specimenDTO
!=null){
128 mv
.addObject(specimenDTO
);