2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.remote
.controller
;
12 import java
.io
.IOException
;
13 import java
.util
.UUID
;
15 import javax
.servlet
.http
.HttpServletRequest
;
16 import javax
.servlet
.http
.HttpServletResponse
;
18 import org
.apache
.logging
.log4j
.LogManager
;
19 import org
.apache
.logging
.log4j
.Logger
;
20 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
21 import org
.springframework
.stereotype
.Controller
;
22 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
23 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
24 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
25 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
27 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
28 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
29 import eu
.etaxonomy
.cdm
.compare
.taxon
.TaxonNodeSortMode
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
31 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
32 import eu
.etaxonomy
.cdm
.remote
.controller
.util
.PagerParameters
;
33 import io
.swagger
.annotations
.Api
;
36 * @author a.kohlbecker
41 @RequestMapping(value
= {"/taxonNode/{uuid}"})
42 //NOTE by AM: it seems that TaxonNodeController does not inherit from BaseController
43 // because doGet method return type is a TaxonNodeDTO not TaxonNode as expected
45 public class TaxonNodeController
extends AbstractController
<TaxonNode
, ITaxonNodeService
> {
47 public static final Logger logger
= LogManager
.getLogger(TaxonNodeController
.class);
51 public void setService(ITaxonNodeService service
) {
52 this.service
= service
;
57 method
= RequestMethod
.GET
)
58 public TaxonNodeDto
doGetParent(
59 @PathVariable("uuid") UUID uuid
,
60 HttpServletRequest request
,
61 @SuppressWarnings("unused") HttpServletResponse response
64 logger
.info("doGetParent() " + requestPathAndQuery(request
));
65 return service
.parentDto(uuid
);
69 method
= RequestMethod
.GET
)
70 public TaxonNodeDto
doGet(
71 @PathVariable("uuid") UUID uuid
,
72 HttpServletRequest request
,
73 HttpServletResponse response
74 ) throws IOException
{
76 logger
.info("doGet() " + requestPathAndQuery(request
));
77 TaxonNodeDto dto
= service
.dto(uuid
);
79 HttpStatusMessage
.UUID_NOT_FOUND
.send(response
);
85 value
= {"childNodes"},
86 method
= RequestMethod
.GET
)
87 public Pager
<TaxonNodeDto
> doPageChildNodes(
88 @PathVariable("uuid") UUID uuid
,
89 @RequestParam(value
= "pageIndex", required
= false) Integer pageIndex
,
90 @RequestParam(value
= "pageSize", required
= false) Integer pageSize
,
91 @RequestParam(value
="sortMode", defaultValue
= ClassificationController
.DEFAULT_TAXONNODEDTO_SORT_MODE
) TaxonNodeSortMode sortMode
,
92 @RequestParam(value
="doSynonyms", defaultValue
= "false") Boolean doSynonyms
,
93 HttpServletResponse response
94 ) throws IOException
{
96 boolean includeUnpublished
= NO_UNPUBLISHED
; //for now we do not allow any remote service to publish unpublished data
98 PagerParameters pagerParameters
= new PagerParameters(pageSize
, pageIndex
);
99 pagerParameters
.normalizeAndValidate(response
);
101 return service
.pageChildNodesDTOs(uuid
, false, includeUnpublished
, doSynonyms
, sortMode
, pagerParameters
.getPageSize(), pagerParameters
.getPageIndex());