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
.WebDataBinder
;
25 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
26 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
27 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
28 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
30 import eu
.etaxonomy
.cdm
.api
.service
.INameService
;
31 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
32 import eu
.etaxonomy
.cdm
.model
.name
.NonViralName
;
33 import eu
.etaxonomy
.cdm
.model
.name
.Rank
;
34 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
35 import eu
.etaxonomy
.cdm
.model
.name
.TypeDesignationBase
;
36 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
37 import eu
.etaxonomy
.cdm
.remote
.dto
.tdwg
.voc
.TaxonName
;
38 import eu
.etaxonomy
.cdm
.remote
.editor
.RankPropertyEditor
;
39 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDPropertyEditor
;
42 * TODO write controller documentation
44 * @author a.kohlbecker
49 @RequestMapping(value
= {"/name/{uuid}"})
50 public class NameController
extends AnnotatableController
<TaxonNameBase
, INameService
>
53 private static final List
<String
> TYPEDESIGNATION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
54 "typeStatus.representations",
59 "citation.authorTeam.$",
62 private static final List
<String
> NAME_CACHE_INIT_STRATEGY
= Arrays
.asList(new String
[]{
66 public NameController(){
68 setInitializationStrategy(Arrays
.asList(new String
[]{"$"})); //TODO still needed????
72 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
76 public void setService(INameService service
) {
77 this.service
= service
;
82 * Get the list of {@link TypeDesignationBase}s of the
83 * {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.
85 * URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>
89 * @return a List of {@link TypeDesignationBase} entities which are initialized
90 * using the {@link #TYPEDESIGNATION_INIT_STRATEGY}
92 *///TODO obsolete method?
93 @RequestMapping(value
= { "typeDesignations" }, method
= RequestMethod
.GET
)
94 public List
<TypeDesignationBase
> doGetNameTypeDesignations(
95 @PathVariable("uuid") UUID uuid
, HttpServletRequest request
,
96 HttpServletResponse response
) throws IOException
{
98 logger
.info("doGetTypeDesignations()" + request
.getServletPath());
99 TaxonNameBase tnb
= getCdmBaseInstance(uuid
, response
,
100 (List
<String
>) null);
101 Pager
<TypeDesignationBase
> p
= service
.getTypeDesignations(tnb
, null,
102 null, null, TYPEDESIGNATION_INIT_STRATEGY
);
103 return p
.getRecords();
107 //TODO obsolete method?
109 value
= {"nameCache"},
110 method
= RequestMethod
.GET
)
111 public List
<String
> doGetNameCache(@PathVariable("uuid") UUID uuid
,
112 HttpServletRequest request
, HttpServletResponse response
)throws IOException
{
114 logger
.info("doGetNameCache()" + request
.getServletPath());
115 TaxonNameBase tnb
= getCdmBaseInstance(uuid
, response
, NAME_CACHE_INIT_STRATEGY
);
116 NonViralName nvn
= (NonViralName
) tnb
;
117 String nameCacheString
= nvn
.getNameCache();
118 List result
= new ArrayList
<String
>();
119 result
.add(nameCacheString
);