merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / controller / TaxonNodeListController.java
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.Arrays;
15 import java.util.List;
16 import java.util.UUID;
17
18 import javax.servlet.http.HttpServletResponse;
19
20 import org.apache.log4j.Logger;
21 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.stereotype.Controller;
23 import org.springframework.web.bind.WebDataBinder;
24 import org.springframework.web.bind.annotation.InitBinder;
25 import org.springframework.web.bind.annotation.PathVariable;
26 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RequestMethod;
28
29 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
30 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
31 import eu.etaxonomy.cdm.remote.editor.UUIDPropertyEditor;
32
33 /**
34 * @author n.hoffmann
35 * @created Apr 8, 2010
36 * @version 1.0
37 */
38 @Controller
39 public class TaxonNodeListController extends BaseListController<TaxonNode, ITaxonNodeService> {
40 private static final Logger logger = Logger
41 .getLogger(TaxonNodeListController.class);
42
43
44 private static final List<String> NODE_INIT_STRATEGY = Arrays.asList(new String[]{
45 "taxon.sec",
46 "taxon.name.taggedName",
47 "taxon.name.titleCache"
48 });
49
50
51 private ITaxonNodeService service;
52
53 /* (non-Javadoc)
54 * @see eu.etaxonomy.cdm.remote.controller.AbstractListController#setService(eu.etaxonomy.cdm.api.service.IService)
55 */
56 @Override
57 @Autowired
58 public void setService(ITaxonNodeService service) {
59 this.service = service;
60 }
61
62 @InitBinder
63 public void initBinder(WebDataBinder binder) {
64 binder.registerCustomEditor(UUID.class, new UUIDPropertyEditor());
65 }
66
67 /**
68 * @param treeUuid
69 * @param response
70 * @return
71 * @throws IOException
72 */
73 @RequestMapping(
74 value = {"/taxonNode/{taxonNodeUuid}/childNodes/"},
75 method = RequestMethod.GET)
76 public List<TaxonNode> getChildNodes(
77 @PathVariable("taxonNodeUuid") UUID taxonNodeUuid,
78 HttpServletResponse response
79 ) throws IOException {
80
81 TaxonNode taxonNode = service.getTaxonNodeByUuid(taxonNodeUuid);
82
83 return service.loadChildNodesOfTaxonNode(taxonNode, NODE_INIT_STRATEGY);
84 }
85
86
87 }