1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 EDIT European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version
|
7
|
* 1.1 See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.remote.controller;
|
11
|
|
12
|
import io.swagger.annotations.Api;
|
13
|
|
14
|
import java.io.IOException;
|
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.apache.log4j.Logger;
|
23
|
import org.springframework.beans.factory.annotation.Autowired;
|
24
|
import org.springframework.stereotype.Controller;
|
25
|
import org.springframework.web.bind.WebDataBinder;
|
26
|
import org.springframework.web.bind.annotation.InitBinder;
|
27
|
import org.springframework.web.bind.annotation.PathVariable;
|
28
|
import org.springframework.web.bind.annotation.RequestMapping;
|
29
|
import org.springframework.web.bind.annotation.RequestMethod;
|
30
|
import org.springframework.web.servlet.ModelAndView;
|
31
|
|
32
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
33
|
import eu.etaxonomy.cdm.database.UpdatableRoutingDataSource;
|
34
|
import eu.etaxonomy.cdm.model.name.Rank;
|
35
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
36
|
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;
|
37
|
|
38
|
/**
|
39
|
* The ClassificationController class is a Spring MVC Controller.
|
40
|
* <p>
|
41
|
* The syntax of the mapped service URIs contains the the {datasource-name} path element.
|
42
|
* The available {datasource-name}s are defined in a configuration file which
|
43
|
* is loaded by the {@link UpdatableRoutingDataSource}. If the
|
44
|
* UpdatableRoutingDataSource is not being used in the actual application
|
45
|
* context any arbitrary {datasource-name} may be used.
|
46
|
* <p>
|
47
|
* @author a.kohlbecker
|
48
|
* @date 20.03.2009
|
49
|
*
|
50
|
* TODO this controller should be a portal controller!!
|
51
|
*/
|
52
|
@Controller
|
53
|
@Api("portal_classification")
|
54
|
@RequestMapping(value = {"/portal/classification/{uuid}"})
|
55
|
public class ClassificationPortalController extends BaseController<Classification,IClassificationService> {
|
56
|
|
57
|
|
58
|
private static final List<String> CLASSIFICATION_INIT_STRATEGY = Arrays.asList(new String[]{
|
59
|
"reference.authorship",
|
60
|
"childNodes"
|
61
|
});
|
62
|
|
63
|
public static final Logger logger = Logger.getLogger(ClassificationPortalController.class);
|
64
|
|
65
|
@Override
|
66
|
@Autowired
|
67
|
public void setService(IClassificationService service) {
|
68
|
this.service = service;
|
69
|
}
|
70
|
|
71
|
|
72
|
|
73
|
@InitBinder
|
74
|
@Override
|
75
|
public void initBinder(WebDataBinder binder) {
|
76
|
super.initBinder(binder);
|
77
|
binder.registerCustomEditor(Rank.class, new RankPropertyEditor());
|
78
|
}
|
79
|
|
80
|
/**
|
81
|
*
|
82
|
*/
|
83
|
public ClassificationPortalController() {
|
84
|
super();
|
85
|
setInitializationStrategy(CLASSIFICATION_INIT_STRATEGY);
|
86
|
}
|
87
|
|
88
|
@RequestMapping(value = { "classificationRootNode" }, method = RequestMethod.GET)
|
89
|
public ModelAndView getClassificationRootNode(@PathVariable("uuid") UUID uuid, HttpServletRequest request,
|
90
|
HttpServletResponse response) throws IOException {
|
91
|
|
92
|
ModelAndView mv = new ModelAndView();
|
93
|
mv.addObject(service.getRootNode(uuid));
|
94
|
return mv;
|
95
|
}
|
96
|
|
97
|
|
98
|
}
|