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 io
.swagger
.annotations
.Api
;
14 import java
.io
.IOException
;
15 import java
.util
.Arrays
;
16 import java
.util
.List
;
17 import java
.util
.UUID
;
19 import javax
.servlet
.http
.HttpServletRequest
;
20 import javax
.servlet
.http
.HttpServletResponse
;
22 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
23 import org
.springframework
.stereotype
.Controller
;
24 import org
.springframework
.transaction
.annotation
.Transactional
;
25 import org
.springframework
.web
.bind
.WebDataBinder
;
26 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
27 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
28 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
29 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
31 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
33 import eu
.etaxonomy
.cdm
.api
.service
.IVocabularyService
;
34 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
35 import eu
.etaxonomy
.cdm
.ext
.geo
.IEditGeoService
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
37 import eu
.etaxonomy
.cdm
.model
.common
.MarkerType
;
38 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
39 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
40 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
41 import eu
.etaxonomy
.cdm
.remote
.editor
.DefinedTermBaseList
;
42 import eu
.etaxonomy
.cdm
.remote
.editor
.NamedAreaLevelPropertyEditor
;
43 import eu
.etaxonomy
.cdm
.remote
.editor
.TermBaseListPropertyEditor
;
44 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDListPropertyEditor
;
45 import eu
.etaxonomy
.cdm
.remote
.editor
.UuidList
;
49 * @author a.kohlbecker
54 @Api("portal_description")
55 @Transactional(readOnly
=true)
56 @RequestMapping(value
= {
57 "/portal/description/{uuid}",
58 "/portal/description/{uuid_list}"})
59 public class DescriptionPortalController
extends BaseController
<DescriptionBase
, IDescriptionService
>
62 protected static final List
<String
> DESCRIPTION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
65 "elements.multilanguageText.*",
66 "elements.annotations",
67 "elements.sources.citation.authorship.$",
68 "elements.sources.nameUsedInSource",
69 "elements.area.level",
70 "elements.modifyingText",
71 "elements.stateData.*",
72 "elements.statisticalValues.*",
79 protected static final List
<String
> ORDERED_DISTRIBUTION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
81 "elements.annotations",
83 "elements.sources.citation.authorship.$",
84 "elements.sources.nameUsedInSource",
85 "elements.area.level",
88 protected static final List
<String
> DISTRIBUTION_INFO_INIT_STRATEGY
= Arrays
.asList(new String
[]{
89 "sources.citation.authorship.$",
90 "sources.nameUsedInSource",
95 private ITermService termService
;
98 private IVocabularyService vocabularyService
;
102 private IEditGeoService geoService
;
105 public DescriptionPortalController() {
107 setInitializationStrategy(DESCRIPTION_INIT_STRATEGY
);
112 public void initBinder(WebDataBinder binder
) {
113 super.initBinder(binder
);
114 binder
.registerCustomEditor(UuidList
.class, new UUIDListPropertyEditor());
115 binder
.registerCustomEditor(NamedAreaLevel
.class, new NamedAreaLevelPropertyEditor());
116 binder
.registerCustomEditor(DefinedTermBaseList
.class, new TermBaseListPropertyEditor
<MarkerType
>(termService
));
120 * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
124 public void setService(IDescriptionService service
) {
125 this.service
= service
;
128 @RequestMapping(value
= "//portal/descriptionElement/{descriptionelement_uuid}/annotation", method
= RequestMethod
.GET
) // mapped as absolute path, see CdmAntPathMatcher
129 public Pager
<Annotation
> getAnnotations(
130 @PathVariable("descriptionelement_uuid") UUID uuid
,
131 HttpServletRequest request
,
132 HttpServletResponse response
) throws IOException
{
133 logger
.info("getAnnotations() - " + requestPathAndQuery(request
) );
134 DescriptionElementBase annotatableEntity
= service
.getDescriptionElementByUuid(uuid
);
135 Pager
<Annotation
> annotations
= service
.getDescriptionElementAnnotations(annotatableEntity
, null, null, 0, null, getInitializationStrategy());