1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
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.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.remote.controller;
|
12
|
|
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;
|
18
|
|
19
|
import javax.servlet.http.HttpServletRequest;
|
20
|
import javax.servlet.http.HttpServletResponse;
|
21
|
|
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
|
|
28
|
import eu.etaxonomy.cdm.api.service.INameService;
|
29
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
30
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
31
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
32
|
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
|
33
|
|
34
|
/**
|
35
|
* TODO write controller documentation
|
36
|
*
|
37
|
* @author a.kohlbecker
|
38
|
* @date 24.03.2009
|
39
|
*/
|
40
|
|
41
|
@Controller
|
42
|
@RequestMapping(value = {"/name/{uuid}"})
|
43
|
public class NameController extends AnnotatableController<TaxonNameBase, INameService>
|
44
|
{
|
45
|
|
46
|
private static final List<String> TYPEDESIGNATION_INIT_STRATEGY = Arrays.asList(new String []{
|
47
|
"typeStatus.representations",
|
48
|
"typifiedNames",
|
49
|
"typeSpecimen",
|
50
|
"typeName",
|
51
|
"citation",
|
52
|
"citation.authorTeam.$",
|
53
|
});
|
54
|
|
55
|
private static final List<String> NAME_CACHE_INIT_STRATEGY = Arrays.asList(new String []{
|
56
|
|
57
|
});
|
58
|
|
59
|
public NameController(){
|
60
|
super();
|
61
|
setInitializationStrategy(Arrays.asList(new String[]{"$"})); //TODO still needed????
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
|
66
|
*/
|
67
|
@Autowired
|
68
|
@Override
|
69
|
public void setService(INameService service) {
|
70
|
this.service = service;
|
71
|
}
|
72
|
|
73
|
|
74
|
/**
|
75
|
* Get the list of {@link TypeDesignationBase}s of the
|
76
|
* {@link TaxonNameBase} instance identified by the <code>{name-uuid}</code>.
|
77
|
* <p>
|
78
|
* URI: <b>/{datasource-name}/name/{name-uuid}/typeDesignations</b>
|
79
|
*
|
80
|
* @param request
|
81
|
* @param response
|
82
|
* @return a List of {@link TypeDesignationBase} entities which are initialized
|
83
|
* using the {@link #TYPEDESIGNATION_INIT_STRATEGY}
|
84
|
* @throws IOException
|
85
|
*///TODO obsolete method?
|
86
|
@RequestMapping(value = { "typeDesignations" }, method = RequestMethod.GET)
|
87
|
public List<TypeDesignationBase> doGetNameTypeDesignations(
|
88
|
@PathVariable("uuid") UUID uuid, HttpServletRequest request,
|
89
|
HttpServletResponse response) throws IOException {
|
90
|
|
91
|
logger.info("doGetTypeDesignations()" + request.getServletPath());
|
92
|
TaxonNameBase tnb = getCdmBaseInstance(uuid, response,
|
93
|
(List<String>) null);
|
94
|
Pager<TypeDesignationBase> p = service.getTypeDesignations(tnb, null,
|
95
|
null, null, TYPEDESIGNATION_INIT_STRATEGY);
|
96
|
return p.getRecords();
|
97
|
|
98
|
}
|
99
|
|
100
|
//TODO obsolete method?
|
101
|
@RequestMapping(
|
102
|
value = {"nameCache"},
|
103
|
method = RequestMethod.GET)
|
104
|
public List<String> doGetNameCache(@PathVariable("uuid") UUID uuid,
|
105
|
HttpServletRequest request, HttpServletResponse response)throws IOException {
|
106
|
|
107
|
logger.info("doGetNameCache()" + request.getServletPath());
|
108
|
TaxonNameBase tnb = getCdmBaseInstance(uuid, response, NAME_CACHE_INIT_STRATEGY);
|
109
|
NonViralName nvn = (NonViralName) tnb;
|
110
|
String nameCacheString = nvn.getNameCache();
|
111
|
List result = new ArrayList<String>();
|
112
|
result.add(nameCacheString);
|
113
|
return result;
|
114
|
|
115
|
}
|
116
|
|
117
|
}
|