json serialisatoin of Map<Language, LanguageString> & refactoring
[cdmlib.git] / cdmlib-remote / src / main / java / eu / etaxonomy / cdm / remote / json / processor / bean / TaxonNodeDaoBeanProcessor.java
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 net.sf.json.CycleSetAcess;
16 import net.sf.json.JSONObject;
17 import net.sf.json.JsonConfig;
18 import net.sf.json.processors.JsonBeanProcessor;
19 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
20 import eu.etaxonomy.cdm.remote.dto.TaggedText;
21
22 /**
23 * WARNING! The idea i started implementing here will not work at all!!
24 * @author a.kohlbecker
25 *
26 */
27 public class TaxonNodeDaoBeanProcessor extends CycleSetAcess implements JsonBeanProcessor {
28
29
30 /* (non-Javadoc)
31 * @see net.sf.json.processors.JsonBeanProcessor#processBean(java.lang.Object, net.sf.json.JsonConfig)
32 */
33 public JSONObject processBean(Object bean, JsonConfig jsonConfig) {
34
35 TaxonNode node = (TaxonNode)bean;
36 JSONObject json = new JSONObject();
37 json.element("class", "TaxonNodeDao");
38 json.element("titleCache", node.getTaxon().getName().getTitleCache(), jsonConfig);
39 List<TaggedText> taggedTitle = TaxonNameBaseBeanProcessor.getTaggedName(node.getTaxon().getName());
40 json.element("taggedTitle", taggedTitle, jsonConfig);
41 json.element("taxonUuid", node.getTaxon().getUuid(), jsonConfig);
42 json.element("secUuid", node.getTaxon().getSec().getUuid(), jsonConfig);
43 json.element("taxonomicChildrenCount", node.getCountChildren(), jsonConfig);
44 json.element("rankLabel", node.getTaxon().getName().getRank().getLabel(), jsonConfig);
45 //json.element("treeUuid", node.getTaxonomicTree().getUuid(), jsonConfig);
46
47 return json;
48 }
49
50 }