Project

General

Profile

Revision 38f374fc

ID38f374fcb054c490fa1998f4808baa1240421b14
Parent b1703fba
Child 1abedc74

Added by Andreas Kohlbecker over 8 years ago

reducing confusion about featureTree REST services and default initstrategy

View differences:

.gitattributes
1705 1705
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureNodeController.java -text
1706 1706
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeController.java -text
1707 1707
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeListController.java -text
1708
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeListPortalController.java -text
1709
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreePortalController.java -text
1708 1710
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/HttpStatusMessage.java -text
1709 1711
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/IdDoesNotExistException.java -text
1710 1712
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/IdentifiableListController.java -text
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/AbstractController.java
29 29
 */
30 30
public abstract class AbstractController<T extends CdmBase, SERVICE extends IService<T>> {
31 31

  
32
    protected static final List<String> DEFAULT_INIT_STRATEGY = Arrays.asList(new String []{
32
    private static final List<String> DEFAULT_INIT_STRATEGY = Arrays.asList(new String []{
33 33
            "$"
34 34
    });
35 35

  
......
56 56
     *
57 57
     * @param initializationStrategy
58 58
     */
59
    public void setInitializationStrategy(List<String> initializationStrategy) {
59
    public final void setInitializationStrategy(List<String> initializationStrategy) {
60 60
        this.initializationStrategy = initializationStrategy;
61 61
    }
62 62

  
63 63
    /**
64
     * Provides access to the default initialization strategy.
65
     * The default initialization strategy is predefined for all controllers in
66
     * {@link #DEFAULT_INIT_STRATEGY} but can be altered by
67
     * concrete implementations by utilizing {@link #setInitializationStrategy(List)}
68
     * in the constructor of the specific controller.
69
     *
70
     * @return the default initialization strategy
71
     */
72
    public final List<String> getInitializationStrategy() {
73
        return this.initializationStrategy;
74
    }
75

  
76
    /**
64 77
     * Returns the HTTP request path and query parameters as string
65 78
     *
66 79
     * @param request
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/BaseListController.java
82 82
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageIndex);
83 83
        pagerParameters.normalizeAndValidate(response);
84 84

  
85
        return service.page(type, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null, DEFAULT_INIT_STRATEGY);
85
        return service.page(type, pagerParameters.getPageSize(), pagerParameters.getPageIndex(), null, getInitializationStrategy());
86 86
    }
87 87

  
88 88
//    /**
......
125 125
        //if(start == null){ start = 0;}
126 126
        if(limit == null){ limit = PagerParameters.DEFAULT_PAGESIZE;}
127 127
        if(limit < 1){ limit = null;}
128
        return service.list(type, limit, start, null, DEFAULT_INIT_STRATEGY);
128
        return service.list(type, limit, start, null, getInitializationStrategy());
129 129
    }
130 130

  
131 131
  /* TODO
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionController.java
31 31
import eu.etaxonomy.cdm.api.service.IDescriptionService;
32 32
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
33 33
import eu.etaxonomy.cdm.api.service.pager.Pager;
34

  
35 34
import eu.etaxonomy.cdm.model.common.Annotation;
36 35
import eu.etaxonomy.cdm.model.common.Language;
37 36
import eu.etaxonomy.cdm.model.description.CategoricalData;
......
69 68
        super();
70 69
    }
71 70

  
72
    private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
73
            new String[]{
74
                "representations",
75
                "root.feature.representations",
76
                "root.children.feature.representations",
77
                "root.children.children.feature.representations",
78
            });
79

  
80

  
81

  
82 71
    protected static final List<String> TAXONDESCRIPTION_INIT_STRATEGY = Arrays.asList(new String []{
83 72
            "$",
84 73
            "elements.$",
......
111 100
     * @return
112 101
     * @throws IOException
113 102
     */
114
    @RequestMapping(value = {"/featureTree/{uuid}"}, method = RequestMethod.GET)
115
    public FeatureTree doGetFeatureTree(
116
            @PathVariable("uuid") UUID uuid,
117
            HttpServletRequest request,
118
            HttpServletResponse response)throws IOException {
119
        FeatureTree featureTree = getCdmBaseInstance(FeatureTree.class, featureTreeService, uuid, response, FEATURETREE_INIT_STRATEGY);
120
        return featureTree;
121
    }
103
//    @RequestMapping(value = {"/featureTree/{uuid}"}, method = RequestMethod.GET)
104
//    public FeatureTree doGetFeatureTree(
105
//            @PathVariable("uuid") UUID uuid,
106
//            HttpServletRequest request,
107
//            HttpServletResponse response)throws IOException {
108
//        FeatureTree featureTree = getCdmBaseInstance(FeatureTree.class, featureTreeService, uuid, response, FEATURETREE_INIT_STRATEGY);
109
//        return featureTree;
110
//    }
122 111

  
123 112
    @RequestMapping(value = "/descriptionElement/{descriptionelement_uuid}", method = RequestMethod.GET)
124 113
    public ModelAndView doGetDescriptionElement(
......
149 138
            return null;
150 139
        }
151 140

  
152
        Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, DEFAULT_INIT_STRATEGY);
141
        Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, getInitializationStrategy());
153 142
        return annotations;
154 143
    }
155 144

  
......
201 190
        PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);
202 191
        pagerParams.normalizeAndValidate(response);
203 192

  
204
        Pager<DescriptionElementBase> pager = service.searchElements(type, queryString, pageSize, pageNumber, null, DEFAULT_INIT_STRATEGY);
193
        Pager<DescriptionElementBase> pager = service.searchElements(type, queryString, pageSize, pageNumber, null, getInitializationStrategy());
205 194

  
206 195
        return pager;
207 196
    }
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionListController.java
25 25
import org.springframework.web.servlet.ModelAndView;
26 26

  
27 27
import eu.etaxonomy.cdm.api.service.IDescriptionService;
28
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
29 28
import eu.etaxonomy.cdm.api.service.ITermService;
30 29
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution;
31 30
import eu.etaxonomy.cdm.api.service.description.TransmissionEngineDistribution.AggregationMode;
32 31
import eu.etaxonomy.cdm.api.service.pager.Pager;
33 32
import eu.etaxonomy.cdm.model.description.DescriptionBase;
34
import eu.etaxonomy.cdm.model.description.FeatureTree;
35 33
import eu.etaxonomy.cdm.model.location.NamedArea;
36 34
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
37 35
import eu.etaxonomy.cdm.model.location.NamedAreaType;
......
49 47
@RequestMapping(value = {"/description"})
50 48
public class DescriptionListController extends IdentifiableListController<DescriptionBase, IDescriptionService> {
51 49

  
52
	@Autowired
53
	private IFeatureTreeService featureTreeService;
54 50

  
55 51
    @Autowired
56 52
    private ITermService termService;
......
68 64
     */
69 65
    private static UUID transmissionEngineMonitorUuid = null;
70 66

  
71
	private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
72
			new String[]{
73
				"representations",
74
				"root.feature.representations",
75
				"root.children.feature.representations"
76
			});
77

  
78
	/* (non-Javadoc)
79
	 * @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService)
80
	 */
81
	@Override
82
	@Autowired
83
	public void setService(IDescriptionService service) {
84
		this.service = service;
85
	}
86

  
87
	@RequestMapping(method = RequestMethod.GET, value="/featureTree")
88
	public List<FeatureTree> doGetFeatureTrees(HttpServletRequest request, HttpServletResponse response) throws IOException {
89

  
90
		List<FeatureTree> obj = featureTreeService.list(null,null,null,null,FEATURETREE_INIT_STRATEGY);
91
		return obj;
92
	}
93 67

  
94 68

  
69
    /* (non-Javadoc)
70
     * @see eu.etaxonomy.cdm.remote.controller.BaseListController#setService(eu.etaxonomy.cdm.api.service.IService)
71
     */
72
    @Override
73
    @Autowired
74
    public void setService(IDescriptionService service) {
75
        this.service = service;
76
    }
77

  
95 78
    @RequestMapping(value = { "accumulateDistributions" }, method = RequestMethod.GET)
96 79
    public ModelAndView doAccumulateDistributions(
97 80
            @RequestParam(value= "mode", required = true) final AggregationMode mode,
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/DescriptionPortalController.java
32 32

  
33 33
import eu.etaxonomy.cdm.api.service.DistributionTree;
34 34
import eu.etaxonomy.cdm.api.service.IDescriptionService;
35
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
36 35
import eu.etaxonomy.cdm.api.service.pager.Pager;
37 36
import eu.etaxonomy.cdm.model.common.Annotation;
38 37
import eu.etaxonomy.cdm.model.description.DescriptionBase;
39 38
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
40
import eu.etaxonomy.cdm.model.description.FeatureTree;
41 39
import eu.etaxonomy.cdm.model.description.TaxonDescription;
42 40
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
43 41
import eu.etaxonomy.cdm.remote.editor.NamedAreaLevelPropertyEditor;
......
52 50
 */
53 51

  
54 52
@Controller
55
@RequestMapping(value = {"/portal/description/{uuid}", "/portal/description/{uuid_list}", "/portal/descriptionElement/{descriptionelement_uuid}", "/portal/featureTree/{featuretree_uuid}"})
53
@RequestMapping(value = {
54
            "/portal/description/{uuid}",
55
            "/portal/description/{uuid_list}",
56
            "/portal/descriptionElement/{descriptionelement_uuid}",
57
    })
56 58
public class DescriptionPortalController extends BaseController<DescriptionBase, IDescriptionService>
57 59
{
58
    @Autowired
59
    private IFeatureTreeService featureTreeService;
60

  
61
    private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
62
            new String[]{
63
                "representations",
64
                "root.feature.representations",
65
                "root.children.feature.representations",
66
            });
67

  
68 60
    private static final List<String> DESCRIPTIONS_DISTRIBUTION_INIT_STRATEGY = Arrays.asList(new String []{
69 61
            "elements.sources.citation.$",
70 62
            "elements.area.$",
......
104 96
        this.service = service;
105 97
    }
106 98

  
107
    /**
108
     * TODO write controller method documentation
109
     *
110
     * @param request
111
     * @param response
112
     * @return
113
     * @throws IOException
114
     */
115

  
116
    @RequestMapping(value = {"/portal/featureTree/{featuretree_uuid}"}, method = RequestMethod.GET)
117
    public FeatureTree doGetFeatureTree(
118
            @PathVariable("featuretree_uuid") UUID featureUuid,
119
            HttpServletRequest request,
120
            HttpServletResponse response)throws IOException {
121
        //UUID featureTreeUuid = readValueUuid(request, null);
122
        FeatureTree featureTree = featureTreeService.load(featureUuid, FEATURETREE_INIT_STRATEGY);
123
        if(featureTree == null){
124
            HttpStatusMessage.UUID_NOT_FOUND.send(response);
125
        }
126
        return featureTree;
127
    }
128

  
129 99
    @RequestMapping(value = "/portal/descriptionElement/{descriptionelement_uuid}/annotation", method = RequestMethod.GET)
130 100
    public Pager<Annotation> getAnnotations(
131 101
            @PathVariable("descriptionelement_uuid") UUID uuid,
......
133 103
            HttpServletResponse response) throws IOException {
134 104
        logger.info("getAnnotations() - " + request.getRequestURI());
135 105
        DescriptionElementBase annotatableEntity = service.getDescriptionElementByUuid(uuid);
136
        Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, DEFAULT_INIT_STRATEGY);
106
        Pager<Annotation> annotations = service.getDescriptionElementAnnotations(annotatableEntity, null, null, 0, null, getInitializationStrategy());
137 107
        return annotations;
138 108
    }
139 109

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeController.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
24 24
 * @version 1.0
25 25
 */
26 26
@Controller
27
@RequestMapping(value = {"/featuretree/{uuid}"})
27
@RequestMapping(value = {"/featureTree/{uuid}"})
28 28
public class FeatureTreeController extends BaseController<FeatureTree, IFeatureTreeService> {
29
	private static final Logger logger = Logger
30
			.getLogger(FeatureTreeController.class);
29
    private static final Logger logger = Logger
30
            .getLogger(FeatureTreeController.class);
31 31

  
32
	/* (non-Javadoc)
33
	 * @see eu.etaxonomy.cdm.remote.controller.BaseController#setService(eu.etaxonomy.cdm.api.service.IService)
34
	 */
35
	@Override
36
	@Autowired
37
	public void setService(IFeatureTreeService service) {
38
		this.service = service;
39
	}
32
    /* (non-Javadoc)
33
     * @see eu.etaxonomy.cdm.remote.controller.BaseController#setService(eu.etaxonomy.cdm.api.service.IService)
34
     */
35
    @Override
36
    @Autowired
37
    public void setService(IFeatureTreeService service) {
38
        this.service = service;
39
    }
40 40
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeListController.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
10 10

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

  
13
import org.apache.log4j.Logger;
14 13
import org.springframework.beans.factory.annotation.Autowired;
15 14
import org.springframework.stereotype.Controller;
16 15
import org.springframework.web.bind.annotation.RequestMapping;
......
24 23
 * @version 1.0
25 24
 */
26 25
@Controller
27
@RequestMapping(value = {"/featuretrees"})
26
@RequestMapping(value = {"/featureTree"})
28 27
public class FeatureTreeListController extends IdentifiableListController<FeatureTree, IFeatureTreeService> {
29
	private static final Logger logger = Logger
30
			.getLogger(FeatureTreeListController.class);
31 28

  
32
	/* (non-Javadoc)
33
	 * @see eu.etaxonomy.cdm.remote.controller.BaseController#setService(eu.etaxonomy.cdm.api.service.IService)
34
	 */
35
	@Override
36
	@Autowired
37
	public void setService(IFeatureTreeService service) {
38
		this.service = service;
39
	}
29
    /* (non-Javadoc)
30
     * @see eu.etaxonomy.cdm.remote.controller.BaseController#setService(eu.etaxonomy.cdm.api.service.IService)
31
     */
32
    @Override
33
    @Autowired
34
    public void setService(IFeatureTreeService service) {
35
        this.service = service;
36
    }
40 37
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreeListPortalController.java
1
// $Id$
2
/**
3
* Copyright (C) 2013 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.cdm.remote.controller;
11

  
12
import java.util.Arrays;
13
import java.util.List;
14

  
15
import org.springframework.stereotype.Controller;
16
import org.springframework.web.bind.annotation.RequestMapping;
17

  
18
/**
19
 * @author a.kohlbecker
20
 * @date Jun 24, 2013
21
 *
22
 */
23
@Controller
24
@RequestMapping(value = {"/portal/featureTree"})
25
public class FeatureTreeListPortalController extends FeatureTreeListController {
26

  
27
    private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
28
            new String[]{
29
                "representations",
30
                "root.feature.representations",
31
                "root.children.feature.representations"
32
            });
33

  
34
    public FeatureTreeListPortalController() {
35
        setInitializationStrategy(FEATURETREE_INIT_STRATEGY);
36
    }
37

  
38
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/FeatureTreePortalController.java
1
// $Id$
2
/**
3
* Copyright (C) 2013 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
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.
9
*/
10
package eu.etaxonomy.cdm.remote.controller;
11

  
12
import java.util.Arrays;
13
import java.util.List;
14

  
15
import org.springframework.stereotype.Controller;
16
import org.springframework.web.bind.annotation.RequestMapping;
17

  
18
/**
19
 * @author a.kohlbecker
20
 * @date Jun 24, 2013
21
 *
22
 */
23
@Controller
24
@RequestMapping(value = {"/portal/featureTree/{uuid}"})
25
public class FeatureTreePortalController extends FeatureTreeController {
26

  
27
    private static final List<String> FEATURETREE_INIT_STRATEGY = Arrays.asList(
28
            new String[]{
29
                    "representations",
30
                    "root.feature.representations",
31
                    "root.children.feature.representations",
32
                    "root.children.children.feature.representations",
33
            });
34

  
35
    public FeatureTreePortalController() {
36
        setInitializationStrategy(FEATURETREE_INIT_STRATEGY);
37
    }
38

  
39
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/NameListController.java
10 10
package eu.etaxonomy.cdm.remote.controller;
11 11

  
12 12
import java.io.IOException;
13
import java.util.List;
14 13

  
15 14
import javax.servlet.http.HttpServletRequest;
16 15
import javax.servlet.http.HttpServletResponse;
17 16

  
18 17
import org.springframework.beans.factory.annotation.Autowired;
19 18
import org.springframework.stereotype.Controller;
20
import org.springframework.web.bind.annotation.PathVariable;
21 19
import org.springframework.web.bind.annotation.RequestMapping;
22 20
import org.springframework.web.bind.annotation.RequestMethod;
23 21
import org.springframework.web.bind.annotation.RequestParam;
......
63 61
        PagerParameters pagerParams = new PagerParameters(pageSize, pageNumber);
64 62
        pagerParams.normalizeAndValidate(response);
65 63

  
66
        return (Pager<TaxonNameBase>) service.findTitleCache(null, query, pagerParams.getPageSize(), pagerParams.getPageIndex(), null, matchMode);
64
        return service.findTitleCache(null, query, pagerParams.getPageSize(), pagerParams.getPageIndex(), null, matchMode);
67 65

  
68 66
    }
69 67

  
......
78 76
        PagerParameters pagerParameters = new PagerParameters(pageSize, pageNumber);
79 77
        pagerParameters.normalizeAndValidate(response);
80 78

  
81
        return (Pager<TaxonNameBase>) service.findByTitle(TaxonNameBase.class, query, matchMode, null, pageSize, pageNumber, null, DEFAULT_INIT_STRATEGY);
79
        return service.findByTitle(TaxonNameBase.class, query, matchMode, null, pageSize, pageNumber, null, getInitializationStrategy());
82 80
    }
83 81

  
84 82
}
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/OccurrenceListController.java
114 114

  
115 115
        return service.pageByAssociatedTaxon(null, includeRelationships, associatedTaxon,
116 116
                maxDepth, pagerParams.getPageSize(), pagerParams.getPageIndex(),
117
                orderHints, DEFAULT_INIT_STRATEGY);
117
                orderHints, getInitializationStrategy());
118 118

  
119 119
    }
120 120

  
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/TaxonController.java
72 72
    }
73 73

  
74 74

  
75
    @Override
75 76
    @Autowired
76 77
    public void setService(ITaxonService service) {
77 78
        this.service = service;
......
102 103
        if(tb instanceof Taxon){
103 104
            //the taxon already is accepted
104 105
            //FIXME take the current view into account once views are implemented!!!
105
            resultset.add((Taxon)tb);
106
            resultset.add(tb);
106 107
        } else {
107 108
            Synonym syn = (Synonym)tb;
108 109
            resultset.addAll(syn.getAcceptedTaxa());
......
123 124
            HttpStatusMessage.UUID_NOT_FOUND.send(response);
124 125
        }
125 126

  
126
        return service.listClassifications(taxonBase, null, null, DEFAULT_INIT_STRATEGY);
127
        return service.listClassifications(taxonBase, null, null, getInitializationStrategy());
127 128
    }
128 129

  
129 130
    @RequestMapping(value = "taxonNodes", method = RequestMethod.GET)

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)