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
.WebDataBinder
;
24 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
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
.bind
.annotation
.RequestParam
;
29 import org
.springframework
.web
.servlet
.ModelAndView
;
31 import eu
.etaxonomy
.cdm
.api
.service
.IReferenceService
;
32 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
33 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
34 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDPropertyEditor
;
37 * TODO write controller documentation
39 * @author a.kohlbecker
44 @RequestMapping(value
= {"/reference/{uuid}"})
45 public class ReferenceController
extends BaseController
<Reference
, IReferenceService
>
48 private static final List
<String
> NOMENCLATURAL_CITATION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
50 "authorTeam", // TODO obsolete??
51 "inReference.authorTeam"
54 private static final List
<String
> CITATION_WITH_AUTHORTEAM_INIT_STRATEGY
= Arrays
.asList(new String
[]{
55 "authorTeam.$" // TODO obsolete??
58 public ReferenceController(){
59 setInitializationStrategy(Arrays
.asList(new String
[]{
61 "authorTeam.$" // TODO obsolete??
66 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
70 public void setService(IReferenceService service
) {
71 this.service
= service
;
75 * TODO write controller documentation
83 value
= {"nomenclaturalCitation"},
84 method
= RequestMethod
.GET
)
85 public ModelAndView
doGetNomenclaturalCitation(
86 @PathVariable("uuid") UUID uuid
,
87 HttpServletRequest request
,
88 HttpServletResponse response
,
89 @RequestParam(value
= "microReference", required
= false) String microReference
)throws IOException
{
90 ModelAndView mv
= new ModelAndView();
91 Reference rb
= service
.load(uuid
, NOMENCLATURAL_CITATION_INIT_STRATEGY
);
92 if(INomenclaturalReference
.class.isAssignableFrom(rb
.getClass())){
93 String nomRefCit
= ((INomenclaturalReference
)rb
).getNomenclaturalCitation(microReference
);
94 mv
.addObject(nomRefCit
);
97 response
.sendError(400, "The supplied reference-uuid must specify a INomenclaturalReference.");
103 value
= {"authorTeam"},
104 method
= RequestMethod
.GET
)
105 public ModelAndView
doGetAuthorTeam(
106 @PathVariable("uuid") UUID uuid
,
107 HttpServletRequest request
,
108 HttpServletResponse response
) {
109 ModelAndView mv
= new ModelAndView();
110 Reference rb
= service
.load(uuid
, CITATION_WITH_AUTHORTEAM_INIT_STRATEGY
);
111 if(rb
.getAuthorTeam() != null){
112 mv
.addObject(rb
.getAuthorTeam());