Project

General

Profile

Download (4.98 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.cdm.remote.controller;
11

    
12
import io.swagger.annotations.Api;
13

    
14
import java.io.IOException;
15
import java.util.Arrays;
16
import java.util.List;
17
import java.util.UUID;
18

    
19
import javax.servlet.http.HttpServletRequest;
20
import javax.servlet.http.HttpServletResponse;
21

    
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;
30

    
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;
46

    
47
/**
48
 *
49
 * @author a.kohlbecker
50
 * @since Jun 25, 2013
51
 *
52
 */
53
@Controller
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>
60
{
61

    
62
    protected static final List<String> DESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
63
            "$",
64
            "elements.$",
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.*",
73
            "elements.unit",
74
            "elements.media",
75
            "elements.kindOfUnit"
76

    
77
    });
78

    
79
    protected static final List<String> ORDERED_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{
80
            "elements.$",
81
            "elements.annotations",
82
            "elements.markers",
83
            "elements.sources.citation.authorship.$",
84
            "elements.sources.nameUsedInSource",
85
            "elements.area.level",
86
    });
87

    
88
    protected static final List<String> DISTRIBUTION_INFO_INIT_STRATEGY = Arrays.asList(new String []{
89
            "sources.citation.authorship.$",
90
            "sources.nameUsedInSource",
91
            "annotations"
92
    });
93

    
94
    @Autowired
95
    private ITermService termService;
96

    
97
    @Autowired
98
    private IVocabularyService vocabularyService ;
99

    
100

    
101
    @Autowired
102
    private IEditGeoService geoService;
103

    
104

    
105
    public DescriptionPortalController() {
106
        super();
107
        setInitializationStrategy(DESCRIPTION_INIT_STRATEGY);
108
    }
109

    
110
    @InitBinder
111
    @Override
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));
117
    }
118

    
119
    /* (non-Javadoc)
120
     * @see eu.etaxonomy.cdm.remote.controller.GenericController#setService(eu.etaxonomy.cdm.api.service.IService)
121
     */
122
    @Autowired
123
    @Override
124
    public void setService(IDescriptionService service) {
125
        this.service = service;
126
    }
127

    
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());
136
        return annotations;
137
    }
138

    
139
}
(24-24/67)