Project

General

Profile

Download (2.34 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.json.processor.bean;
11

    
12
import java.util.List;
13

    
14
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
15
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
16
import net.sf.json.JSONObject;
17
import net.sf.json.JsonConfig;
18
import net.sf.json.processors.JsonBeanProcessor;
19

    
20
/**
21
 * @author a.kohlbecker
22
 * @since 29.07.2010
23
 *
24
 * @deprecated use the eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto instead for all classification web service endpoints
25
 */
26
@Deprecated
27
public class TaxonNodeDtoBeanProcessor implements JsonBeanProcessor {
28

    
29

    
30
    @Override
31
    public JSONObject processBean(Object bean, JsonConfig jsonConfig) {
32

    
33
        TaxonNode node = (TaxonNode)bean;
34
        JSONObject json = new JSONObject();
35
        json.element("class", "TaxonNodeDto");
36
        json.element("uuid", node.getUuid(), jsonConfig);
37
        json.element("taxonomicChildrenCount", node.getCountChildren(), jsonConfig);
38
        //json.element("classificationUuid", node.getClassification().getUuid(), jsonConfig);
39
        if(node.getTaxon() != null){
40
            json.element("titleCache", node.getTaxon().getName().getTitleCache(), jsonConfig);
41
            List<TaggedText> taggedTitle = node.getTaxon().getName().getTaggedName();
42
            json.element("taggedTitle", taggedTitle, jsonConfig);
43
            json.element("taxonUuid", node.getTaxon().getUuid(), jsonConfig);
44
            //Sec can be null (web services can return null for sec)
45
            //comparation made for avoiding view exceptions
46
            if (node.getTaxon().getSec() == null){
47
                json.element("secUuid", "null");
48
            }else{
49
                json.element("secUuid", node.getTaxon().getSec().getUuid(), jsonConfig);
50
            }
51
            json.element("unplaced", node.isUnplaced());
52
            json.element("excluded", node.isExcluded());
53
            String ranklabel = null;
54
            if(node.getTaxon().getName().getRank() != null){
55
                ranklabel = node.getTaxon().getName().getRank().getLabel();
56
            }
57
            json.element("rankLabel", ranklabel, jsonConfig);
58
        }
59
        return json;
60
    }
61

    
62
}
(20-20/25)