1
|
// $Id: TaxonBaseBeanProcessor.java 5473 2009-03-25 13:42:07Z a.kohlbecker $
|
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.bean;
|
12
|
|
13
|
import java.util.Arrays;
|
14
|
import java.util.List;
|
15
|
|
16
|
import net.sf.json.JSONObject;
|
17
|
import net.sf.json.JsonConfig;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
22
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
23
|
|
24
|
/**
|
25
|
* @author a.kohlbecker
|
26
|
*
|
27
|
*/
|
28
|
public class TaxonNameBaseBeanProcessor extends AbstractCdmBeanProcessor<TaxonNameBase> {
|
29
|
|
30
|
public static final Logger logger = Logger.getLogger(TaxonNameBaseBeanProcessor.class);
|
31
|
|
32
|
private boolean skipTaggedName = false;
|
33
|
|
34
|
/**
|
35
|
* @return the skipTaggedName
|
36
|
*/
|
37
|
public boolean isSkipTaggedName() {
|
38
|
return skipTaggedName;
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* @param skipTaggedName the skipTaggedName to set
|
43
|
*/
|
44
|
public void setSkipTaggedName(boolean skipTaggedName) {
|
45
|
this.skipTaggedName = skipTaggedName;
|
46
|
}
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#getIgnorePropNames()
|
50
|
*/
|
51
|
@Override
|
52
|
public List<String> getIgnorePropNames() {
|
53
|
return Arrays.asList(new String[]{
|
54
|
// ignore nameRelations to avoid LazyLoadingExceptions coming
|
55
|
// from NameRelationshipBeanProcessor.secondStep() in which
|
56
|
// the transient field fromName is added to the serialization
|
57
|
"relationsFromThisName",
|
58
|
"relationsToThisName",
|
59
|
"combinationAuthorship",
|
60
|
"basionymAuthorship",
|
61
|
"exCombinationAuthorship",
|
62
|
"exBasionymAuthorship"
|
63
|
});
|
64
|
}
|
65
|
|
66
|
/* (non-Javadoc)
|
67
|
* @see eu.etaxonomy.cdm.remote.json.processor.AbstractCdmBeanProcessor#processBeanSecondStage(java.lang.Object, net.sf.json.JSONObject, net.sf.json.JsonConfig)
|
68
|
*/
|
69
|
@Override
|
70
|
public JSONObject processBeanSecondStep(TaxonNameBase bean, JSONObject json, JsonConfig jsonConfig) {
|
71
|
if(logger.isDebugEnabled()){
|
72
|
logger.debug("processing second step" + bean);
|
73
|
}
|
74
|
if(!skipTaggedName){
|
75
|
json.element("taggedName", bean.getTaggedName(), jsonConfig);
|
76
|
}
|
77
|
if(bean instanceof NonViralName){
|
78
|
json.element("nameCache", ((NonViralName) bean).getNameCache(), jsonConfig);
|
79
|
}
|
80
|
return json;
|
81
|
}
|
82
|
|
83
|
}
|