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
.ArrayList
;
15 import java
.util
.Arrays
;
16 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import javax
.servlet
.http
.HttpServletRequest
;
20 import javax
.servlet
.http
.HttpServletResponse
;
22 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
23 import org
.springframework
.stereotype
.Controller
;
24 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
25 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
26 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
27 import org
.springframework
.web
.servlet
.ModelAndView
;
29 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
30 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
31 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
32 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
33 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
34 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
37 * TODO write controller documentation
39 * @author a.kohlbecker
44 @RequestMapping(value
= {"/name/{uuid}"})
45 public class NameController
extends BaseController
<TaxonNameBase
, INameService
>
48 private static final List
<String
> TYPEDESIGNATION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
49 "typeStatus.representations",
54 "citation.authorTeam.$",
57 private static final List
<String
> NAME_CACHE_INIT_STRATEGY
= Arrays
.asList(new String
[]{
61 public NameController(){
63 setInitializationStrategy(Arrays
.asList(new String
[]{"$"})); //TODO still needed????
67 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
71 public void setService(INameService service
) {
72 this.service
= service
;
77 * Get the list of {@link TypeDesignationBase}s of the
78 * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.
80 * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>
84 * @return a List of {@link TypeDesignationBase} entities which are initialized
85 * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}
87 *///TODO obsolete method?
88 @RequestMapping(value
= { "typeDesignations" }, method
= RequestMethod
.GET
)
89 public List
<TypeDesignationBase
> doGetNameTypeDesignations(
90 @PathVariable("uuid") UUID uuid
, HttpServletRequest request
,
91 HttpServletResponse response
) throws IOException
{
93 logger
.info("doGetTypeDesignations()" + request
.getServletPath());
94 TaxonNameBase tnb
= getCdmBaseInstance(uuid
, response
,
96 Pager
<TypeDesignationBase
> p
= service
.getTypeDesignations(tnb
, null,
97 null, null, TYPEDESIGNATION_INIT_STRATEGY
);
98 return p
.getRecords();
103 value
= {"nameCache"},
104 method
= RequestMethod
.GET
)
105 public List
<String
> doGetNameCache(@PathVariable("uuid") UUID uuid
,
106 HttpServletRequest request
, HttpServletResponse response
)throws IOException
{
108 logger
.info("doGetNameCache()" + request
.getServletPath());
109 TaxonNameBase tnb
= getCdmBaseInstance(uuid
, response
, NAME_CACHE_INIT_STRATEGY
);
110 NonViralName nvn
= (NonViralName
) tnb
;
111 String nameCacheString
= nvn
.getNameCache();
112 List result
= new ArrayList
<String
>();
113 result
.add(nameCacheString
);
118 @RequestMapping(value
= "taggedName", method
= RequestMethod
.GET
)
119 public ModelAndView
doGetTaggedName(
120 @PathVariable("uuid") UUID uuid
,
121 HttpServletRequest request
,
122 HttpServletResponse response
) throws IOException
{
123 logger
.info("doGetDescriptionElementsByType() - " + request
.getServletPath());
125 ModelAndView mv
= new ModelAndView();
126 mv
.addObject(service
.getTaggedName(uuid
));