2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * 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
;
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
.annotation
.PathVariable
;
24 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
25 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
26 import org
.springframework
.web
.servlet
.ModelAndView
;
28 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
29 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
30 import eu
.etaxonomy
.cdm
.model
.name
.TaxonName
;
31 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
32 import io
.swagger
.annotations
.Api
;
35 * TODO write controller documentation
37 * @author a.kohlbecker
43 @RequestMapping(value
= {"/name/{uuid}"})
44 public class NameController
extends AbstractIdentifiableController
<TaxonName
, INameService
>{
46 private static final List
<String
> TYPEDESIGNATION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
47 "typeStatus.representations",
52 "citation.authorship.$",
55 private static final List
<String
> NAME_CACHE_INIT_STRATEGY
= Arrays
.asList(new String
[]{
59 public NameController(){
61 setInitializationStrategy(Arrays
.asList(new String
[]{"$"})); //TODO still needed????
66 public void setService(INameService service
) {
67 this.service
= service
;
72 * Get the list of {@link TypeDesignationBase}s of the
73 * {@link TaxonName} instance identified by the <code>{name-uuid}</code>.
75 * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>
79 * @return a List of {@link TypeDesignationBase} entities which are initialized
80 * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}
83 * TODO obsolete method?
85 @RequestMapping(value
= { "typeDesignations" }, method
= RequestMethod
.GET
)
86 public List
<TypeDesignationBase
> doGetNameTypeDesignations(
87 @PathVariable("uuid") UUID uuid
, HttpServletRequest request
,
88 HttpServletResponse response
) throws IOException
{
90 if (request
!= null) {
91 logger
.info("doGetTypeDesignations()" + request
.getRequestURI());
93 TaxonName tnb
= getCdmBaseInstance(uuid
, response
,
95 Pager
<TypeDesignationBase
> p
= service
.getTypeDesignations(tnb
, null,
96 null, null, TYPEDESIGNATION_INIT_STRATEGY
);
97 return p
.getRecords();
101 value
= {"nameCache"},
102 method
= RequestMethod
.GET
)
103 public List
<String
> doGetNameCache(@PathVariable("uuid") UUID uuid
,
104 HttpServletRequest request
, HttpServletResponse response
)throws IOException
{
106 logger
.info("doGetNameCache()" + request
.getRequestURI());
107 TaxonName tnb
= getCdmBaseInstance(uuid
, response
, NAME_CACHE_INIT_STRATEGY
);
108 String nameCacheString
= tnb
.getNameCache();
109 List
<String
> result
= new ArrayList
<>();
110 result
.add(nameCacheString
);
115 @RequestMapping(value
= "taggedName", method
= RequestMethod
.GET
)
116 public ModelAndView
doGetTaggedName(
117 @PathVariable("uuid") UUID uuid
,
118 HttpServletRequest request
,
119 HttpServletResponse response
) throws IOException
{
120 logger
.info("doGetDescriptionElementsByType() - " + request
.getRequestURI());
122 ModelAndView mv
= new ModelAndView();
123 mv
.addObject(service
.getTaggedName(uuid
));