1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2009 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;
|
12
|
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.Arrays;
|
15
|
import java.util.List;
|
16
|
|
17
|
import net.sf.json.JSONObject;
|
18
|
import net.sf.json.JsonConfig;
|
19
|
import net.sf.json.processors.JsonBeanProcessor;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.hibernate.Hibernate;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
25
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
26
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
27
|
|
28
|
/**
|
29
|
* @author a.kohlbecker
|
30
|
*
|
31
|
*/
|
32
|
public class TaxonBeanProcessor extends AbstractCdmBeanProcessor<Taxon> {
|
33
|
|
34
|
public static final Logger logger = Logger.getLogger(TaxonBeanProcessor.class);
|
35
|
|
36
|
/* (non-Javadoc)
|
37
|
* @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#getIgnorePropNames()
|
38
|
*/
|
39
|
@Override
|
40
|
public List<String> getIgnorePropNames() {
|
41
|
return Arrays.asList(new String[]{
|
42
|
"taxonomicParent" //TODO put in json-config ignore list
|
43
|
});
|
44
|
}
|
45
|
|
46
|
/* (non-Javadoc)
|
47
|
* @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#processBeanSecondStage(java.lang.Object, net.sf.json.JSONObject, net.sf.json.JsonConfig)
|
48
|
*/
|
49
|
@Override
|
50
|
public JSONObject processBeanSecondStep(Taxon bean, JSONObject json, JsonConfig jsonConfig) {
|
51
|
// if(logger.isDebugEnabled()){
|
52
|
// logger.debug("processing second step" + bean);
|
53
|
// }
|
54
|
//
|
55
|
// if(Hibernate.isInitialized(bean.getName()) && Hibernate.isInitialized(bean.getName().getHomotypicalGroup())){
|
56
|
//
|
57
|
// json.element("homotypicSynonyms", bean.getHomotypicSynonymsByHomotypicGroup(), jsonConfig);
|
58
|
//
|
59
|
// List<HomotypicalGroup> hsgl = bean.getHeterotypicSynonymyGroups();
|
60
|
// List<List<Synonym>> heterotypicSynonymyGroups = new ArrayList<List<Synonym>>(hsgl.size());
|
61
|
// for(HomotypicalGroup hsg : hsgl){
|
62
|
// heterotypicSynonymyGroups.add(hsg.getSynonymsInGroup(bean.getSec()));
|
63
|
// }
|
64
|
//
|
65
|
// json.element("heterotypicSynonymyGroups", heterotypicSynonymyGroups, jsonConfig);
|
66
|
// }
|
67
|
return json;
|
68
|
}
|
69
|
|
70
|
}
|