Project

General

Profile

Download (2.34 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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
package eu.etaxonomy.cdm.remote.controller;
10

    
11
import java.io.IOException;
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import javax.servlet.http.HttpServletRequest;
16
import javax.servlet.http.HttpServletResponse;
17

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

    
26
import eu.etaxonomy.cdm.api.service.IVocabularyService;
27
import eu.etaxonomy.cdm.api.service.pager.Pager;
28
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
29
import eu.etaxonomy.cdm.model.term.TermVocabulary;
30
import io.swagger.annotations.Api;
31

    
32
/**
33
 * @author a.kohlbecker
34
 * @since 22.07.2010
35
 *
36
 */
37
@Controller
38
@Api("termVocabulary")
39
@RequestMapping(value = {"/termVocabulary/{uuid}"})
40
public class VocabularyController extends AbstractIdentifiableController<TermVocabulary, IVocabularyService> {
41

    
42
    public static final Logger logger = Logger.getLogger(VocabularyController.class);
43

    
44

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

    
51

    
52
    @RequestMapping(value="terms", method=RequestMethod.GET, params="orderBy")
53
    public Pager<DefinedTermBase> terms(
54
            @PathVariable("uuid")UUID uuid,
55
            @RequestParam(name="orderBy", defaultValue="BY_ORDER_INDEX_ASC", required=true) OrderHintPreset orderBy,
56
            HttpServletResponse response,
57
            HttpServletRequest request) throws IOException {
58

    
59
        logger.info("terms() " + requestPathAndQuery(request));
60

    
61
        TermVocabulary<?> vocabulary = getCdmBaseInstance(uuid, response, (List<String>)null);
62

    
63
        Pager<DefinedTermBase> pager = service.getTerms(vocabulary, null, 0, orderBy.checkSuitableFor(vocabulary.getClass()).orderHints(), getInitializationStrategy());
64

    
65
        return pager;
66
    }
67

    
68
}
(74-74/75)