1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.remote.controller;
|
12
|
|
13
|
import java.io.IOException;
|
14
|
import java.util.Arrays;
|
15
|
import java.util.List;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import javax.servlet.http.HttpServletRequest;
|
19
|
import javax.servlet.http.HttpServletResponse;
|
20
|
|
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;
|
27
|
|
28
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
29
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
|
30
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
31
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
32
|
|
33
|
/**
|
34
|
* TODO write controller documentation
|
35
|
*
|
36
|
* @author a.kohlbecker
|
37
|
* @date 24.03.2009
|
38
|
*/
|
39
|
@Controller
|
40
|
@RequestMapping(value = {"/portal/occurrence/{uuid}"})
|
41
|
public class OccurrencePortalController extends BaseController<SpecimenOrObservationBase, IOccurrenceService>
|
42
|
{
|
43
|
|
44
|
private static final List<String> DEFAULT_INIT_STRATEGY = Arrays.asList(new String []{
|
45
|
"$",
|
46
|
"determinations.*",
|
47
|
"sources.$",
|
48
|
"derivedFrom.type",
|
49
|
"derivedFrom.originals.*",
|
50
|
"derivedFrom.originals.determinations.taxon",
|
51
|
"derivedFrom.gatheringEvent.exactLocation.$",
|
52
|
"specimenTypeDesignations.*",
|
53
|
"specimenTypeDesignations.citation.*",
|
54
|
"specimenTypeDesignations.homotypicalGroup.*",
|
55
|
"sequences.$",
|
56
|
"sequences.annotations",
|
57
|
"markers.markerType",
|
58
|
"gatheringEvent.$"
|
59
|
});
|
60
|
|
61
|
|
62
|
/**
|
63
|
*
|
64
|
*/
|
65
|
public OccurrencePortalController() {
|
66
|
super();
|
67
|
setInitializationStrategy(DEFAULT_INIT_STRATEGY);
|
68
|
}
|
69
|
|
70
|
/* (non-Javadoc)
|
71
|
* @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
|
72
|
*/
|
73
|
@Autowired
|
74
|
@Override
|
75
|
public void setService(IOccurrenceService service) {
|
76
|
this.service = service;
|
77
|
}
|
78
|
|
79
|
@RequestMapping(value = { "derivedFrom" }, method = RequestMethod.GET)
|
80
|
public ModelAndView doGetDerivedFrom(
|
81
|
@PathVariable("uuid") UUID uuid,
|
82
|
HttpServletRequest request,
|
83
|
HttpServletResponse response) throws IOException {
|
84
|
|
85
|
logger.info("doGetDerivedFrom() " + request.getRequestURI());
|
86
|
|
87
|
ModelAndView mv = new ModelAndView();
|
88
|
|
89
|
List<String> initStrategy = DEFAULT_INIT_STRATEGY;
|
90
|
|
91
|
SpecimenOrObservationBase sob = getCdmBaseInstance(uuid, response, initStrategy);
|
92
|
if(sob instanceof DerivedUnit){
|
93
|
DerivationEvent derivationEvent = ((DerivedUnit)sob).getDerivedFrom();
|
94
|
mv.addObject(derivationEvent);
|
95
|
}
|
96
|
return mv;
|
97
|
}
|
98
|
|
99
|
|
100
|
|
101
|
}
|