Project

General

Profile

Download (2.34 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
 * Copyright (C) 2007 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

    
11
package eu.etaxonomy.cdm.remote.json.processor.bean;
12

    
13
import java.util.List;
14

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

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

    
30

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

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

    
63
}
(20-20/25)