Project

General

Profile

Download (2.91 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* 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 1.1
7
* 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 java.io.IOException;
13
import java.util.UUID;
14

    
15
import javax.servlet.http.HttpServletResponse;
16

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

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

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

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

    
49

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

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

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

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

    
93
        return service.pageChildNodesDTOs(uuid, false, doSynonyms, sortMode, pagerParameters.getPageSize(), pagerParameters.getPageIndex());
94
    }
95
}
(58-58/67)