3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.remote
.json
.processor
.bean
;
13 import java
.util
.List
;
15 import net
.sf
.json
.JSONObject
;
16 import net
.sf
.json
.JsonConfig
;
17 import net
.sf
.json
.processors
.JsonBeanProcessor
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
19 import eu
.etaxonomy
.cdm
.strategy
.TaggedText
;
20 import eu
.etaxonomy
.cdm
.strategy
.TaggedTextGenerator
;
23 * @author a.kohlbecker
27 public class TaxonNodeDaoBeanProcessor
implements JsonBeanProcessor
{
31 * @see net.sf.json.processors.JsonBeanProcessor#processBean(java.lang.Object, net.sf.json.JsonConfig)
34 public JSONObject
processBean(Object bean
, JsonConfig jsonConfig
) {
36 TaxonNode node
= (TaxonNode
)bean
;
37 JSONObject json
= new JSONObject();
38 json
.element("class", "TaxonNodeDao");
39 json
.element("uuid", node
.getUuid(), jsonConfig
);
40 json
.element("titleCache", node
.getTaxon().getName().getTitleCache(), jsonConfig
);
41 List
<TaggedText
> taggedTitle
= TaggedTextGenerator
.getTaggedName(node
.getTaxon().getName());
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");
49 json
.element("secUuid", node
.getTaxon().getSec().getUuid(), jsonConfig
);
51 json
.element("taxonomicChildrenCount", node
.getCountChildren(), jsonConfig
);
52 json
.element("unplaced", node
.getTaxon().isUnplaced());
53 json
.element("excluded", node
.getTaxon().isExcluded());
54 String ranklabel
= null;
55 if(node
.getTaxon().getName().getRank() != null){
56 ranklabel
= node
.getTaxon().getName().getRank().getLabel();
58 json
.element("rankLabel", ranklabel
, jsonConfig
);
59 //json.element("treeUuid", node.getClassification().getUuid(), jsonConfig);