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
;
36 * TODO write controller documentation
38 * @author a.kohlbecker
43 @RequestMapping(value
= {"/name/{uuid}"})
44 public class NameController
extends BaseController
<TaxonNameBase
, INameService
>
47 private static final List
<String
> TYPEDESIGNATION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
48 "typeStatus.representations",
53 "citation.authorTeam.$",
56 private static final List
<String
> NAME_CACHE_INIT_STRATEGY
= Arrays
.asList(new String
[]{
60 public NameController(){
62 setInitializationStrategy(Arrays
.asList(new String
[]{"$"})); //TODO still needed????
66 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
70 public void setService(INameService service
) {
71 this.service
= service
;
76 * Get the list of {@link TypeDesignationBase}s of the
77 * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.
79 * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>
83 * @return a List of {@link TypeDesignationBase} entities which are initialized
84 * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}
87 * TODO obsolete method?
89 @RequestMapping(value
= { "typeDesignations" }, method
= RequestMethod
.GET
)
90 public List
<TypeDesignationBase
> doGetNameTypeDesignations(
91 @PathVariable("uuid") UUID uuid
, HttpServletRequest request
,
92 HttpServletResponse response
) throws IOException
{
94 logger
.info("doGetTypeDesignations()" + request
.getServletPath());
95 TaxonNameBase tnb
= getCdmBaseInstance(uuid
, response
,
97 Pager
<TypeDesignationBase
> p
= service
.getTypeDesignations(tnb
, null,
98 null, null, TYPEDESIGNATION_INIT_STRATEGY
);
99 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
));