Project

General

Profile

« Previous | Next » 

Revision bd9c39e8

Added by Andreas Müller over 6 years ago

Fix compile error in Print Publisher

View differences:

cdmlib-print/src/main/java/eu/etaxonomy/cdm/print/LocalXMLEntityFactory.java
17 17
import java.util.List;
18 18
import java.util.UUID;
19 19

  
20
import net.sf.json.JsonConfig;
21

  
22 20
import org.apache.log4j.Logger;
23 21
import org.jdom.Document;
24 22
import org.jdom.Element;
......
41 39
import eu.etaxonomy.cdm.remote.controller.dto.PolytomousKeyNodeDtoController;
42 40
import eu.etaxonomy.cdm.remote.view.JsonView;
43 41
import eu.etaxonomy.cdm.remote.view.JsonView.Type;
42
import net.sf.json.JsonConfig;
44 43

  
45 44
/**
46 45
 * The local entity factory assumes that an application context is available and
......
48 47
 *
49 48
 * @author n.hoffmann
50 49
 * @created Jul 16, 2010
51
 * @version 1.0
52 50
 */
53 51
@Component
54 52
public class LocalXMLEntityFactory extends XmlEntityFactoryBase {
......
158 156
        return processElementList(result);
159 157
    }
160 158

  
161
    /*
162
     * (non-Javadoc)
163
     *
164
     * @see
165
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getChildNodes(org.jdom.
166
     * Element)
167
     */
168 159
    @Override
169 160
    public List<Element> getChildNodes(Element treeNode) {
170 161
        xmlView.setJsonConfig(jsonConfig);
......
176 167
        try {
177 168
            if (EntityType.CLASSIFICATION.equals(entityType)) {
178 169
                resultObject = classificationController.getChildNodes(uuid,
179
                        null);
170
                        null, null);
180 171
            } else if (EntityType.TAXON_NODE.equals(entityType)) {
181 172
                resultObject = taxonNodePrintAppController
182 173
                        .getChildNodes(uuid, null);
......
191 182
        return processElementList(result);
192 183
    }
193 184

  
194
    /*
195
     * (non-Javadoc)
196
     *
197
     * @see
198
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getTaxonNodeByUuid(java
199
     * .util.UUID)
200
     */
201 185
    @Override
202 186
    public Element getTaxonNode(UUID taxonNodeUuid) {
203 187
        xmlView.setJsonConfig(jsonConfig);
......
250 234
        return result;
251 235
    }
252 236

  
253
    /*
254
     * (non-Javadoc)
255
     *
256
     * @see
257
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getFeatureForFeatureNode
258
     * (java.util.UUID)
259
     */
260 237
    @Override
261 238
    public Element getFeatureForFeatureNode(UUID uuid) {
262 239
        xmlView.setJsonConfig(jsonConfig);
......
294 271
        return result;
295 272
    }
296 273

  
297
    /*
298
     * (non-Javadoc)
299
     *
300
     * @see
301
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getTaxonForTaxonNode(org
302
     * .jdom.Element)
303
     */
304 274
    @Override
305 275
    public Element getTaxonForTaxonNode(Element taxonNodeElement) {
306 276
        xmlView.setJsonConfig(jsonConfig);
......
371 341
        return elementList;
372 342
    }
373 343

  
374
    /*
375
     * (non-Javadoc)
376
     *
377
     * @see
378
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getTypeDesignations(org
379
     * .jdom.Element)
380
     */
381 344
    @Override
382 345
    public List<Element> getTypeDesignations(Element nameElement) {
383 346
        xmlView.setJsonConfig(jsonConfig);
......
401 364
        return processElementList(result);
402 365
    }
403 366

  
404
    /*
405
     * (non-Javadoc)n
406
     *
407
     * @see
408
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getDescriptions(org.jdom
409
     * .Element)
410
     */
411 367
    @Override
412 368
    public Element getDescriptions(Element taxonElement) {
413 369
        xmlView.setJsonConfig(jsonConfigPortal);
......
429 385
        return result;
430 386
    }
431 387

  
432
    /*
433
     * (non-Javadoc)
434
     *
435
     * @see
436
     * eu.etaxonomy.printpublisher.IXMLEntityFactory#getPolytomousKey(org
437
     * .jdom.Element)
438
     */
388

  
439 389
    @Override
440 390
    public Element getPolytomousKey(Element taxonElement) {
441 391
    	xmlView.setJsonConfig(jsonConfigPortal);
......
515 465
        return new Element("somethingWentWrong");
516 466
    }
517 467

  
518
	/* (non-Javadoc)
519
	 * @see eu.etaxonomy.cdm.print.IXMLEntityFactory#getReferences(org.jdom.Element)
520
	 */
521
	@Override
522
	public List<Element> getReferences(Element referenceElement) {
523
		// TODO Auto-generated method stub
524
		return null;
525
	}
468
    @Override
469
    public List<Element> getReferences(Element referenceElement) {
470
        // TODO Auto-generated method stub
471
        return null;
472
    }
526 473

  
527
	/* (non-Javadoc)
528
	 * @see eu.etaxonomy.cdm.print.IXMLEntityFactory#getTaxonNodesByName(java.lang.String)
529
	 */
530 474
	@Override
531 475
	public Element getTaxonNodesByName(String taxonName, String classification) {
532 476
		// TODO Auto-generated method stub
533 477
		return null;
534 478
	}
535 479

  
536
	/* (non-Javadoc)
537
	 * @see eu.etaxonomy.cdm.print.IXMLEntityFactory#getMedia(org.jdom.Element)
538
	 */
539 480
	@Override
540 481
	public List<Element> getMedia(Element taxonElement) {
541 482
		// TODO Auto-generated method stub
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/ClassificationController.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 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 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.web.bind.WebDataBinder;
25
import org.springframework.web.bind.annotation.InitBinder;
26
import org.springframework.web.bind.annotation.PathVariable;
27
import org.springframework.web.bind.annotation.RequestMapping;
28
import org.springframework.web.bind.annotation.RequestMethod;
29
import org.springframework.web.bind.annotation.RequestParam;
30

  
31
import eu.etaxonomy.cdm.api.service.IClassificationService;
32
import eu.etaxonomy.cdm.api.service.ITermService;
33
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
34
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
35
import eu.etaxonomy.cdm.model.name.Rank;
36
import eu.etaxonomy.cdm.model.taxon.Classification;
37
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
38
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;
39
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
40
import eu.etaxonomy.cdm.remote.editor.UuidList;
41

  
42
/**
43
 * @author a.kohlbecker
44
 * @date 03.06.2010
45
 *
46
 */
47
@Controller
48
@Api("classification")
49
@RequestMapping(value = {"/classification/{uuid}"})
50
public class ClassificationController extends BaseController<Classification,IClassificationService> {
51

  
52

  
53
    private ITermService termService;
54

  
55
    @Override
56
    @Autowired
57
    public void setService(IClassificationService service) {
58
        this.service = service;
59
    }
60

  
61
    @Autowired
62
    public void setTermService(ITermService termService) {
63
        this.termService = termService;
64
    }
65

  
66

  
67
    @InitBinder
68
    @Override
69
    public void initBinder(WebDataBinder binder) {
70
        super.initBinder(binder);
71
        binder.registerCustomEditor(Rank.class, new RankPropertyEditor());
72
        binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());
73
    }
74

  
75
    private List<String> NODE_INIT_STRATEGY(){
76
        return Arrays.asList(new String[]{
77
            "taxon.name"
78
    });}
79

  
80
    /**
81
     * @param classificationUuid
82
     * @param response
83
     * @return
84
     * @throws IOException
85
     *
86
     */
87
    @RequestMapping(
88
            value = {"childNodes"},
89
            method = RequestMethod.GET)
90
    public List<TaxonNode> getChildNodes(
91
            @PathVariable("uuid") UUID classificationUuid,
92
            HttpServletRequest request,
93
            HttpServletResponse response
94
            ) throws IOException {
95

  
96
        return getChildNodesAtRank(classificationUuid, null, request, response);
97
    }
98

  
99
    @RequestMapping(
100
            value = {"childNodesAt/{rankUuid}"},
101
            method = RequestMethod.GET)
102
    public List<TaxonNode> getChildNodesAtRank(
103
            @PathVariable("uuid") UUID classificationUuid,
104
            @PathVariable("rankUuid") UUID rankUuid,
105
            HttpServletRequest request,
106
            HttpServletResponse response
107
            ) throws IOException {
108

  
109
        logger.info("getChildNodesAtRank() - " + request.getRequestURI());
110

  
111
        Classification classification = service.find(classificationUuid);
112

  
113
        if(classification == null) {
114
            response.sendError(404 , "Classification not found using " + classificationUuid );
115
            return null;
116
        }
117
        Rank rank = findRank(rankUuid);
118

  
119
//        long start = System.currentTimeMillis();
120
        List<TaxonNode> rootNodes = service.listRankSpecificRootNodes(classification, rank, null, null, NODE_INIT_STRATEGY());
121
//        System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start));
122

  
123
        return rootNodes;
124
    }
125

  
126
    private Rank findRank(UUID rankUuid) {
127
        Rank rank = null;
128
        if(rankUuid != null){
129
            DefinedTermBase<?> definedTermBase =  termService.find(rankUuid);
130
            if(definedTermBase instanceof Rank){
131
                rank = (Rank) definedTermBase;
132
            } else {
133
               throw new IllegalArgumentException("DefinedTermBase is not a Rank");
134
            }
135
        }
136
        return rank;
137
    }
138

  
139
    /**
140
     * @param classificationUuid
141
     * @param response
142
     * @return
143
     * @throws IOException
144
     */
145
    @RequestMapping(
146
            value = {"groupedTaxa"},
147
            method = RequestMethod.GET)
148
    public List<GroupedTaxonDTO> getGroupedTaxaByHigherTaxon(
149
            @PathVariable("uuid") UUID classificationUuid,
150
            @RequestParam(value = "taxonUuids", required = true) UuidList taxonUuids,
151
            @RequestParam(value = "minRankUuid", required = false) UUID minRankUuid,
152
            @RequestParam(value = "maxRankUuid", required = false) UUID maxRankUuid,
153
            HttpServletRequest request,
154
            HttpServletResponse response
155
            ) throws IOException {
156

  
157
        logger.info("getGroupedTaxaByHigherTaxon() - " + request.getRequestURI());
158

  
159
        Classification classification = service.find(classificationUuid);
160
        if(classification == null) {
161
            response.sendError(404 , "Classification not found using " + classificationUuid );
162
            return null;
163
        }
164

  
165

  
166
        Rank minRank = findRank(minRankUuid);
167
        Rank maxRank = findRank(maxRankUuid);
168

  
169
//        long start = System.currentTimeMillis();
170
        List<GroupedTaxonDTO> result = service.groupTaxaByHigherTaxon(taxonUuids, classificationUuid, minRank, maxRank);
171
//        System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start));
172

  
173
        return result;
174
    }
175
}
1
// $Id$
2
/**
3
* Copyright (C) 2009 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 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.web.bind.WebDataBinder;
25
import org.springframework.web.bind.annotation.InitBinder;
26
import org.springframework.web.bind.annotation.PathVariable;
27
import org.springframework.web.bind.annotation.RequestMapping;
28
import org.springframework.web.bind.annotation.RequestMethod;
29
import org.springframework.web.bind.annotation.RequestParam;
30

  
31
import eu.etaxonomy.cdm.api.service.IClassificationService;
32
import eu.etaxonomy.cdm.api.service.ITermService;
33
import eu.etaxonomy.cdm.api.service.dto.GroupedTaxonDTO;
34
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
35
import eu.etaxonomy.cdm.model.name.Rank;
36
import eu.etaxonomy.cdm.model.taxon.Classification;
37
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
38
import eu.etaxonomy.cdm.remote.editor.RankPropertyEditor;
39
import eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor;
40
import eu.etaxonomy.cdm.remote.editor.UuidList;
41

  
42
/**
43
 * @author a.kohlbecker
44
 * @date 03.06.2010
45
 *
46
 */
47
@Controller
48
@Api("classification")
49
@RequestMapping(value = {"/classification/{uuid}"})
50
public class ClassificationController extends BaseController<Classification,IClassificationService> {
51

  
52

  
53
    private ITermService termService;
54

  
55
    @Override
56
    @Autowired
57
    public void setService(IClassificationService service) {
58
        this.service = service;
59
    }
60

  
61
    @Autowired
62
    public void setTermService(ITermService termService) {
63
        this.termService = termService;
64
    }
65

  
66

  
67
    @InitBinder
68
    @Override
69
    public void initBinder(WebDataBinder binder) {
70
        super.initBinder(binder);
71
        binder.registerCustomEditor(Rank.class, new RankPropertyEditor());
72
        binder.registerCustomEditor(UuidList.class, new UUIDListPropertyEditor());
73
    }
74

  
75
    private List<String> NODE_INIT_STRATEGY(){
76
        return Arrays.asList(new String[]{
77
            "taxon.name"
78
    });}
79

  
80
    /**
81
     * @param classificationUuid
82
     * @param response
83
     * @return
84
     * @throws IOException
85
     *
86
     */
87
    @RequestMapping(
88
            value = {"childNodes"},
89
            method = RequestMethod.GET)
90
    public List<TaxonNode> getChildNodes(
91
            @PathVariable("uuid") UUID classificationUuid,
92
            HttpServletRequest request,
93
            HttpServletResponse response
94
            ) throws IOException {
95

  
96
        return getChildNodesAtRank(classificationUuid, null, request, response);
97
    }
98

  
99
    @RequestMapping(
100
            value = {"childNodesAt/{rankUuid}"},
101
            method = RequestMethod.GET)
102
    public List<TaxonNode> getChildNodesAtRank(
103
            @PathVariable("uuid") UUID classificationUuid,
104
            @PathVariable("rankUuid") UUID rankUuid,
105
            HttpServletRequest request,
106
            HttpServletResponse response
107
            ) throws IOException {
108

  
109
        logger.info("getChildNodesAtRank() - " + request.getRequestURI());
110

  
111
        Classification classification = service.find(classificationUuid);
112

  
113
        if(classification == null) {
114
            response.sendError(404 , "Classification not found using " + classificationUuid );
115
            return null;
116
        }
117
        Rank rank = findRank(rankUuid);
118

  
119
//        long start = System.currentTimeMillis();
120
        List<TaxonNode> rootNodes = service.listRankSpecificRootNodes(classification, rank, null, null, NODE_INIT_STRATEGY());
121
//        System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start));
122

  
123
        return rootNodes;
124
    }
125

  
126

  
127
    /**
128
     * @param classificationUuid
129
     * @param response
130
     * @return
131
     * @throws IOException
132
     */
133
    @RequestMapping(
134
            value = {"groupedTaxa"},
135
            method = RequestMethod.GET)
136
    public List<GroupedTaxonDTO> getGroupedTaxaByHigherTaxon(
137
            @PathVariable("uuid") UUID classificationUuid,
138
            @RequestParam(value = "taxonUuids", required = true) UuidList taxonUuids,
139
            @RequestParam(value = "minRankUuid", required = false) UUID minRankUuid,
140
            @RequestParam(value = "maxRankUuid", required = false) UUID maxRankUuid,
141
            HttpServletRequest request,
142
            HttpServletResponse response
143
            ) throws IOException {
144

  
145
        logger.info("getGroupedTaxaByHigherTaxon() - " + request.getRequestURI());
146

  
147
        Classification classification = service.find(classificationUuid);
148
        if(classification == null) {
149
            response.sendError(404 , "Classification not found using " + classificationUuid );
150
            return null;
151
        }
152

  
153

  
154
        Rank minRank = findRank(minRankUuid);
155
        Rank maxRank = findRank(maxRankUuid);
156

  
157
//        long start = System.currentTimeMillis();
158
        List<GroupedTaxonDTO> result = service.groupTaxaByHigherTaxon(taxonUuids, classificationUuid, minRank, maxRank);
159
//        System.err.println("service.listRankSpecificRootNodes() " + (System.currentTimeMillis() - start));
160

  
161
        return result;
162
    }
163

  
164

  
165
    private Rank findRank(UUID rankUuid) {
166
        Rank rank = null;
167
        if(rankUuid != null){
168
            DefinedTermBase<?> definedTermBase =  termService.find(rankUuid);
169
            if(definedTermBase instanceof Rank){
170
                rank = (Rank) definedTermBase;
171
            } else {
172
               throw new IllegalArgumentException("DefinedTermBase is not a Rank");
173
            }
174
        }
175
        return rank;
176
    }
177
}

Also available in: Unified diff