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