3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.remote
.controller
;
13 import java
.io
.IOException
;
14 import java
.util
.Arrays
;
15 import java
.util
.HashSet
;
16 import java
.util
.List
;
18 import java
.util
.UUID
;
20 import javax
.servlet
.http
.HttpServletRequest
;
21 import javax
.servlet
.http
.HttpServletResponse
;
23 import org
.apache
.commons
.lang
.ObjectUtils
;
24 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
25 import org
.springframework
.stereotype
.Controller
;
26 import org
.springframework
.web
.bind
.WebDataBinder
;
27 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
28 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
29 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
30 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
31 import org
.springframework
.web
.bind
.annotation
.RequestParam
;
33 import eu
.etaxonomy
.cdm
.api
.service
.DistributionTree
;
34 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
35 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
37 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
38 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
39 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
40 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
41 import eu
.etaxonomy
.cdm
.remote
.editor
.NamedAreaLevelPropertyEditor
;
42 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDListPropertyEditor
;
43 import eu
.etaxonomy
.cdm
.remote
.editor
.UuidList
;
48 * This controller is mostly a 1:1 copy of the DescriptionController
49 * and this provides identical end points which only differ in the depth of the
50 * object graphs returned.
52 * @author a.kohlbecker
57 @RequestMapping(value
= {
58 "/portal/description/{uuid}",
59 "/portal/description/{uuid_list}",
60 "/portal/descriptionElement/{descriptionelement_uuid}"})
61 public class DescriptionPortalController
extends BaseController
<DescriptionBase
, IDescriptionService
>
64 protected static final List
<String
> DESCRIPTION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
67 "elements.sources.citation.authorTeam.$",
68 "elements.sources.nameUsedInSource.originalNameString",
69 "elements.area.level",
70 "elements.modifyingText",
76 public DescriptionPortalController() {
78 setInitializationStrategy(DESCRIPTION_INIT_STRATEGY
);
83 public void initBinder(WebDataBinder binder
) {
84 super.initBinder(binder
);
85 binder
.registerCustomEditor(UuidList
.class, new UUIDListPropertyEditor());
86 binder
.registerCustomEditor(NamedAreaLevel
.class, new NamedAreaLevelPropertyEditor());
90 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
94 public void setService(IDescriptionService service
) {
95 this.service
= service
;
98 @RequestMapping(value
= "/portal/descriptionElement/{descriptionelement_uuid}/annotation", method
= RequestMethod
.GET
)
99 public Pager
<Annotation
> getAnnotations(
100 @PathVariable("descriptionelement_uuid") UUID uuid
,
101 HttpServletRequest request
,
102 HttpServletResponse response
) throws IOException
{
103 logger
.info("getAnnotations() - " + request
.getRequestURI());
104 DescriptionElementBase annotatableEntity
= service
.getDescriptionElementByUuid(uuid
);
105 Pager
<Annotation
> annotations
= service
.getDescriptionElementAnnotations(annotatableEntity
, null, null, 0, null, getInitializationStrategy());
109 @RequestMapping(value
= "/portal/description/{uuid_list}/DistributionTree", method
= RequestMethod
.GET
)
110 public DistributionTree
doGetOrderedDistributionsB(
111 @PathVariable("uuid_list") UuidList descriptionUuidList
,
112 @RequestParam(value
= "omitLevels", required
= false) Set
<NamedAreaLevel
> levels
,
113 HttpServletRequest request
, HttpServletResponse response
) {
114 logger
.info("getOrderedDistributionsB(" + ObjectUtils
.toString(levels
) + ") - " + request
.getRequestURI());
115 Set
<TaxonDescription
> taxonDescriptions
= new HashSet
<TaxonDescription
>();
116 TaxonDescription description
;
117 for (UUID descriptionUuid
: descriptionUuidList
) {
118 description
= (TaxonDescription
) service
.load(descriptionUuid
, DESCRIPTION_INIT_STRATEGY
);
119 taxonDescriptions
.add(description
);
121 DistributionTree distTree
= service
.getOrderedDistributions(taxonDescriptions
, levels
, DESCRIPTION_INIT_STRATEGY
);