Project

General

Profile

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

    
12
import io.swagger.annotations.Api;
13

    
14
import java.io.IOException;
15
import java.util.List;
16
import java.util.UUID;
17

    
18
import javax.servlet.http.HttpServletRequest;
19
import javax.servlet.http.HttpServletResponse;
20

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

    
29
import eu.etaxonomy.cdm.api.service.IVocabularyService;
30
import eu.etaxonomy.cdm.api.service.pager.Pager;
31
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
32
import eu.etaxonomy.cdm.model.common.TermVocabulary;
33

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

    
44
    public static final Logger logger = Logger.getLogger(VocabularyController.class);
45

    
46
    /* (non-Javadoc)
47
     * @see eu.etaxonomy.cdm.remote.controller.BaseController#setService(eu.etaxonomy.cdm.api.service.IService)
48
     */
49
    @Autowired
50
    @Override
51
    public void setService(IVocabularyService service) {
52
        this.service = service;
53
    }
54

    
55

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

    
63
        logger.info("terms() " + requestPathAndQuery(request));
64

    
65
        TermVocabulary vocabulary = getCdmBaseInstance(uuid, response, (List<String>)null);
66

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

    
69
        return pager;
70
    }
71

    
72
}
(62-62/63)