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.
9 package eu
.etaxonomy
.cdm
.remote
.controller
;
11 import java
.util
.Arrays
;
12 import java
.util
.List
;
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
.transaction
.annotation
.Transactional
;
23 import org
.springframework
.web
.bind
.WebDataBinder
;
24 import org
.springframework
.web
.bind
.annotation
.InitBinder
;
25 import org
.springframework
.web
.bind
.annotation
.PathVariable
;
26 import org
.springframework
.web
.bind
.annotation
.RequestMapping
;
27 import org
.springframework
.web
.bind
.annotation
.RequestMethod
;
29 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionElementService
;
30 import eu
.etaxonomy
.cdm
.api
.service
.IDescriptionService
;
31 import eu
.etaxonomy
.cdm
.api
.service
.ITermService
;
32 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
33 import eu
.etaxonomy
.cdm
.model
.common
.Annotation
;
34 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
35 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
36 import eu
.etaxonomy
.cdm
.model
.location
.NamedAreaLevel
;
37 import eu
.etaxonomy
.cdm
.persistence
.dao
.initializer
.EntityInitStrategy
;
38 import eu
.etaxonomy
.cdm
.remote
.editor
.DefinedTermBaseList
;
39 import eu
.etaxonomy
.cdm
.remote
.editor
.NamedAreaLevelPropertyEditor
;
40 import eu
.etaxonomy
.cdm
.remote
.editor
.TermBaseListPropertyEditor
;
41 import eu
.etaxonomy
.cdm
.remote
.editor
.UUIDListPropertyEditor
;
42 import eu
.etaxonomy
.cdm
.remote
.editor
.UuidList
;
43 import io
.swagger
.annotations
.Api
;
46 * @author a.kohlbecker
50 @Api("portal_description")
51 @Transactional(readOnly
=true)
52 @RequestMapping(value
= {
53 "/portal/description/{uuid}",
54 "/portal/description/{uuid_list}"})
55 public class DescriptionPortalController
extends BaseController
<DescriptionBase
, IDescriptionService
> {
57 private static final Logger logger
= LogManager
.getLogger();
59 public static final EntityInitStrategy DESCRIPTION_INIT_STRATEGY
= new EntityInitStrategy(Arrays
.asList(new String
[] {
61 "descriptiveDataSets",
62 "descriptiveDataSets.descriptiveSystem",
63 "descriptiveDataSets.descriptiveSystem.root",
64 "descriptiveDataSets.descriptiveSystem.root.childNodes",
65 "descriptiveDataSets.descriptiveSystem.root.childNodes.term",
67 "elements.annotations",
68 "elements.multilanguageText.*",
69 "elements.stateData.*",
70 "elements.sources.citation.authorship.$",
71 "elements.sources.nameUsedInSource",
73 "elements.modifyingText",
75 "elements.area.level",
76 "elements.statisticalValues.*",
78 "elements.kindOfUnit",
83 "sources.cdmSource.target",
87 protected static final List
<String
> ORDERED_DISTRIBUTION_INIT_STRATEGY
= Arrays
.asList(new String
[]{
89 "elements.annotations",
90 "elements.annotations.includes.$",
92 "elements.sources.citation.authorship.$",
93 "elements.sources.nameUsedInSource",
94 "elements.area.level",
97 protected static final List
<String
> DISTRIBUTION_INFO_INIT_STRATEGY
= Arrays
.asList(new String
[]{
98 "sources.citation.authorship.$",
99 "sources.nameUsedInSource",
101 "annotations.includes.$"
105 private ITermService termService
;
108 private IDescriptionElementService descriptionElementService
;
110 public DescriptionPortalController() {
112 setInitializationStrategy(DESCRIPTION_INIT_STRATEGY
.getPropertyPaths());
117 public void initBinder(WebDataBinder binder
) {
118 super.initBinder(binder
);
119 binder
.registerCustomEditor(UuidList
.class, new UUIDListPropertyEditor());
120 binder
.registerCustomEditor(NamedAreaLevel
.class, new NamedAreaLevelPropertyEditor());
121 binder
.registerCustomEditor(DefinedTermBaseList
.class, new TermBaseListPropertyEditor
<>(termService
));
126 public void setService(IDescriptionService service
) {
127 this.service
= service
;
130 @RequestMapping(value
= "//portal/descriptionElement/{descriptionelement_uuid}/annotation", method
= RequestMethod
.GET
) // mapped as absolute path, see CdmAntPathMatcher
131 public Pager
<Annotation
> getAnnotations(
132 @PathVariable("descriptionelement_uuid") UUID uuid
,
133 HttpServletRequest request
,
134 HttpServletResponse response
) {
135 logger
.info("getAnnotations() - " + requestPathAndQuery(request
) );
136 DescriptionElementBase annotatableEntity
= descriptionElementService
.find(uuid
);
137 Pager
<Annotation
> annotations
= descriptionElementService
.getAnnotations(annotatableEntity
, null, null, 0, null, getInitializationStrategy());