3 * Copyright (C) 2009 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.
10 package eu
.etaxonomy
.cdm
.remote
.controller
;
12 import java
.io
.IOException
;
13 import java
.util
.ArrayList
;
14 import java
.util
.Arrays
;
15 import java
.util
.List
;
18 import java
.util
.UUID
;
20 import javax
.servlet
.http
.HttpServletRequest
;
21 import javax
.servlet
.http
.HttpServletResponse
;
23 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
24 import org
.springframework
.stereotype
.Controller
;
25 import org
.springframework
.web
.bind
.WebDataBinder
;
26 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
27 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
28 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
29 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
31 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacade
;
32 import eu
.etaxonomy
.cdm
.api
.facade
.DerivedUnitFacadeNotSupportedException
;
33 import eu
.etaxonomy
.cdm
.api
.service
.IOccurrenceService
;
34 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
35 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableSource
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
37 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
38 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
39 import eu
.etaxonomy
.cdm
.model
.location
.Point
;
40 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
41 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
42 import eu
.etaxonomy
.cdm
.model
.occurrence
.Collection
;
43 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
44 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnitBase
;
45 import eu
.etaxonomy
.cdm
.model
.occurrence
.DeterminationEvent
;
46 import eu
.etaxonomy
.cdm
.model
.occurrence
.FieldObservation
;
47 import eu
.etaxonomy
.cdm
.model
.occurrence
.GatheringEvent
;
48 import eu
.etaxonomy
.cdm
.model
.occurrence
.PreservationMethod
;
49 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
50 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
51 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDPropertyEditor
;
54 * @author a.kohlbecker
59 @RequestMapping(value
= {"/derivedunitfacade/{uuid}"})
60 public class DerivedUnitFacadeController
extends AbstractController
{
63 private IOccurrenceService service
;
66 public void setService(IOccurrenceService service
) {
67 this.service
= service
;
71 public void initBinder(WebDataBinder binder
) {
72 binder
.registerCustomEditor(UUID
.class, new UUIDPropertyEditor());
75 @RequestMapping(method
= RequestMethod
.GET
)
76 public DerivedUnitFacade
doGet(
77 @PathVariable("uuid") UUID uuid
,
78 HttpServletRequest request
,
79 HttpServletResponse response
) throws IOException
{
81 logger
.info("getGet() - " + request
.getServletPath());
82 DerivedUnitFacade duf
= newFacadeFrom(uuid
, response
, null);
87 @RequestMapping(method
= RequestMethod
.GET
, value
= "{uuid}/collectingareas")
88 public Object
doGetCollectingAreas(
89 @PathVariable("uuid") UUID uuid
,
90 HttpServletRequest request
,
91 HttpServletResponse response
) throws IOException
{
93 logger
.info("doGetCollectingAreas() - " + request
.getServletPath());
94 DerivedUnitFacade duf
= newFacadeFrom(uuid
,
96 Arrays
.asList(new String
[]{"ecology"}));
97 return duf
.getCollectingAreas();
100 @RequestMapping(method
= RequestMethod
.GET
, value
= "{uuid}/collection")
101 public Object
doGetCollection(
102 @PathVariable("uuid") UUID uuid
,
103 HttpServletRequest request
,
104 HttpServletResponse response
) throws IOException
{
106 logger
.info("doGetCollection() - " + request
.getServletPath());
107 DerivedUnitFacade duf
= newFacadeFrom(uuid
,
109 Arrays
.asList(new String
[]{"collection"}));
110 return duf
.getCollection();
115 // public Point getExactLocation() => valueProcessor?
118 // public Collection getCollection() {
119 // public AgentBase getCollector() {
120 // public DerivedUnitBase getDerivedUnit() {
121 // public Map<Language, LanguageString> getDerivedUnitDefinitions(){
122 // public List<Media> getDerivedUnitMedia() {
123 // public Set<DeterminationEvent> getDeterminations() {
124 // public Set<Specimen> getDuplicates(){
125 // public Map<Language, LanguageString> getEcologyAll(){
126 // public Map<Language, LanguageString> getFieldObjectDefinition() {
127 // public List<Media> getFieldObjectMedia() {
128 // public FieldObservation getFieldObservation(){
129 // public GatheringEvent getGatheringEvent() {
130 // public String getGatheringEventDescription() {
131 // public Map<Language, LanguageString> getPlantDescriptionAll(){ ==> representation !!
132 // public PreservationMethod getPreservationMethod()
133 // public Set<IdentifiableSource> getSources(){
134 // public TaxonNameBase getStoredUnder() {
137 private DerivedUnitFacade
newFacadeFrom(UUID uuid
, HttpServletResponse response
, List
<String
> extendedInitStrategy
)
139 List
<String
> initStrategy
= new ArrayList
<String
>(DEFAULT_INIT_STRATEGY
);
140 if(extendedInitStrategy
!= null && extendedInitStrategy
.size() > 0){
141 initStrategy
.addAll(extendedInitStrategy
);
143 SpecimenOrObservationBase
<?
> sob
= service
.load(uuid
, null);
144 if(sob
instanceof DerivedUnitBase
<?
>){
146 return service
.getDerivedUnitFacade(((DerivedUnitBase
)sob
), initStrategy
);
147 } catch (DerivedUnitFacadeNotSupportedException e
) {
148 logger
.error(e
); //TODO ...
151 HttpStatusMessage
.UUID_REFERENCES_WRONG_TYPE
.send(response
);