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 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");
50 json
.element("secUuid", node
.getTaxon().getSec().getUuid(), jsonConfig
);
52 json
.element("taxonomicChildrenCount", node
.getCountChildren(), jsonConfig
);
53 json
.element("unplaced", node
.getTaxon().isUnplaced());
54 json
.element("excluded", node
.getTaxon().isExcluded());
55 String ranklabel
= null;
56 if(node
.getTaxon().getName().getRank() != null){
57 ranklabel
= node
.getTaxon().getName().getRank().getLabel();
59 json
.element("rankLabel", ranklabel
, jsonConfig
);
60 //json.element("treeUuid", node.getClassification().getUuid(), jsonConfig);