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 io.swagger.annotations.Api;
|
14
|
|
15
|
import java.io.IOException;
|
16
|
import java.util.Arrays;
|
17
|
import java.util.List;
|
18
|
import java.util.UUID;
|
19
|
|
20
|
import javax.servlet.http.HttpServletRequest;
|
21
|
import javax.servlet.http.HttpServletResponse;
|
22
|
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
24
|
import org.springframework.stereotype.Controller;
|
25
|
import org.springframework.web.bind.annotation.PathVariable;
|
26
|
import org.springframework.web.bind.annotation.RequestMapping;
|
27
|
import org.springframework.web.bind.annotation.RequestMethod;
|
28
|
import org.springframework.web.servlet.ModelAndView;
|
29
|
|
30
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
31
|
import eu.etaxonomy.cdm.model.occurrence.DerivationEvent;
|
32
|
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
|
33
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
34
|
|
35
|
/**
|
36
|
* TODO write controller documentation
|
37
|
*
|
38
|
* @author a.kohlbecker
|
39
|
* @date 24.03.2009
|
40
|
*/
|
41
|
@Controller
|
42
|
@Api("occurrence")
|
43
|
@RequestMapping(value = {"/occurrence/{uuid}"})
|
44
|
public class OccurrenceController extends BaseController<SpecimenOrObservationBase, IOccurrenceService>
|
45
|
{
|
46
|
|
47
|
protected static final List<String> DEFAULT_INIT_STRATEGY = Arrays.asList(new String []{
|
48
|
"$",
|
49
|
"sequences.$",
|
50
|
});
|
51
|
|
52
|
private static final List<String> DERIVED_UNIT_INIT_STRATEGY = Arrays.asList(new String []{
|
53
|
"derivedFrom.derivatives",
|
54
|
"derivedFrom.originals",
|
55
|
});
|
56
|
|
57
|
|
58
|
|
59
|
/* (non-Javadoc)
|
60
|
* @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
|
61
|
*/
|
62
|
@Autowired
|
63
|
@Override
|
64
|
public void setService(IOccurrenceService service) {
|
65
|
this.service = service;
|
66
|
}
|
67
|
|
68
|
@RequestMapping(value = { "derivedFrom" }, method = RequestMethod.GET)
|
69
|
public ModelAndView doGetDerivedFrom(
|
70
|
@PathVariable("uuid") UUID uuid, HttpServletRequest request,
|
71
|
HttpServletResponse response) throws IOException {
|
72
|
|
73
|
logger.info("doGetDerivedFrom()" + request.getRequestURI());
|
74
|
|
75
|
ModelAndView mv = new ModelAndView();
|
76
|
SpecimenOrObservationBase sob = getCdmBaseInstance(uuid, response, DERIVED_UNIT_INIT_STRATEGY);
|
77
|
if(sob instanceof DerivedUnit){
|
78
|
DerivationEvent derivationEvent = ((DerivedUnit)sob).getDerivedFrom();
|
79
|
if (derivationEvent != null) {
|
80
|
mv.addObject(derivationEvent);
|
81
|
}
|
82
|
}
|
83
|
return mv;
|
84
|
}
|
85
|
|
86
|
}
|