1 |
aa037c70
|
Andreas Kohlbecker
|
/**
|
2 |
|
|
* Copyright (C) 2009 EDIT
|
3 |
8b38c58e
|
Andreas Kohlbecker
|
* European Distributed Institute of Taxonomy
|
4 |
aa037c70
|
Andreas Kohlbecker
|
* http://www.e-taxonomy.eu
|
5 |
8b38c58e
|
Andreas Kohlbecker
|
*
|
6 |
aa037c70
|
Andreas Kohlbecker
|
* 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 |
851c8d2e
|
Andreas Kohlbecker
|
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 |
8b38c58e
|
Andreas Kohlbecker
|
import org.apache.log4j.Logger;
|
19 |
aa037c70
|
Andreas Kohlbecker
|
import org.springframework.beans.factory.annotation.Autowired;
|
20 |
|
|
import org.springframework.stereotype.Controller;
|
21 |
851c8d2e
|
Andreas Kohlbecker
|
import org.springframework.web.bind.annotation.PathVariable;
|
22 |
aa037c70
|
Andreas Kohlbecker
|
import org.springframework.web.bind.annotation.RequestMapping;
|
23 |
851c8d2e
|
Andreas Kohlbecker
|
import org.springframework.web.bind.annotation.RequestMethod;
|
24 |
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
25 |
aa037c70
|
Andreas Kohlbecker
|
|
26 |
|
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
27 |
851c8d2e
|
Andreas Kohlbecker
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
28 |
1c39686b
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
|
29 |
|
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
30 |
d7043c98
|
Andreas Müller
|
import io.swagger.annotations.Api;
|
31 |
aa037c70
|
Andreas Kohlbecker
|
|
32 |
|
|
/**
|
33 |
|
|
* @author a.kohlbecker
|
34 |
7fa325bc
|
Andreas Müller
|
* @since 22.07.2010
|
35 |
aa037c70
|
Andreas Kohlbecker
|
*
|
36 |
|
|
*/
|
37 |
|
|
@Controller
|
38 |
fcb2c8b8
|
Andreas Kohlbecker
|
@Api("termVocabulary")
|
39 |
dcdd69ca
|
Andreas Kohlbecker
|
@RequestMapping(value = {"/termVocabulary/{uuid}"})
|
40 |
d7043c98
|
Andreas Müller
|
public class VocabularyController extends AbstractIdentifiableController<TermVocabulary, IVocabularyService> {
|
41 |
aa037c70
|
Andreas Kohlbecker
|
|
42 |
8b38c58e
|
Andreas Kohlbecker
|
public static final Logger logger = Logger.getLogger(VocabularyController.class);
|
43 |
|
|
|
44 |
d7043c98
|
Andreas Müller
|
|
45 |
8b38c58e
|
Andreas Kohlbecker
|
@Autowired
|
46 |
|
|
@Override
|
47 |
|
|
public void setService(IVocabularyService service) {
|
48 |
|
|
this.service = service;
|
49 |
|
|
}
|
50 |
aa037c70
|
Andreas Kohlbecker
|
|
51 |
851c8d2e
|
Andreas Kohlbecker
|
|
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 |
d7043c98
|
Andreas Müller
|
TermVocabulary<?> vocabulary = getCdmBaseInstance(uuid, response, (List<String>)null);
|
62 |
851c8d2e
|
Andreas Kohlbecker
|
|
63 |
|
|
Pager<DefinedTermBase> pager = service.getTerms(vocabulary, null, 0, orderBy.checkSuitableFor(vocabulary.getClass()).orderHints(), getInitializationStrategy());
|
64 |
|
|
|
65 |
|
|
return pager;
|
66 |
|
|
}
|
67 |
|
|
|
68 |
aa037c70
|
Andreas Kohlbecker
|
}
|