Project

General

Profile

Download (2.91 KB) Statistics
| Branch: | Tag: | Revision:
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.UUID;
15

    
16
import javax.servlet.http.HttpServletResponse;
17

    
18
import org.springframework.beans.factory.annotation.Autowired;
19
import org.springframework.stereotype.Controller;
20
import org.springframework.web.bind.annotation.PathVariable;
21
import org.springframework.web.bind.annotation.RequestMapping;
22
import org.springframework.web.bind.annotation.RequestMethod;
23
import org.springframework.web.bind.annotation.RequestParam;
24

    
25
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
26
import eu.etaxonomy.cdm.api.service.NodeSortMode;
27
import eu.etaxonomy.cdm.api.service.pager.Pager;
28
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
29
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
30
import eu.etaxonomy.cdm.remote.controller.util.PagerParameters;
31
import io.swagger.annotations.Api;
32

    
33
/**
34
 *
35
 * @author a.kohlbecker
36
 * @date Jun 13, 2016
37
 *
38
 */
39
@Controller
40
@Api("taxonNode")
41
@RequestMapping(value = {"/taxonNode/{uuid}"})
42
public class TaxonNodeController extends AbstractController<TaxonNode, ITaxonNodeService> {
43

    
44
    @Override
45
    @Autowired
46
    public void setService(ITaxonNodeService service) {
47
        this.service = service;
48
    }
49

    
50

    
51
    /**
52
     *
53
     * @param uuid
54
     * @param response
55
     * @return
56
     * @throws IOException
57
     */
58
    @RequestMapping(
59
            value = {"parent"},
60
            method = RequestMethod.GET)
61
    public TaxonNodeDto doGetParent(
62
            @PathVariable("uuid") UUID uuid,
63
            HttpServletResponse response
64
            ) throws IOException {
65

    
66
        return service.parentDto(uuid);
67
    }
68

    
69
    /**
70
     *
71
     * @param uuid
72
     * @param pageIndex
73
     * @param pageSize
74
     * @param sortMode
75
     * @param response
76
     * @return
77
     * @throws IOException
78
     */
79
    @RequestMapping(
80
            value = {"childNodes"},
81
            method = RequestMethod.GET)
82
    public Pager<TaxonNodeDto> doPageChildNodes(
83
            @PathVariable("uuid") UUID uuid,
84
            @RequestParam(value = "pageNumber", required = false) Integer pageIndex,
85
            @RequestParam(value = "pageSize", required = false) Integer pageSize,
86
            @RequestParam(value="sortMode", defaultValue="AlphabeticalOrder") NodeSortMode sortMode,
87
            @RequestParam(value="doSynonyms", defaultValue="false") Boolean doSynonyms,
88
            HttpServletResponse response
89
            ) throws IOException {
90

    
91
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageIndex);
92
        pagerParameters.normalizeAndValidate(response);
93

    
94
        return service.pageChildNodesDTOs(uuid, false, doSynonyms, sortMode, pagerParameters.getPageSize(), pagerParameters.getPageIndex());
95
    }
96
}
(56-56/63)